]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: always evict oldest objects first in pool_evict_from_local_cache()
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Jan 2022 11:40:14 +0000 (12:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Jan 2022 11:40:14 +0000 (12:40 +0100)
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

index c5390abf3229eca22ec2310bc4849e1eefdd08ce..e64bfcacf0af0c9316392b9876c8589ccfc75599 100644 (file)
@@ -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--;