[ovs-dev] [PATCHv3 5/5] bridge: Only store instant_stats on device changes

Joe Stringer joestringer at nicira.com
Mon Nov 25 21:44:22 UTC 2013


Currently, we iterat through all interfaces in instant_stats_run(), grabbing
up-to-date information about device status. After assembling all of this
information for all interfaces, we determine whether anything changed and only
send an update to ovsdb-server if something changed.

This patch uses connectivity_seq to determine whether there have been any
changes prior to polling all interfaces, allowing us to skip port polling when
nothing changes. In a test environment of 5000 internal ports and 50 tunnel
ports with bfd, this reduces average CPU usage from around 20%->5%. When ports
change status more often than every 100ms, CPU usage will increase to previous
rates.

Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
v3: Track sequence statically, not per-bridge
    Don't wake up on sequence change
v2: Initial post
---
 vswitchd/bridge.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 17fd3ce..2f5623a 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -170,6 +170,9 @@ static struct ovsdb_idl_txn *daemonize_txn;
 /* Most recently processed IDL sequence number. */
 static unsigned int idl_seqno;
 
+/* Track changes to port connectivity. */
+static uint64_t connectivity_seqno = LLONG_MIN;
+
 /* Each time this timer expires, the bridge fetches interface and mirror
  * statistics and pushes them into the database. */
 #define IFACE_STATS_INTERVAL (5 * 1000) /* In milliseconds. */
@@ -2254,12 +2257,19 @@ instant_stats_run(void)
 
     if (!instant_txn) {
         struct bridge *br;
+        uint64_t seq;
 
         if (time_msec() < instant_next_txn) {
             return;
         }
         instant_next_txn = time_msec() + INSTANT_INTERVAL_MSEC;
 
+        seq = connectivity_seq_read();
+        if (seq == connectivity_seqno) {
+            return;
+        }
+        connectivity_seqno = seq;
+
         instant_txn = ovsdb_idl_txn_create(idl);
         HMAP_FOR_EACH (br, node, &all_bridges) {
             struct iface *iface;
-- 
1.7.9.5




More information about the dev mailing list