public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Patrick McGehearty <patrick.mcgehearty@oracle.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v2] Remove upper limit on tunable MALLOC_MMAP_THRESHOLD
Date: Mon,  1 Nov 2021 21:48:47 +0000	[thread overview]
Message-ID: <1635803327-25346-1-git-send-email-patrick.mcgehearty@oracle.com> (raw)

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


             reply	other threads:[~2021-11-01 21:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 21:48 Patrick McGehearty [this message]
2021-11-02  0:27 ` DJ Delorie
2021-11-09 22:33   ` Patrick McGehearty
2021-11-10  0:36     ` DJ Delorie
2021-11-25  0:52       ` Patrick McGehearty
2021-11-29 20:42         ` DJ Delorie
2021-11-29 21:35           ` Patrick McGehearty
2021-12-07 19:51           ` Patrick McGehearty
2021-12-07 20:35             ` DJ Delorie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1635803327-25346-1-git-send-email-patrick.mcgehearty@oracle.com \
    --to=patrick.mcgehearty@oracle.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).