[PATCH v3 1/2] stack: introduce pile
Morten Brørup
mb at smartsharesystems.com
Mon Aug 31 11:05:44 CEST 2026
> From: Konstantin Ananyev [mailto:konstantin.ananyev at huawei.com]
> Sent: Monday, 31 August 2026 10.50
>
> > 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.
>
> Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
>
> The code itself looks ok to me, thought I still think it is worth to
> consider
> moving lf_pile (and lf_stack) DP implementation in .c, to avoid each
> rte_stack_pus/pop
> to inline all three of them.
If a use case knows the selected stack implement at build time, it can call the implementation's push/pop functions directly.
I updated the mempool stack driver v3 patch [1] to do this for all three stack implementations.
[1]: https://patchwork.dpdk.org/project/dpdk/patch/20260827135556.522443-3-mb@smartsharesystems.com/
> My speculation is that the perf diff for bulk enqueue/dequeue because
> of
> that would be negligible, while both are quite big for inlining them
> always
> (specially lf_pile).
If the number of objects being pushed/popped is known at build time, the compiler can optimize the functions when inlined.
I tried experimented with conditional inlining depending on the number of objects being known at build time, but I wasn't really pleased with it.
More information about the dev
mailing list