]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: mark most static pool configuration variables as read-mostly
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Feb 2022 17:31:53 +0000 (18:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 Feb 2022 19:44:26 +0000 (20:44 +0100)
The mem_poison_byte, mem_fail_rate, using_default_allocator and the
pools list are all only set once at boot time and never changed later,
while they're heavily used at run time. Let's optimize their usage from
all threads by marking them read-mostly so that them reside in a shared
cache line.

src/pool.c

index cc92245c7a8354257dded12af169f4e2e2a2b928..60be27d0db488795d30fef2c919ed54de6a4c17b 100644 (file)
@@ -35,14 +35,14 @@ THREAD_LOCAL size_t pool_cache_bytes = 0;                /* total cache size */
 THREAD_LOCAL size_t pool_cache_count = 0;                /* #cache objects   */
 #endif
 
-static struct list pools = LIST_HEAD_INIT(pools);
-int mem_poison_byte = -1;
+static struct list pools __read_mostly = LIST_HEAD_INIT(pools);
+int mem_poison_byte __read_mostly = -1;
 
 #ifdef DEBUG_FAIL_ALLOC
-static int mem_fail_rate = 0;
+static int mem_fail_rate __read_mostly = 0;
 #endif
 
-static int using_default_allocator = 1;
+static int using_default_allocator __read_mostly = 1;
 static int(*my_mallctl)(const char *, void *, size_t *, void *, size_t) = NULL;
 
 /* ask the allocator to trim memory pools.