summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-26 21:28:35 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-27 17:56:05 +0300
commitece628e5a347dd319cffe4b53dbd73ebc42d0b4d (patch)
treec464a5542b7e9e1c9ac9ec3195a5c303ce6f30de
parentb04141e736946ad77e83f95c75625e069699d507 (diff)
downloadbdwgc-ece628e5a347dd319cffe4b53dbd73ebc42d0b4d.tar.gz
Allow to unmap memory block right in GC cycle where block is freed
This commit changes how GC_unmap_threshold is interpreted: GC_unmap_threshold==N now means block is returned to OS if the block is freed N-1 collections ago (previously was: N collections ago). * allchblk.c [USE_MUNMAP && !MUNMAP_THRESHOLD] (MUNMAP_THRESHOLD): Change value from 6 to 7. * configure.ac [$enable_munmap!=no && ($MUNMAP_THRESHOLD="" || $MUNMAP_THRESHOLD=yes)] (MUNMAP_THRESHOLD): Likewise. * allchblk.c [USE_MUNMAP] (GC_unmap_old): Go on with unmapping also if GC_gc_no==hb_last_reclaimed+GC_unmap_threshold; update comment. * configure.ac (munmap): Update help string (including change of the default value from 6 to 7). * configure.ac [$enable_munmap!=no] (MUNMAP_THRESHOLD): Likewise. * doc/README.environment (GC_UNMAP_THRESHOLD): Update documentation. * doc/README.macros (MUNMAP_THRESHOLD): Likewise. * include/private/gcconfig.h [USE_MUNMAP && !MUNMAP_THRESHOLD && (SN_TARGET_PS3 || SN_TARGET_PSP2 || MSWIN_XBOX1)] (MUNMAP_THRESHOLD): Change value from 2 to 3.
-rw-r--r--allchblk.c10
-rw-r--r--configure.ac9
-rw-r--r--doc/README.environment8
-rw-r--r--doc/README.macros7
-rw-r--r--include/private/gcconfig.h2
5 files changed, 19 insertions, 17 deletions
diff --git a/allchblk.c b/allchblk.c
index 37cbdada..d03ef174 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -402,7 +402,7 @@ STATIC void GC_add_to_fl(struct hblk *h, hdr *hhdr)
#ifdef USE_MUNMAP
# ifndef MUNMAP_THRESHOLD
-# define MUNMAP_THRESHOLD 6
+# define MUNMAP_THRESHOLD 7
# endif
GC_INNER int GC_unmap_threshold = MUNMAP_THRESHOLD;
@@ -484,10 +484,10 @@ GC_INNER void GC_unmap_old(void)
hhdr = HDR(h);
if (!IS_MAPPED(hhdr)) continue;
- /* Check that the interval is larger than the threshold (the */
- /* truncated counter value wrapping is handled correctly). */
- if ((unsigned short)(GC_gc_no - hhdr->hb_last_reclaimed) >
- (unsigned short)GC_unmap_threshold) {
+ /* Check that the interval is not smaller than the threshold. */
+ /* The truncated counter value wrapping is handled correctly. */
+ if ((unsigned short)(GC_gc_no - hhdr->hb_last_reclaimed)
+ >= (unsigned short)GC_unmap_threshold) {
# ifdef COUNT_UNMAPPED_REGIONS
/* Continue with unmapping the block only if it will not */
/* create too many unmapped regions, or if unmapping */
diff --git a/configure.ac b/configure.ac
index 0962f51f..094b5b16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -922,8 +922,8 @@ AC_ARG_ENABLE(mmap,
AC_ARG_ENABLE(munmap,
[AS_HELP_STRING([--enable-munmap=N],
- [return page to the OS if empty for N collections
- (default: 6)])],
+ [return page to the OS if page is marked as
+ empty during N collections (default: 7)])],
MUNMAP_THRESHOLD=$enableval)
if test x$enable_munmap != xno; then
AC_DEFINE([USE_MMAP], 1,
@@ -935,10 +935,11 @@ if test x$enable_munmap != xno; then
[Define to return memory to OS with munmap calls
(see doc/README.macros).])
if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
- MUNMAP_THRESHOLD=6
+ MUNMAP_THRESHOLD=7
fi
AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
- [Number of GC cycles to wait before unmapping an unused block.])
+ [Number of sequential garbage collections during those a candidate
+ block for unmapping should be marked as free.])
else
if test "${gc_use_mmap}" = "yes"; then
AC_DEFINE([USE_MMAP], 1,
diff --git a/doc/README.environment b/doc/README.environment
index 16e527d4..d6423ad2 100644
--- a/doc/README.environment
+++ b/doc/README.environment
@@ -147,10 +147,10 @@ GC_FREE_SPACE_DIVISOR - Set GC_free_space_divisor to the indicated value.
Setting it to larger values decreases space consumption
and increases GC frequency.
-GC_UNMAP_THRESHOLD - Set the desired memory blocks unmapping threshold (the
- number of sequential garbage collections for which
- a candidate block for unmapping should remain free). The
- special value "0" completely disables unmapping.
+GC_UNMAP_THRESHOLD - Set the desired threshold of memory blocks unmapping
+ (the number of sequential garbage collections during those
+ a candidate block for unmapping should be marked as free).
+ The special value "0" completely disables unmapping.
GC_FORCE_UNMAP_ON_GCOLLECT - Turn "unmap as much as possible on explicit GC"
mode on (overrides the default value). Has no effect on
diff --git a/doc/README.macros b/doc/README.macros
index e013566c..887b3240 100644
--- a/doc/README.macros
+++ b/doc/README.macros
@@ -312,9 +312,10 @@ USE_MUNMAP Causes memory to be returned to the OS under the right
USE_WINALLOC (Cygwin only) Use Win32 VirtualAlloc (instead of sbrk or mmap)
to get new memory. Useful if memory unmapping (USE_MUNMAP) is enabled.
-MUNMAP_THRESHOLD=<value> Set the desired memory blocks unmapping
- threshold (the number of sequential garbage collections for which
- a candidate block for unmapping should remain free).
+MUNMAP_THRESHOLD=<value> Set the default threshold of memory blocks
+ unmapping (the number of sequential garbage collections during those
+ a candidate block for unmapping should be marked as free). The special
+ value "0" completely disables unmapping.
GC_FORCE_UNMAP_ON_GCOLLECT Set "unmap as much as possible on explicit GC"
mode on by default. The mode could be changed at run-time. Has no effect
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 694b66d6..ec849a56 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -2755,7 +2755,7 @@ EXTERN_C_BEGIN
#if defined(USE_MUNMAP) && !defined(MUNMAP_THRESHOLD) \
&& (defined(SN_TARGET_PS3) \
|| defined(SN_TARGET_PSP2) || defined(MSWIN_XBOX1))
-# define MUNMAP_THRESHOLD 2
+# define MUNMAP_THRESHOLD 3
#endif
#if defined(USE_MUNMAP) && defined(COUNT_UNMAPPED_REGIONS) \