2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-17 14:28:02 +00:00

bridge: Only store instant_stats on device changes

Previously, we iterated through all interfaces in instant_stats_run(),
grabbing up-to-date information about device and port 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 connectivity_seq to determine whether
there have been any changes before polling all interfaces, which reduces
unnecessary processing in the average case. In a test environment of
5000 internal ports and 50 tunnel ports with bfd, this reduces average
CPU usage of the main thread from about 15% to about 5%. When ports
change status more often than every 100ms, CPU usage is expected to
increase to previous rates.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
Joe Stringer
2013-12-13 03:33:49 +00:00
committed by Ethan Jackson
parent f23d157c05
commit 7f8f2757f3

View File

@@ -22,6 +22,7 @@
#include "bfd.h"
#include "bitmap.h"
#include "cfm.h"
#include "connectivity.h"
#include "coverage.h"
#include "daemon.h"
#include "dirs.h"
@@ -41,6 +42,7 @@
#include "ofproto/bond.h"
#include "ofproto/ofproto.h"
#include "poll-loop.h"
#include "seq.h"
#include "sha1.h"
#include "shash.h"
#include "smap.h"
@@ -155,6 +157,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. */
@@ -2164,12 +2169,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 = seq_read(connectivity_seq_get());
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;