[m-rev.] for review: Enable munmap support in Boehm GC by default.

Peter Wang novalazy at gmail.com
Wed Jul 22 17:17:47 AEST 2020


Memory unmapping support is useful for long running programs to return
unused memory pages back to the OS, e.g. a server process can reduce the
amount of physical memory it occupies during idle periods.

Previously the user building the Mercury system needed to enable munmap
support at configure time. In 2008 I wrote:

    Allow the use of munmap() in Boehm GC, in order to return unused
    memory pages back to the OS. This has an adverse effect on run times
    so we want to be able to enable it on a per-application basis.

Bdwgc upstream has more recently enabled munmap support by default on
the master branch (albeit, not the v7.6.x branch we currently use).

Some testing on my machine suggests that we can try enabling munmap
support by default:

  - in asm_fast.gc grade, there was no discernable difference to the
    compiler's performance, with or without munmap support

  - in the hlc.gc grade, the compiler ran 1-2% faster
    WITH munmap support enabled

Tested on Linux/x86-64, time to compile the 10 largest modules in the
arena directory.

configure:
    Change default value of enable_gc_mmap and enable_gc_munmap to yes.

    Invert sense of --enable-gc-mmap and --enable-gc-munmap options in
    the help text.

NEWS:
    Announce change.
---
 NEWS         | 10 ++++++++++
 configure.ac | 12 ++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/NEWS b/NEWS
index e2905d01c..be8816d7a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+NEWS since Mercury 20.06
+========================
+
+Changes to the Mercury implementation
+-------------------------------------
+
+* We have enabled support for unmapping of unused memory pages in Boehm GC
+  by default. If this should cause a problem on your platform, it can be
+  disabled by passing `--disable-gc-munmap` to configure.
+
 NEWS for Mercury 20.06
 ======================
 
diff --git a/configure.ac b/configure.ac
index a510dbfb7..ee62f60e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -734,14 +734,14 @@ AC_SUBST(ENABLE_BOEHM_LARGE_CONFIG)
 #
 
 AC_ARG_ENABLE(gc-mmap,
-    AC_HELP_STRING([--enable-gc-mmap],
-                   [use mmap instead of sbrk when using Boehm GC]),
-    enable_gc_mmap="$enableval",enable_gc_mmap=no)
+    AC_HELP_STRING([--disable-gc-mmap],
+                   [use sbrk instead of mmap when using Boehm GC]),
+    enable_gc_mmap="$enableval",enable_gc_mmap=yes)
 
 AC_ARG_ENABLE(gc-munmap,
-    AC_HELP_STRING([--enable-gc-munmap],
-                   [enable unmapping of unused pages when using Boehm GC]),
-    enable_gc_munmap="$enableval",enable_gc_munmap=no)
+    AC_HELP_STRING([--disable-gc-munmap],
+                   [disable unmapping of unused pages when using Boehm GC]),
+    enable_gc_munmap="$enableval",enable_gc_munmap=yes)
 
 AC_MSG_CHECKING(whether to enable unmapping of unused pages when using Boehm GC)
 case "$enable_gc_munmap" in
-- 
2.27.0



More information about the reviews mailing list