From patchwork Mon Aug 29 22:32:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil McKee X-Patchwork-Id: 663858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sNRHq28g0z9s9W for ; Tue, 30 Aug 2016 08:33:09 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=inmon-com.20150623.gappssmtp.com header.i=@inmon-com.20150623.gappssmtp.com header.b=m7IpJ5p3; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 9EC1D105E2; Mon, 29 Aug 2016 15:33:08 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 73A3E10585 for ; Mon, 29 Aug 2016 15:33:07 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id D6F6D420340 for ; Mon, 29 Aug 2016 16:33:06 -0600 (MDT) X-ASG-Debug-ID: 1472509985-09eadd5bb205000001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar5.cudamail.com with ESMTP id lyBcWNmcpGW7Vrqh (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 29 Aug 2016 16:33:05 -0600 (MDT) X-Barracuda-Envelope-From: neil.mckee@inmon.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mail-yb0-f169.google.com) (209.85.213.169) by mx3-pf2.cudamail.com with ESMTPS (AES128-SHA encrypted); 29 Aug 2016 22:33:04 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at _netblocks.google.com designates 209.85.213.169 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.213.169 Received: by mail-yb0-f169.google.com with SMTP id x93so629823ybh.1 for ; Mon, 29 Aug 2016 15:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inmon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=A1r9g+8y+Tmjn3tF2kilC4tf9n4hgTpOPzEzv6Gn2ss=; b=m7IpJ5p3HEB8ORTU26/brZVG36uuezhqn0uFyPQGKLMTSpsNsOW95oq0NLDX79LKuo 5rDW3de3R90kA/TsVoAVwzEcNab5TMkKj7Fj8qKJFgotzlrkG2OPxL8U+XHd7OgBLuyT mPYY3h1l7ZQwEezPrAqG74sBf3HcNZh/ABH6ls8z+Cv3VVA4NvibChOlWOyIEw6jvD32 mm24AAB5l2U/go1IeuzkYmb5kDkLNpeQXwXXQ/FDK60TBgvN201qg+5buwO0GNWvSeF7 k59A6gqQ1Hb2NGFPmm7lxFiz5ts9tSLA1WoDGuEL3df5Xduua1wH+M+WGl/K6itejw7P fzMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=A1r9g+8y+Tmjn3tF2kilC4tf9n4hgTpOPzEzv6Gn2ss=; b=facpEimpfdQ+T08Er/Il7g1IRf7jjvXL3QLCNY1QBe5sOTx4vdUArmermV8ZTTusYG d4S9pnLaqKve9yB0KgdN6ace4bpfWOtxgneYgswEmxpx84qZQperGvjit+XIuNQRk6dQ VcGRRsjGeBBAsUW+eWfCk9XqY0ZHMGWVG+DDo+uWart9/zRMDD9I1RvYHcft6uDpowIZ kXHzu6H+ReyB3HDL1BQwLcQJ+2mPdQexmnhWnAkTOvwZNqGY5lQ6iAUW58pz2LMrUHC7 9AcWYYIyqmDPRiIKldD2FYs7LGEtmOOhXWGGZE4vqTrEffiCYEgl8KsXr9tP0H8uPOHO o0bA== X-Gm-Message-State: AE9vXwPbFrN032lGwdYw6KCz5n6XfKqcxDOSd64JUMlMdT8eomOSFsl3zlP++q09Mv5F0NQxoxIlVJo9Cl9+Ug== X-Received: by 10.37.65.82 with SMTP id o79mr292487yba.145.1472509982562; Mon, 29 Aug 2016 15:33:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.163.131 with HTTP; Mon, 29 Aug 2016 15:32:41 -0700 (PDT) X-Originating-IP: [38.128.195.34] X-CudaMail-Envelope-Sender: neil.mckee@inmon.com From: Neil McKee Date: Mon, 29 Aug 2016 15:32:41 -0700 Message-ID: X-CudaMail-MID: CM-V2-828051096 X-CudaMail-DTE: 082916 X-CudaMail-Originating-IP: 209.85.213.169 To: "dev@openvswitch.org" X-ASG-Orig-Subj: [##CM-V2-828051096##][PATCH] Flush freshly-polled sFlow counters promptly. X-GBUdb-Analysis: 0, 209.85.213.169, Ugly c=0.369283 p=-0.222222 Source Normal X-MessageSniffer-Rules: 0-0-0-7905-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1472509985 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.32439 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH] Flush freshly-polled sFlow counters promptly. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" This patch changes the order of the steps that are followed every second in the sFlow agent. By moving the receiver_tick() step to the end, we ensure that any counters that were polled during the poller_tick() step are flushed immediately to the sFlow collector. This eliminates what was a variable time-delay between counters being polled and being flushed. The variable time-delay that this eliminates could be up to a second because counters lingering in the output buffer could be flushed at any time by the arrival of random packet-samples. Since the sFlow standard does not require that a poll-timestamp be sent along with the counters the collector must use his receive-time as the timestamp, so that extra second of variable delay was "stretching or shrinking" the time between successive counter readings. This affected any counter-rate calculation that was based only on the delta between sucessive samples. The effect was small with a polling interval of 60 seconds: just +/- 2%. But the effect grew larger when faster polling was configured. For example, if the counters were pushed every 5 seconds then the instantaneous rate calculations could wander by +/- 20%. For a thorough analysis of this problem, see Rick Jones' paper: "High Frequency sFlow v5 Counter Sampling" ftp://ftp.netperf.org/papers/high_freq_sflow/hf_sflow_counters.pdf So this patch makes it possible to obtain usable results even when high-frequency polling is configured. Signed-off-by: Neil McKee --- lib/sflow_agent.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sflow_agent.c b/lib/sflow_agent.c index 9c2e028..878c3da 100644 --- a/lib/sflow_agent.c +++ b/lib/sflow_agent.c @@ -128,12 +128,15 @@ void sfl_agent_tick(SFLAgent *agent, time_t now) SFLSampler *sm = agent->samplers; SFLPoller *pl = agent->pollers; agent->now = now; - /* receivers use ticks to flush send data */ - for(; rcv != NULL; rcv = rcv->nxt) sfl_receiver_tick(rcv, now); /* samplers use ticks to decide when they are sampling too fast */ for(; sm != NULL; sm = sm->nxt) sfl_sampler_tick(sm, now); /* pollers use ticks to decide when to ask for counters */ for(; pl != NULL; pl = pl->nxt) sfl_poller_tick(pl, now); + /* receivers use ticks to flush send data. By doing this + * step last we ensure that fresh counters polled during + * sfl_poller_tick() above will be flushed promptly. + */ + for(; rcv != NULL; rcv = rcv->nxt) sfl_receiver_tick(rcv, now); } /*_________________---------------------------__________________