DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru,
	dev@dpdk.org
Subject: Re: [PATCH] mempool: optimize get objects with constant n
Date: Tue, 18 Apr 2023 08:44:35 -0700	[thread overview]
Message-ID: <20230418154435.GA4574@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87891@smartserver.smartshare.dk>

On Tue, Apr 18, 2023 at 05:30:27PM +0200, Morten Brørup wrote:
> > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> > Sent: Tuesday, 18 April 2023 17.15
> > 
> > On Tue, Apr 18, 2023 at 12:06:42PM +0100, Bruce Richardson wrote:
> > > On Tue, Apr 11, 2023 at 08:48:45AM +0200, Morten Brørup wrote:
> > > > When getting objects from the mempool, the number of objects to get
> > is
> > > > often constant at build time.
> > > >
> > > > This patch adds another code path for this case, so the compiler can
> > > > optimize more, e.g. unroll the copy loop when the entire request is
> > > > satisfied from the cache.
> > > >
> > > > On an Intel(R) Xeon(R) E5-2620 v4 CPU, and compiled with gcc 9.4.0,
> > > > mempool_perf_test with constant n shows an increase in rate_persec
> > by an
> > > > average of 17 %, minimum 9.5 %, maximum 24 %.
> > > >
> > > > The code path where the number of objects to get is unknown at build
> > time
> > > > remains essentially unchanged.
> > > >
> > > > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > >
> > > Change looks a good idea. Some suggestions inline below, which you may
> > want to
> > > take on board for any future version. I'd strongly suggest adding some
> > > extra clarifying code comments, as I suggest below.
> > > With those exta code comments:
> > >
> > > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > >
> > > > ---
> > > >  lib/mempool/rte_mempool.h | 24 +++++++++++++++++++++---
> > > >  1 file changed, 21 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
> > > > index 9f530db24b..ade0100ec7 100644
> > > > --- a/lib/mempool/rte_mempool.h
> > > > +++ b/lib/mempool/rte_mempool.h
> > > > @@ -1500,15 +1500,33 @@ rte_mempool_do_generic_get(struct
> > rte_mempool *mp, void **obj_table,
> > > >  	if (unlikely(cache == NULL))
> > > >  		goto driver_dequeue;
> > > >
> > > > -	/* Use the cache as much as we have to return hot objects first */
> > > > -	len = RTE_MIN(remaining, cache->len);
> > > >  	cache_objs = &cache->objs[cache->len];
> > > > +
> > > > +	if (__extension__(__builtin_constant_p(n)) && n <= cache->len) {
> > 
> > don't take direct dependency on compiler builtins. define a macro so we
> > don't have to play shotgun surgery later.
> > 
> > also what is the purpose of using __extension__ here? are you annotating
> > the use of __builtin_constant_p() or is there more? because if that's
> > the only reason i see no need to use __extension__ when already using a
> > compiler specific builtin like this, that it is not standard is implied
> > and enforced by a compile break.
> 
> ARM 32-bit memcpy() [1] does it this way, so I did the same.
> 
> [1]: https://elixir.bootlin.com/dpdk/v23.03/source/lib/eal/arm/include/rte_memcpy_32.h#L122

i see thanks.

> 
> While I agree that a macro for __builtin_constant_p() would be good, it belongs in a patch to fix portability, not in this patch.

i agree it isn't composite of this change.

would you mind introducing it as a separate patch and depending on it or
do you feel that would delay this patch too much? i wouldn't mind doing
it myself but there is a long merge time on my patches which means i end
up having to carry the adaptations locally for weeks at a time.

thanks

  reply	other threads:[~2023-04-18 15:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  6:48 Morten Brørup
2023-04-18 11:06 ` Bruce Richardson
2023-04-18 11:29   ` Morten Brørup
2023-04-18 12:54     ` Bruce Richardson
2023-04-18 12:55     ` Bruce Richardson
2023-06-07  7:51       ` Thomas Monjalon
2023-06-07  8:03         ` Morten Brørup
2023-06-07  8:10           ` Thomas Monjalon
2023-06-07  8:33             ` Morten Brørup
2023-06-07  8:41             ` Morten Brørup
2023-04-18 15:15   ` Tyler Retzlaff
2023-04-18 15:30     ` Morten Brørup
2023-04-18 15:44       ` Tyler Retzlaff [this message]
2023-04-18 15:50         ` Morten Brørup
2023-04-18 16:01           ` Tyler Retzlaff
2023-04-18 16:05   ` Morten Brørup
2023-04-18 19:51 ` [PATCH v3] " Morten Brørup
2023-04-18 20:09 ` [PATCH v4] " Morten Brørup
2023-06-07  9:12   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230418154435.GA4574@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
    --to=roretzla@linux.microsoft.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).