unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Remove upper limit on tunable MALLOC_MMAP_THRESHOLD
@ 2021-11-01 21:48 Patrick McGehearty via Libc-alpha
  2021-11-02  0:27 ` DJ Delorie via Libc-alpha
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick McGehearty via Libc-alpha @ 2021-11-01 21:48 UTC (permalink / raw)
  To: libc-alpha

Differences in Version 2:

Version 1 of this patch was made on glibc 2.28 malloc/malloc.c.
My mistake. This version is made against today's (Nov 1, 2021)
upstream version of glibc, malloc/malloc.c.

The current limit on MALLOC_MMAP_THRESHOLD is either 1 Mbyte (for
32-bit apps) or 32 Mbytes (for 64-bit apps).  This value was set by a
patch dated 2006 (15 years ago).  Attempts to set the threshold higher
are currently ignored.

The default behavior is appropriate for many highly parallel
applications where many processes or threads are sharing RAM. In other
situations where the number of active processes or threads closely
matches the number of cores, a much higher limit may be desired by the
application designer. By today's standards on personal computers and
small servers, 2 Gbytes of RAM per core is commonly available. On
larger systems 4 Gbytes or more of RAM is sometimes available.
Instead of raising the limit to match current needs, this patch
proposes to remove the limit of the tunable, leaving the decision up
to the user of a tunable to judge the best value for their needs.

This patch does not change any of the defaults for malloc tunables,
retaining the current behavior of the dynamic malloc mmap threshold.

malloc/
	malloc.c changed do_set_mmap_threshold to remove test
	for HEAP_MAX_SIZE.
---
 malloc/malloc.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 095d97a..c1c4ef6 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5216,16 +5216,11 @@ do_set_top_pad (size_t value)
 static __always_inline int
 do_set_mmap_threshold (size_t value)
 {
-  /* Forbid setting the threshold too high.  */
-  if (value <= HEAP_MAX_SIZE / 2)
-    {
-      LIBC_PROBE (memory_mallopt_mmap_threshold, 3, value, mp_.mmap_threshold,
-		  mp_.no_dyn_threshold);
-      mp_.mmap_threshold = value;
-      mp_.no_dyn_threshold = 1;
-      return 1;
-    }
-  return 0;
+  LIBC_PROBE (memory_mallopt_mmap_threshold, 3, value, mp_.mmap_threshold,
+	      mp_.no_dyn_threshold);
+  mp_.mmap_threshold = value;
+  mp_.no_dyn_threshold = 1;
+  return 1;
 }
 
 static __always_inline int
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-12-07 20:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 21:48 [PATCH v2] Remove upper limit on tunable MALLOC_MMAP_THRESHOLD Patrick McGehearty via Libc-alpha
2021-11-02  0:27 ` DJ Delorie via Libc-alpha
2021-11-09 22:33   ` Patrick McGehearty via Libc-alpha
2021-11-10  0:36     ` DJ Delorie via Libc-alpha
2021-11-25  0:52       ` Patrick McGehearty via Libc-alpha
2021-11-29 20:42         ` DJ Delorie via Libc-alpha
2021-11-29 21:35           ` Patrick McGehearty via Libc-alpha
2021-12-07 19:51           ` Patrick McGehearty via Libc-alpha
2021-12-07 20:35             ` DJ Delorie via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).