[ovs-dev] [PATCHv5 4/4] bridge: Only store instant_stats on device changes

Ethan Jackson ethan at nicira.com
Thu Dec 12 23:12:10 UTC 2013


Thanks Joe, I've merged the series.

Ethan

On Thu, Dec 12, 2013 at 11:33 AM, Joe Stringer <joestringer at nicira.com> wrote:
> 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 at nicira.com>
> Acked-by: Ethan Jackson <ethan at nicira.com>
> ---
> v5: Rebase
>     Tweak commit message
> ---
>  vswitchd/bridge.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
> index f3b03af..eb63105 100644
> --- a/vswitchd/bridge.c
> +++ b/vswitchd/bridge.c
> @@ -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;
> --
> 1.7.9.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list