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 5B7AC42B13; Mon, 15 May 2023 14:38:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E2A5140687; Mon, 15 May 2023 14:38:34 +0200 (CEST) Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) by mails.dpdk.org (Postfix) with ESMTP id C718340395 for ; Mon, 15 May 2023 14:38:33 +0200 (CEST) Received: by mail-ua1-f41.google.com with SMTP id a1e0cc1a2514c-77d46c7dd10so57833321241.0 for ; Mon, 15 May 2023 05:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684154313; x=1686746313; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dDz6lCqhEmRndyUzdoHkMdz0pCPmjc7sQqQGYJ6Q1F4=; b=f0GwcCvcAZCnLHpXQM5kezESkT7202FU67nLD74zeuk32zZ+fTLNDenUghUeWhBn8S ENBD/ykylVKBCN+Xk8enQuj+m8KvshPk3MNrU0v5QScvsR3MVW5patcDu3/2kBGuT+So bXK8kLTPwm6Y5NWmQkU0tRhroZjqVUqMcqowx1soAfP7pQSbPCNSa/7iI2H/NBmMina0 1VwhDsQTmNROO3FvED7a1BNk4fUtH15TD1ID7bpdljepyAbSOEn7V2G+5I+0vJMClECu EHs4ObgAEyDN6lDvLpOKEFavkbkW/SfBLqY1Af+wdBf6ZEXcvyZubxxBaJ2IAjbEMIkR neog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684154313; x=1686746313; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dDz6lCqhEmRndyUzdoHkMdz0pCPmjc7sQqQGYJ6Q1F4=; b=gVftOfVNWnP2E4DAofoq0b1jo9CYW1MN2AIsiHwWsgYfIUNo/APhtGCxTHlTctSRQ4 modN7MJS53DfyaUQXvtL6opnMWawUVAi+ifHXSMZBPLA32po8RhZO5T+ORzGeSrfzsER 576MjhtaQ72fTWaPXWwG+IVeUfbCZQ2gwNdRS1+IN3MKsbrQUAWyO17n02jAUoTVpNsD bGWWWqX2U3BbOWYm14nHJT9QTx13qkBclMFNV4g/NzjTDYxS2+aCGJclPfNDfZjnxpUJ IwAC0IE5CIB/O/Hc3wc8SGhSlCk0uYvOjpssygXSyvIO1zDlCezhl6GmgSfEQc0YLqGM OwLQ== X-Gm-Message-State: AC+VfDy941Y/yXfZrvzTPAuTwxyby+vJ/K2LA/WiwmIMo53c1ASNZVZb 6+iTUGE7Q9not4KAEUKmRd+so/K8cHJyXywyOhk= X-Google-Smtp-Source: ACHHUZ57dyLfJKcblo83AekhAmG/XvTlnYMTLameKrlVE0Fnkd4ycqEZVDO6QqZMg/l9LSwlvz1W3ZsRn3kcz0nniFk= X-Received: by 2002:a1f:4597:0:b0:43f:e623:952 with SMTP id s145-20020a1f4597000000b0043fe6230952mr12181977vka.2.1684154312985; Mon, 15 May 2023 05:38:32 -0700 (PDT) MIME-Version: 1.0 References: <20230511081641.6693-1-mattias.ronnblom@ericsson.com> <20230511082415.6720-1-mattias.ronnblom@ericsson.com> <7c0013e1-d11b-2ad0-04b9-73be426d4719@ericsson.com> In-Reply-To: <7c0013e1-d11b-2ad0-04b9-73be426d4719@ericsson.com> From: Jerin Jacob Date: Mon, 15 May 2023 18:08:06 +0530 Message-ID: Subject: Re: [PATCH v3] eventdev: avoid non-burst shortcut for variable-size bursts To: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= Cc: "jerinj@marvell.com" , "hofors@lysator.liu.se" , "dev@dpdk.org" , =?UTF-8?Q?Morten_Br=C3=B8rup?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Fri, May 12, 2023 at 6:45=E2=80=AFPM Mattias R=C3=B6nnblom wrote: > > On 2023-05-12 13:59, Jerin Jacob wrote: > > On Thu, May 11, 2023 at 2:00=E2=80=AFPM Mattias R=C3=B6nnblom > > wrote: > >> > >> Use non-burst event enqueue and dequeue calls from burst enqueue and > >> dequeue only when the burst size is compile-time constant (and equal > >> to one). > >> > >> Signed-off-by: Mattias R=C3=B6nnblom > >> > >> --- > >> > >> v3: Actually include the change v2 claimed to contain. > >> v2: Wrap builtin call in __extension__, to avoid compiler warnings if > >> application is compiled with -pedantic. (Morten Br=C3=B8rup) > >> --- > >> lib/eventdev/rte_eventdev.h | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/lib/eventdev/rte_eventdev.h b/lib/eventdev/rte_eventdev.h > >> index a90e23ac8b..a471caeb6d 100644 > >> --- a/lib/eventdev/rte_eventdev.h > >> +++ b/lib/eventdev/rte_eventdev.h > >> @@ -1944,7 +1944,7 @@ __rte_event_enqueue_burst(uint8_t dev_id, uint8_= t port_id, > >> * Allow zero cost non burst mode routine invocation if appli= cation > >> * requests nb_events as const one > >> */ > >> - if (nb_events =3D=3D 1) > >> + if (__extension__(__builtin_constant_p(nb_events)) && nb_event= s =3D=3D 1) > > > > "Why" part is not clear from the commit message. Is this to avoid > > nb_events read if it is built-in const. > > The __builtin_constant_p() is introduced to avoid having the compiler > generate a conditional branch and two different code paths in case > nb_elem is a run-time variable. > > In particular, this matters if nb_elems is run-time variable and varies > between 1 and some larger value. > > I should have mention this in the commit message. > > A very slight performance improvement. It also makes the code better > match the comment, imo. Zero cost for const one enqueues, but no impact > non-compile-time-constant-length enqueues. > > Feel free to ignore. I did some performance comparison of the patch. A low-end ARM machines shows 0.7% drop with single event case. No regression see with high-end ARM cores with single event case. IMO, optimizing the check for burst mode(the new patch) may not show any real improvement as the cost is divided by number of event. Whereas optimizing the check for single event case(The current code) shows better performance with single event case and no regression with burst mode as cost is divided by number of events. If you agree, then we can skip this patch. > > > If so, check should be following. Right? > > > > if (__extension__((__builtin_constant_p(nb_events)) && nb_events =3D=3D= 1) > > || nb_events =3D=3D 1) > > > > At least, It was my original intention in the code. > > > > > > > >> return (fp_ops->enqueue)(port, ev); > >> else > >> return fn(port, ev, nb_events); > >> @@ -2200,7 +2200,7 @@ rte_event_dequeue_burst(uint8_t dev_id, uint8_t = port_id, struct rte_event ev[], > >> * Allow zero cost non burst mode routine invocation if appli= cation > >> * requests nb_events as const one > >> */ > >> - if (nb_events =3D=3D 1) > >> + if (__extension__(__builtin_constant_p(nb_events)) && nb_event= s =3D=3D 1) > >> return (fp_ops->dequeue)(port, ev, timeout_ticks); > >> else > >> return (fp_ops->dequeue_burst)(port, ev, nb_events, > >> -- > >> 2.34.1 > >> >