From b113657091d4f82d1440d24402ad3593c7d76722 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Thu, 30 Jul 2015 11:03:06 +0100 Subject: [PATCH] Bug 1188834 - Make compacting GC when inactive less frequent except on nightly r=smaug --- dom/base/nsJSEnvironment.cpp | 13 +++++++++---- modules/libpref/init/all.js | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 8e62a3923ee7..83e632762a5a 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -112,9 +112,9 @@ const size_t gStackSize = 8192; #define NS_FULL_GC_DELAY 60000 // ms -// The amount of time to wait from the user being idle to starting a shrinking -// GC. -#define NS_SHRINKING_GC_DELAY 15000 // ms +// The default amount of time to wait from the user being idle to starting a +// shrinking GC. +#define NS_DEAULT_INACTIVE_GC_DELAY 300000 // ms // Maximum amount of time that should elapse between incremental GC slices #define NS_INTERSLICE_GC_DELAY 100 // ms @@ -221,6 +221,7 @@ static bool sGCOnMemoryPressure; // after NS_SHRINKING_GC_DELAY ms later, if the appropriate pref is set. static bool sCompactOnUserInactive; +static uint32_t sCompactOnUserInactiveDelay = NS_DEAULT_INACTIVE_GC_DELAY; static bool sIsCompactingOnUserInactive = false; // In testing, we call RunNextCollectorTimer() to ensure that the collectors are run more @@ -2097,7 +2098,7 @@ nsJSContext::PokeShrinkingGC() } sShrinkingGCTimer->InitWithFuncCallback(ShrinkingGCTimerFired, nullptr, - NS_SHRINKING_GC_DELAY, + sCompactOnUserInactiveDelay, nsITimer::TYPE_ONE_SHOT); } @@ -2855,6 +2856,10 @@ nsJSContext::EnsureStatics() "javascript.options.compact_on_user_inactive", true); + Preferences::AddUintVarCache(&sCompactOnUserInactiveDelay, + "javascript.options.compact_on_user_inactive_delay", + NS_DEAULT_INACTIVE_GC_DELAY); + nsIObserver* observer = new nsJSEnvironmentObserver(); obs->AddObserver(observer, "memory-pressure", false); obs->AddObserver(observer, "user-interaction-inactive", false); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index f86a59bd964f..5b0185e3f60a 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1141,6 +1141,11 @@ pref("javascript.options.mem.log", false); pref("javascript.options.mem.notify", false); pref("javascript.options.gc_on_memory_pressure", true); pref("javascript.options.compact_on_user_inactive", true); +#ifdef NIGHTLY_BUILD +pref("javascript.options.compact_on_user_inactive_delay", 15000); // ms +#else +pref("javascript.options.compact_on_user_inactive_delay", 300000); // ms +#endif pref("javascript.options.mem.gc_high_frequency_time_limit_ms", 1000); pref("javascript.options.mem.gc_high_frequency_low_limit_mb", 100);