Previously, we iterated 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 would determine whether anything changed and only send an update to ovsdb-server if something changed.
This patch uses the new global netdev_seq to determine whether there have been any changes before polling all interfaces, which provides further CPU usage savings. In a test environment of 5000 internal ports and 50 tunnel ports with bfd, this reduces CPU usage to around 5%. When ports change status more often than every 100ms, CPU usage will increase to previous rates. Signed-off-by: Joe Stringer <joestrin...@nicira.com> --- v4: Rebase --- vswitchd/bridge.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 6da5e93..4c35ebb 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 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev