DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	dev@dpdk.org, Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: Re: [PATCH] mempool: micro optimizations
Date: Sun, 08 Jun 2025 19:53:00 +0200	[thread overview]
Message-ID: <3772522.QkHrqEjB74@thomas> (raw)
In-Reply-To: <e7ff43da-001a-483a-b62c-e819944864ff@oktetlabs.ru>

30/03/2025 10:09, Andrew Rybchenko:
> On 3/27/25 20:15, Bruce Richardson wrote:
> > On Wed, Feb 26, 2025 at 03:59:22PM +0000, Morten Brørup wrote:
> >> The comparisons lcore_id < RTE_MAX_LCORE and lcore_id != LCORE_ID_ANY are
> >> equivalent, but the latter compiles to fewer bytes of code space.
> >> Similarly for lcore_id >= RTE_MAX_LCORE and lcore_id == LCORE_ID_ANY.
> >>
> >> The rte_mempool_get_ops() function is also used in the fast path, so
> >> RTE_VERIFY() was replaced by RTE_ASSERT().
> >>
> >> Compilers implicitly consider comparisons of variable == 0 likely, so
> >> unlikely() was added to the check for no mempool cache (mp->cache_size ==
> >> 0) in the rte_mempool_default_cache() function.
> >>
> >> The rte_mempool_do_generic_put() function for adding objects to a mempool
> >> was refactored as follows:
> >> - The comparison for the request itself being too big, which is considered
> >>    unlikely, was moved down and out of the code path where the cache has
> >>    sufficient room for the added objects, which is considered the most
> >>    likely code path.
> >> - Added __rte_assume() about the cache length, size and threshold, for
> >>    compiler optimization when "n" is compile time constant.
> >> - Added __rte_assume() about "ret" being zero, so other functions using
> >>    the value returned by this function can be potentially optimized by the
> >>    compiler; especially when it merges multiple sequential code paths of
> >>    inlined code depending on the return value being either zero or
> >>    negative.
> >> - The refactored source code (with comments) made the separate comment
> >>    describing the cache flush/add algorithm superfluous, so it was removed.
> >>
> >> A few more likely()/unlikely() were added.
> > 
> > In general not a big fan of using likely/unlikely, but if they give a perf
> > benefit, we should probably take them.
> > 
> > Few more comments inline below.
> > 
> >> A few comments were improved for readability.
> >>
> >> Some assertions, RTE_ASSERT(), were added. Most importantly to assert that
> >> the return values of the mempool drivers' enqueue and dequeue operations
> >> are API compliant, i.e. 0 (for success) or negative (for failure), and
> >> never positive.
> >>
> >> Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > 
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Applied, thanks.



      reply	other threads:[~2025-06-08 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 15:59 Morten Brørup
2025-02-26 16:53 ` Bruce Richardson
2025-02-27  9:14   ` Morten Brørup
2025-02-27  9:17     ` Bruce Richardson
2025-02-28 16:59       ` Morten Brørup
2025-03-25  7:13 ` Morten Brørup
2025-03-27 17:15 ` Bruce Richardson
2025-03-27 19:30   ` Morten Brørup
2025-03-30  8:09   ` Andrew Rybchenko
2025-06-08 17:53     ` Thomas Monjalon [this message]

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=3772522.QkHrqEjB74@thomas \
    --to=thomas@monjalon.net \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.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).