From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D541E43EB3; Fri, 19 Apr 2024 20:50:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 58B7340698; Fri, 19 Apr 2024 20:50:00 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 6887040696 for ; Fri, 19 Apr 2024 20:49:59 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 3CBC620D62; Fri, 19 Apr 2024 20:49:59 +0200 (CEST) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH v4 3/6] latencystats: do not use floating point Date: Fri, 19 Apr 2024 20:49:56 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F3CE@smartserver.smartshare.dk> In-Reply-To: <20240419172926.55447-4-stephen@networkplumber.org> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH v4 3/6] latencystats: do not use floating point Thread-Index: AdqSfzV09eGfNnhtT3OnLCegiBNErQACbFrQ References: <20240408195036.182545-1-stephen@networkplumber.org> <20240419172926.55447-1-stephen@networkplumber.org> <20240419172926.55447-4-stephen@networkplumber.org> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Stephen Hemminger" , Cc: "Tyler Retzlaff" , "Reshma Pattan" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > + if (unlikely(first_sample)) { > + first_sample =3D false; > + > glob_stats->min_latency =3D latency; > - else if (latency > glob_stats->max_latency) > glob_stats->max_latency =3D latency; > - /* > - * The average latency is measured using exponential moving > - * average, i.e. using EWMA > - * https://en.wikipedia.org/wiki/Moving_average > - */ > - glob_stats->avg_latency +=3D > - alpha * (latency - glob_stats->avg_latency); > + glob_stats->avg_latency =3D latency; > + glob_stats->jitter =3D latency / 2; Setting jitter at first sample as latency / 2 is wrong. Jitter should remain zero at first sample. > + } else { > + /* > + * The jitter is calculated as statistical mean of > interpacket > + * delay variation. The "jitter estimate" is computed > by taking > + * the absolute values of the ipdv sequence and > applying an > + * exponential filter with parameter 1/16 to generate > the > + * estimate. i.e J=3DJ+(|D(i-1,i)|-J)/16. Where J is > jitter, > + * D(i-1,i) is difference in latency of two > consecutive packets > + * i-1 and i. > + * Reference: Calculated as per RFC 5481, sec 4.1, > + * RFC 3393 sec 4.5, RFC 1889 sec. > + */ > + glob_stats->jitter +=3D ((prev_latency - latency) > + - glob_stats->jitter) / 16; With jitter remaining zero at first sample, Acked-by: Morten Br=F8rup