diff options
author | Willy Tarreau <w@1wt.eu> | 2021-12-30 16:35:32 +0100 |
---|---|---|
committer | Willy Tarreau <w@1wt.eu> | 2022-01-02 12:44:19 +0100 |
commit | 4859984a5b7f02fffd9b85a5e1c4c7beef47382a (patch) | |
tree | f01b20716758a74a63ae98c0e4ed5bdccd113c5e | |
parent | d5ec100661f6b02e9e1b7e9fc14c7a2e7f2dcc8d (diff) | |
download | haproxy-4859984a5b7f02fffd9b85a5e1c4c7beef47382a.tar.gz |
DOC: pool: document the purpose of various structures in the code
The pools have become complex with the shared pools and the thread-local
caches, and the purpose of certain structures is never easy to grasp.
Let's add a bit of documentation there to save some long and painful
analysis to those touching that area.
-rw-r--r-- | include/haproxy/pool-t.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/haproxy/pool-t.h b/include/haproxy/pool-t.h index 111ae3a96..48d06be15 100644 --- a/include/haproxy/pool-t.h +++ b/include/haproxy/pool-t.h @@ -56,16 +56,30 @@ #define POOL_F_NO_FAIL 0x00000004 // do not randomly fail +/* This is the head of a thread-local cache */ struct pool_cache_head { struct list list; /* head of objects in this pool */ unsigned int count; /* number of objects in this pool */ } THREAD_ALIGNED(64); +/* This represents one item stored in the thread-local cache. <by_pool> links + * the object to the list of objects in the pool, and <by_lru> links the object + * to the local thread's list of hottest objects. This way it's possible to + * allocate a fresh object from the cache, or to release cold objects from any + * pool (no bookkeeping is needed since shared pools do not know how many + * objects they store). + */ struct pool_cache_item { struct list by_pool; /* link to objects in this pool */ struct list by_lru; /* link to objects by LRU order */ }; +/* This describes a complete pool, with its status, usage statistics and the + * thread-local caches if any. Even if pools are disabled, these descriptors + * are valid and are used at least to get names and sizes. For small builds + * using neither threads nor pools, this structure might be reduced, and + * alignment could be removed. + */ struct pool_head { void **free_list; unsigned int used; /* how many chunks are currently in use */ |