Bug 1442947 - Compact the heap on shrinking GC when animating if the user is idle r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 18 Apr 2018 10:19:36 +0200
changeset 467763 dbf2bfc0aea9754a44ae6e1c779b82ea84474dff
parent 467762 3c4261ce506185df17964ad81f8e8a7f4ee6c885
child 467764 42e037e0b8d1d774db5cc38ef486639c1c2889f1
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1442947
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442947 - Compact the heap on shrinking GC when animating if the user is idle r=sfink
js/src/gc/GC.cpp
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -2109,20 +2109,30 @@ ArenaLists::unmarkPreMarkedFreeCells()
     }
 }
 
 /* Compacting GC */
 
 bool
 GCRuntime::shouldCompact()
 {
-    // Compact on shrinking GC if enabled, but skip compacting in incremental
-    // GCs if we are currently animating.
-    return invocationKind == GC_SHRINK && isCompactingGCEnabled() &&
-        (!isIncremental || rt->lastAnimationTime + PRMJ_USEC_PER_SEC < PRMJ_Now());
+    // Compact on shrinking GC if enabled.  Skip compacting in incremental GCs
+    // if we are currently animating, unless the user is inactive or we're
+    // responding to memory pressure.
+
+    if (invocationKind != GC_SHRINK || !isCompactingGCEnabled())
+        return false;
+
+    if (initialReason == JS::gcreason::USER_INACTIVE ||
+        initialReason == JS::gcreason::MEM_PRESSURE)
+    {
+        return true;
+    }
+
+    return !isIncremental || rt->lastAnimationTime + PRMJ_USEC_PER_SEC < PRMJ_Now();
 }
 
 bool
 GCRuntime::isCompactingGCEnabled() const
 {
     return compactingEnabled && rt->mainContextFromOwnThread()->compactingDisabledCount == 0;
 }