On Thu, Mar 19, 2026 at 09:13:00AM +0000, Morten Brørup wrote: > The descriptions for the mempool creation functions contained advice for > choosing the optimum (in terms of memory usage) number of elements and > cache size. > The advice was based on implementation details, which was changed long > ago, making the advice completely irrelevant. >
The comment is still correct in most cases, since the default backing storage remains an rte_ring. If passing a power-of-2 size to mempool create one will get a backing rte_ring store which is twice as large as requested, leading to lots of ring slots being wasted. For example, for a pool with 16k elements, the actual ring size allocated will be 32k, leading to wasting 128k of RAM, and also potentially cache too. The latter will occur because of the nature of the ring to iterate through all mempool/ring entries, meaning that even if only 16k of the 32k slots will ever be used, all 32k slots will be passed through the cpu cache if it works on the mempool directly and not just from the per-core cache. On the other hand, I'd be in favour of removing this text if we switched the default mempool in DPDK to being stack-based. While the stack may not be lock-free like the ring, with per-lcore caches the number of accesses to the stack should be small, and it gives much better cache utilization overall - especially in cases where buffers are allocated on one core and freed on a different one! Even in cases where we are not transferring between cores, in a single-core case we still will get better reuse of "hot" buffers than in an rte_ring-backed case. /Bruce

