From: Konstantin Ananyev <konstantin.ananyev@huawei.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>,
"Morten Brørup" <mb@smartsharesystems.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH] stack: introduce pile
Date: Tue, 18 Aug 2026 08:11:36 +0000 [thread overview]
Message-ID: <898dbda9dea547649b1ad6781a356090@huawei.com> (raw)
In-Reply-To: <aoMIQo7y_DyafUDg@bricha3-mobl1.ger.corp.intel.com>
> On Wed, Aug 12, 2026 at 01:47:56PM +0000, Morten Brørup wrote:
> > Added a new high-performance lock-free "pile", using the Stack API.
> > The pile behaves roughly like a stack, but is not strictly LIFO.
> >
> > The pile is optimized for pushing/popping bulks of objects, which
> > it does significantly faster than the lock-free stack.
> >
> > Pushing/popping a number of objects not divisible by the compile time
> > configurable bulk size is handled gracefully, but not as fast as
> > complete bulks.
> >
> > Performance examples, stack_pile_perf_autotest vs. stack_lf_autotest:
> >
> > On a single core, pushing/popping 1 or 8 objects is similar speed.
> > On a single core, pushing/popping 32 objects is 2x faster.
> > On a single core, pushing/popping 512 objects is 10x faster.
> >
> > On four cores, pushing/popping 1, 8 or 32 objects is slightly faster.
> > On four cores, pushing/popping 512 objects is 4x faster.
> >
> > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > ---
> > app/test/test_stack.c | 71 +++++-
> > app/test/test_stack_perf.c | 15 +-
> > config/rte_config.h | 3 +
> > doc/guides/prog_guide/stack_lib.rst | 67 +++++-
> > lib/mempool/rte_mempool.h | 2 +-
> > lib/stack/meson.build | 3 +-
> > lib/stack/rte_stack.c | 18 +-
> > lib/stack/rte_stack.h | 79 +++++++
> > lib/stack/rte_stack_lf.h | 1 +
> > lib/stack/rte_stack_pile.c | 35 +++
> > lib/stack/rte_stack_pile.h | 334 ++++++++++++++++++++++++++++
> > 11 files changed, 609 insertions(+), 19 deletions(-)
> > create mode 100644 lib/stack/rte_stack_pile.c
> > create mode 100644 lib/stack/rte_stack_pile.h
> >
> Looking at this a little closer, and thinking some more, here are some of
> my further thoughts/ideas on this:
>
> * For most cases using a mempool, I can't see having non-strict LIFO
> behaviour being an issue, and there is nothing in the mempool API that
> makes any ordering guarantees about what buffers get given by get/put,
> and in fact we can't make any guarantees because of the fact of multiple
> cores doing allocs and frees. Therefore, for the mempool driver, I
> believe one pre-emptible implementation is enough, so therefore the pile
> mempool driver should just replace the current LF one.
> * For apps which may want to use the stack structs directly, not through a
> mempool, I can see that having defined ordering behaviour may be
> beneficial. However, if multiple cores are involved, then we can never
> guarantee ordering, I believe, so I'm not sure its worth trying to
> enforce strict LIFO for such cases. [If you need the same elements back
> in the correct order from a core, then use a regular stack without sharing
> it].
> * IF we decide that we really, really want LIFO ordering across multiple
> cores - despite the likely random ordering of allocs/frees between those
> cores, I still think that this implementation should replace the LF
> stack. If we reverse the order of elements on enqueue (or dequeue) then
> we should be closer to correct LIFO ordering - and fully lifo if allocs
> and frees are based on multiples of the burst size.
>
> I suppose for me the main question to be resolved is - do we have scenarios
> where we a) have multi-core operation on the stacks and b) absolutely must
> have strict LIFO ordering? In the absense of that, I'd very much be in
> favour of replacing the existing LF implementation completely with this
> one.
I am agree with Bruce - it is probably worth to replace current lfstack implementation with this new one,
as new one is proved to be way much faster.
One more observation: instead of making RTE_STACK_PILE_BULK_SIZE compile time constant,
why not to make it configurable variable (at lfstack instance creation time)?
Then in theory we can support current behavior too - user can create a pile with no bulks,
and all requests will go via solo code-path.
That way we'll have good perf improvement, while preserving old-behavior compatibility for those
who needs it.
Though have to admit, I don't know any off-hand who will need it :)
next prev parent reply other threads:[~2026-08-18 8:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 13:47 [PATCH] stack: introduce pile Morten Brørup
2026-08-12 14:34 ` Bruce Richardson
2026-08-12 16:01 ` Morten Brørup
2026-08-12 16:15 ` Bruce Richardson
2026-08-12 16:28 ` Morten Brørup
2026-08-13 11:50 ` Bruce Richardson
2026-08-17 13:10 ` Bruce Richardson
2026-08-18 8:11 ` Konstantin Ananyev [this message]
2026-08-18 8:50 ` Morten Brørup
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=898dbda9dea547649b1ad6781a356090@huawei.com \
--to=konstantin.ananyev@huawei.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.