]> granicus.if.org Git - gc/commitdiff
Enable memory unmapping by default
authorIvan Maidanski <ivmai@mail.ru>
Sat, 14 Apr 2018 06:26:03 +0000 (09:26 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 14 Apr 2018 06:26:03 +0000 (09:26 +0300)
Issue #152 (bdwgc).

* CMakeLists.txt (enable_munmap): New OPTION (on by default).
* CMakeLists.txt [enable_munmap] (USE_MMAP, USE_MUNMAP): Define macro.
* CMakeLists.txt [enable_checksums && enable_munmap): Issue MESSAGE
that CHECKSUMS is not compatible with USE_MUNMAP.
* configure.ac (AC_ARG_ENABLE(munmap)): Update the help message.
* configure.ac [$enable_munmap=""]: Treat as enable_munmap="yes".
* configure.ac [$MUNMAP_THRESHOLD=""]: Treat as MUNMAP_THRESHOLD="yes".
* doc/README.win32 (GNU Tools): Note about "--disable-munmap" option.
* doc/debugging.md (Unexpectedly Large Heap): Remove advice about
"--enable-munmap" option.

CMakeLists.txt
configure.ac
doc/README.win32
doc/debugging.md

index e79a4c05f8c367aa5ccfaaca4a0f6d36e3a5c1bd..f0d84cd97c6b1fa75bf70ffb521b5fe434f3bff8 100644 (file)
@@ -192,6 +192,11 @@ IF(enable_redirect_malloc)
     ADD_DEFINITIONS("-DGC_USE_DLOPEN_WRAP")
 ENDIF(enable_redirect_malloc)
 
+OPTION(enable_munmap "Return page to the OS if empty for N collections" ON)
+IF(enable_munmap)
+    ADD_DEFINITIONS("-DUSE_MMAP -DUSE_MUNMAP")
+ENDIF(enable_munmap)
+
 OPTION(enable_large_config "Optimize for large heap or root set" NO)
 IF(enable_large_config)
     ADD_DEFINITIONS("-DLARGE_CONFIG")
@@ -204,7 +209,7 @@ ENDIF(enable_gc_assertions)
 
 OPTION(enable_checksums "Report erroneously cleared dirty bits" NO)
 IF(enable_checksums)
-    IF(enable_threads)
+    IF(enable_munmap OR enable_threads)
         MESSAGE("CHECKSUMS not compatible with USE_MUNMAP or threads")
     ENDIF(enable_threads)
     ADD_DEFINITIONS("-DCHECKSUMS")
index e392b9781e5988d602547e7d54a4b808ae18fd3e..35d5a45ae5101f78db6608a43860ffbe639ea32c 100644 (file)
@@ -898,9 +898,10 @@ fi
 
 AC_ARG_ENABLE(munmap,
     [AC_HELP_STRING([--enable-munmap=N],
-        [return page to the os if empty for N collections])],
+                    [Return page to the OS if empty for N collections
+                     (default: 6)])],
     MUNMAP_THRESHOLD=$enableval)
-if test x$enable_munmap != x -a x$enable_munmap != xno; then
+if test x$enable_munmap != xno; then
     AC_DEFINE([USE_MMAP], 1,
               [Define to use mmap instead of sbrk to expand the heap.])
     AH_TEMPLATE([USE_WINALLOC],
@@ -909,7 +910,7 @@ if test x$enable_munmap != x -a x$enable_munmap != xno; then
     AC_DEFINE([USE_MUNMAP], 1,
               [Define to return memory to OS with munmap calls
                (see doc/README.macros).])
-    if test "${MUNMAP_THRESHOLD}" = "yes"; then
+    if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
       MUNMAP_THRESHOLD=6
     fi
     AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
@@ -928,8 +929,7 @@ AC_ARG_ENABLE(checksums,
                      substantial performance cost; use only for debugging
                      of the incremental collector])])
 if test x$enable_checksums = xyes; then
-    if test x$enable_munmap != x -a x$enable_munmap != xno \
-            -o x$THREADS != xnone; then
+    if test x$enable_munmap != xno -o x$THREADS != xnone; then
         AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
     fi
     AC_DEFINE([CHECKSUMS], 1,
index 938ae6e141810ece6317df32ad2f9a88766e2cf0..3ff7000742e92cdfa1df62c43c646eeb5ae1029e 100644 (file)
@@ -71,7 +71,7 @@ configure (this will instruct make to compile with -D GC_DLL).
 Parallel marker is enabled by default; it could be disabled by
 "--disable-parallel-mark" option.
 
-Memory unmapping could be enabled via "--enable-munmap".
+Memory unmapping could be turned off by "--disable-munmap" option.
 
 Borland Tools
 -------------
index b714dfb2a018d8a56361979a8cc09fd0c555c253..28626807779ce7c251a3f9bf08accb03b9b3400a 100644 (file)
@@ -125,9 +125,7 @@ Unexpected heap growth can be due to one of the following:
   symptom is that GC_dump() shows much of the heap as black-listed.
   3. Heap fragmentation. This should never result in unbounded growth, but
   it may account for larger heaps. This is most commonly caused by allocation
-  of large objects. On some platforms it can be reduced by building with
-  `-DUSE_MUNMAP`, which will cause the collector to unmap memory corresponding
-  to pages that have not been recently used.
+  of large objects.
   4. Per object overhead. This is usually a relatively minor effect, but
   it may be worth considering. If the collector recognizes interior pointers,
   object sizes are increased, so that one-past-the-end pointers are correctly