From: Willy Tarreau Date: Sun, 2 Jan 2022 11:40:14 +0000 (+0100) Subject: MINOR: pools: always evict oldest objects first in pool_evict_from_local_cache() X-Git-Tag: v2.6-dev1~207 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/NGINX-js-1660x332.png%20%22NGINX%20JavaScript%20Banner%22?a=commitdiff_plain;h=d5ec100661f6b02e9e1b7e9fc14c7a2e7f2dcc8d;p=haproxy.git 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. --- 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--;