Bug 1569004 - Convert dom.timeout.foreground_throttling_max_budget to static pref. r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 20:09:34 +0000
changeset 485180 ba7879d877738e0d676cc6504bab2e4c7d581f03
parent 485179 3d7f9cba78a7e60b287058e6d25e6818999ac0d9
child 485181 760fd1f569808515a578292a661a06aa93f649e8
push id91160
push userkwright@mozilla.com
push dateMon, 29 Jul 2019 17:51:51 +0000
treeherderautoland@0a9a0b8b35fa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1569004
milestone70.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 1569004 - Convert dom.timeout.foreground_throttling_max_budget to static pref. r=njn Converts dom.timeout.foreground_throttling_max_budget to static pref, removes all.js entry, updates usage, adds entry to StaticPrefList.yaml. Differential Revision: https://phabricator.services.mozilla.com/D39439
dom/base/TimeoutManager.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/base/TimeoutManager.cpp
+++ b/dom/base/TimeoutManager.cpp
@@ -29,20 +29,18 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 LazyLogModule gTimeoutLog("Timeout");
 
 static int32_t gRunningTimeoutDepth = 0;
 
-#define DEFAULT_FOREGROUND_THROTTLING_MAX_BUDGET -1  // infinite
-#define DEFAULT_BUDGET_THROTTLING_MAX_DELAY 15000    // 15s
+#define DEFAULT_BUDGET_THROTTLING_MAX_DELAY 15000  // 15s
 #define DEFAULT_ENABLE_BUDGET_TIMEOUT_THROTTLING false
-static int32_t gForegroundThrottlingMaxBudget = 0;
 static int32_t gBudgetThrottlingMaxDelay = 0;
 static bool gEnableBudgetTimeoutThrottling = false;
 
 // static
 const uint32_t TimeoutManager::InvalidFiringId = 0;
 
 namespace {
 double GetRegenerationFactor(bool aIsBackground) {
@@ -67,17 +65,17 @@ TimeDuration GetMaxBudget(bool aIsBackgr
   // foreground}_throttling_max_budget".
 
   // Returns how high a budget can be regenerated before being
   // clamped. If this value is less or equal to zero,
   // TimeDuration::Forever() is implied.
   int32_t maxBudget =
       aIsBackground
           ? StaticPrefs::dom_timeout_background_throttling_max_budget()
-          : gForegroundThrottlingMaxBudget;
+          : StaticPrefs::dom_timeout_foreground_throttling_max_budget();
   return maxBudget > 0 ? TimeDuration::FromMilliseconds(maxBudget)
                        : TimeDuration::Forever();
 }
 
 TimeDuration GetMinBudget(bool aIsBackground) {
   // The minimum budget is computed by looking up the maximum allowed
   // delay and computing how long time it would take to regenerate
   // that budget using the regeneration factor. This number is
@@ -447,19 +445,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddIntVarCache(&gForegroundThrottlingMaxBudget,
-                              "dom.timeout.foreground_throttling_max_budget",
-                              DEFAULT_FOREGROUND_THROTTLING_MAX_BUDGET);
   Preferences::AddIntVarCache(&gBudgetThrottlingMaxDelay,
                               "dom.timeout.budget_throttling_max_delay",
                               DEFAULT_BUDGET_THROTTLING_MAX_DELAY);
   Preferences::AddBoolVarCache(&gEnableBudgetTimeoutThrottling,
                                "dom.timeout.enable_budget_timer_throttling",
                                DEFAULT_ENABLE_BUDGET_TIMEOUT_THROTTLING);
 }
 
@@ -1276,17 +1271,17 @@ bool TimeoutManager::BudgetThrottlingEna
   // * If it hasn't got open WebSockets
   // * If it hasn't got active IndexedDB databases
 
   // Note that we allow both foreground and background to be
   // considered for budget throttling. What determines if they are if
   // budget throttling is enabled is the max budget.
   if ((aIsBackground
            ? StaticPrefs::dom_timeout_background_throttling_max_budget()
-           : gForegroundThrottlingMaxBudget) < 0) {
+           : StaticPrefs::dom_timeout_foreground_throttling_max_budget()) < 0) {
     return false;
   }
 
   if (!mBudgetThrottleTimeouts || IsActive()) {
     return false;
   }
 
   // Check if there are any active IndexedDB databases
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1833,16 +1833,23 @@
 
 # Maximum value (in ms) for the background budget. Only valid for
 # values greater than 0.
 - name: dom.timeout.background_throttling_max_budget
   type: int32_t
   value: 50
   mirror: always
 
+# Maximum value (in ms) for the foreground budget. Only valid for
+# values greater than 0.
+- name: dom.timeout.foreground_throttling_max_budget
+  type: int32_t
+  value: -1
+  mirror: always
+
 # Should we defer timeouts and intervals while loading a page.  Released
 # on Idle or when the page is loaded.
 - name: dom.timeout.defer_during_load
   type: bool
   value: true
   mirror: always
 
 # Maximum amount of time in milliseconds consecutive setTimeout()/setInterval()
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1078,19 +1078,16 @@ pref("dom.storage.default_quota",      5
 pref("dom.storage.shadow_writes", true);
 pref("dom.storage.snapshot_prefill", 16384);
 pref("dom.storage.snapshot_gradual_prefill", 4096);
 pref("dom.storage.snapshot_reusing", true);
 pref("dom.storage.client_validation", true);
 
 pref("dom.send_after_paint_to_content", false);
 
-// Maximum value (in ms) for the background budget. Only valid for
-// values greater than 0.
-pref("dom.timeout.foreground_throttling_max_budget", -1);
 // The maximum amount a timeout can be delayed by budget throttling
 pref("dom.timeout.budget_throttling_max_delay", 15000);
 // Turn on budget throttling by default
 pref("dom.timeout.enable_budget_timer_throttling", true);
 
 // Don't use new input types
 pref("dom.experimental_forms", false);