MINOR: pools/debug: slightly relax DEBUG_DONT_SHARE_POOLS
The purpose of this debugging option was to prevent certain pools from masking other ones when they were shared. For example, task, http_txn, h2s, h1s, h1c, session, fcgi_strm, and connection are all 192 bytes and would normally be mergedi, but not with this option. The problem is that certain pools are declared multiple times with various parameters, which are often very close, and due to the way the option works, they're not shared either. Good examples of this are captures and stick tables. Some configurations have large numbers of stick-tables of pretty similar types and it's very common to end up with the following when the option is enabled: $ socat - /tmp/sock1 <<< "show pools" | grep stick - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753800=56 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753880=57 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753900=58 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753980=59 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753a00=60 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753a80=61 - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753b00=62 - Pool sticktables (224 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x753780=55 In addition to not being convenient, it can have important effects on the memory usage because these pools will not share their entries, so one stick table cannot allocate from another one's pool. This patch solves this by going back to the initial goal which was not to have different pools in the same list. Instead of masking the MAP_F_SHARED flag, it simply adds a test on the pool's name, and disables pool sharing if the names differ. This way pools are not shared unless they're of the same name and size, which doesn't hinder debugging. The same test above now returns this: $ socat - /tmp/sock1 <<< "show pools" | grep stick - Pool sticktables (160 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 7 users, @0x3fadb30 [SHARED] - Pool sticktables (224 bytes) : 0 allocated (0 bytes), 0 used, needed_avg 0, 0 failures, 1 users, @0x3facaa0 [SHARED] This is much better. This should probably be backported, in order to limit the side effects of DEBUG_DONT_SHARE_POOLS being enabled in production.
This commit is contained in:
parent
48129be18a
commit
1ab6c0bfd2
|
@ -50,14 +50,7 @@
|
|||
#define CONFIG_HAP_NO_GLOBAL_POOLS
|
||||
#endif
|
||||
|
||||
/* Pools of very similar size are shared by default, unless macro
|
||||
* DEBUG_DONT_SHARE_POOLS is set.
|
||||
*/
|
||||
#ifndef DEBUG_DONT_SHARE_POOLS
|
||||
#define MEM_F_SHARED 0x1
|
||||
#else
|
||||
#define MEM_F_SHARED 0
|
||||
#endif
|
||||
#define MEM_F_EXACT 0x2
|
||||
|
||||
/* By default, free objects are linked by a pointer stored at the beginning of
|
||||
|
|
|
@ -80,7 +80,11 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
|
|||
* we look for a shareable one or for the next position
|
||||
* before which we will insert a new one.
|
||||
*/
|
||||
if (flags & entry->flags & MEM_F_SHARED) {
|
||||
if ((flags & entry->flags & MEM_F_SHARED)
|
||||
#ifdef DEBUG_DONT_SHARE_POOLS
|
||||
&& strcmp(name, entry->name) == 0
|
||||
#endif
|
||||
) {
|
||||
/* we can share this one */
|
||||
pool = entry;
|
||||
DPRINTF(stderr, "Sharing %s with %s\n", name, pool->name);
|
||||
|
|
Loading…
Reference in New Issue