From d5ec100661f6b02e9e1b7e9fc14c7a2e7f2dcc8d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 2 Jan 2022 12:40:14 +0100 Subject: [PATCH] MINOR: pools: always evict oldest objects first in pool_evict_from_local_cache() For an unknown reason, despite the comment stating that we were evicting oldest objects first from the local caches, due to the use of LIST_NEXT, the newest were evicted, since pool_put_to_cache() uses LIST_INSERT(). Some tests on 16 threads show that evicting oldest objects instead can improve performance by 0.5-1% especially when using shared pools. --- src/pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pool.c b/src/pool.c index c5390abf3..e64bfcacf 100644 --- a/src/pool.c +++ b/src/pool.c @@ -316,7 +316,7 @@ void pool_evict_from_local_cache(struct pool_head *pool) while (ph->count >= 16 + pool_cache_count / 8 && pool_cache_bytes > CONFIG_HAP_POOL_CACHE_SIZE * 3 / 4) { - item = LIST_NEXT(&ph->list, typeof(item), by_pool); + item = LIST_PREV(&ph->list, typeof(item), by_pool); ph->count--; pool_cache_bytes -= pool->size; pool_cache_count--;