From 488958385c6b8974b8780fb44b91c481e57c2eea Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 18 Apr 2024 19:46:16 +0000 Subject: doc: strongly recommend MALLOC_MMAP_THRESHOLD_=131072 for glibc The 131072 byte lower bound was the old default before the sliding mmap window was introduced in modern glibc malloc. While the sliding mmap window was intended to be faster by reducing syscalls, zeroing and kernel overhead, it is also prone to fragmentation from allocation patterns seen in evented Perl servers. Individual allocations over 128K are rare in our codebase since there aren't many messages this large, making any performance impact tiny. Furthermore, the reduction in fragmentation and memory use will be a speedup for memory-constrained systems since they can avoid swap and have more leftover for the page cache. --- Documentation/RelNotes/v2.0.0.wip | 5 +++-- Documentation/public-inbox-tuning.pod | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Documentation') diff --git a/Documentation/RelNotes/v2.0.0.wip b/Documentation/RelNotes/v2.0.0.wip index 4d872fd7..794d7956 100644 --- a/Documentation/RelNotes/v2.0.0.wip +++ b/Documentation/RelNotes/v2.0.0.wip @@ -54,8 +54,9 @@ treewide * SHA-256 coderepos are fully supported (but not inboxes, yet) - * jemalloc (tested as an LD_PRELOAD) is recommended to reduce fragmentation - in long-running daemon processes serving unpredictable traffic + * for daemons serving public traffic, MALLOC_MMAP_THRESHOLD_=131072 is + recommended to reduce fragmentation in glibc malloc, while jemalloc + (tested as an LD_PRELOAD) is another option. PublicInbox::WWW diff --git a/Documentation/public-inbox-tuning.pod b/Documentation/public-inbox-tuning.pod index 7d0690b4..892ee0f2 100644 --- a/Documentation/public-inbox-tuning.pod +++ b/Documentation/public-inbox-tuning.pod @@ -165,11 +165,10 @@ capacity planning. Bursts of small object allocations late in process life contribute to fragmentation of the heap due to arenas (slabs) used internally by Perl. -jemalloc (tested as an LD_PRELOAD on GNU/Linux) reduces -overall fragmentation compared to glibc malloc in long-lived processes. -glibc malloc users may try setting C to a lower -value (e.g. 131072) but that may require increasing the -C sysctl. +glibc malloc users should use C to reduce +fragmentation from the sliding mmap window. jemalloc (tested as an +LD_PRELOAD on GNU/Linux) also reduces fragmentation compared to an +unconfigured glibc malloc in long-lived processes. =head2 Other OS tuning knobs -- cgit v1.2.3-24-ge0c7