On 12/24/22 13:46, Morten Brørup wrote:
Micro-optimization:
Reduced the most likely code path in the generic put function by moving an
unlikely check out of the most likely code path and further down.
Also updated the comments in the function.
v3 (feedback from Konstantin Ananyev):
* Removed assertion and comment about the invariant preventing overflow
in the comparison. They were more confusing than enlightening.
v2 (feedback from Andrew Rybchenko):
* Modified comparison to prevent overflow if n is really huge and len is
non-zero.
* Added assertion about the invariant preventing overflow in the
comparison.
* Crossing the threshold is not extremely unlikely, so removed likely()
from that comparison.
The compiler will generate code with optimal static branch prediction
here anyway.
Signed-off-by: Morten Brørup <m...@smartsharesystems.com>
Acked-by: Konstantin Ananyev <konstantin.anan...@huawei.com>
Thanks for optimizing it further.
Reviewed-by: Andrew Rybchenko <andrew.rybche...@oktetlabs.ru>
---
lib/mempool/rte_mempool.h | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 9f530db24b..61ca0c6b65 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1364,32 +1364,33 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void
* const *obj_table,
{
void **cache_objs;
- /* No cache provided */
+ /* No cache provided? */
IMHO such changes do not add value and just add noise.
There are few similar cases below.
No strong opinion in any case.