Bug 1569004 - Convert dom.timeout.background_budget_regeneration_rate to StaticPref. r=njn
authorkriswright <kwright@mozilla.com>
Fri, 26 Jul 2019 03:07:42 +0000
changeset 485160 68cb4f3a31fde323e010323b085429b93e8628f6
parent 485159 0708d16f56de796ac01b7399190d50758d09c80c
child 485161 89aacbb2f52f8905045c0aba8b21cbd9e8dc3d31
push id36360
push userccoroiu@mozilla.com
push dateMon, 29 Jul 2019 21:38:39 +0000
treeherdermozilla-central@927abd2c418b [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.background_budget_regeneration_rate to StaticPref. r=njn Converts dom.timeout.background_budget_regeneration_rate varcache pref in TimeoutManager.cpp to static pref, removes entry in all.js, adds entry to StaticPrefList.yaml. Differential Revision: https://phabricator.services.mozilla.com/D39435
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,23 +29,21 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 LazyLogModule gTimeoutLog("Timeout");
 
 static int32_t gRunningTimeoutDepth = 0;
 
-#define DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR 100  // 1ms per 100ms
-#define DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR 1    // 1ms per 1ms
-#define DEFAULT_BACKGROUND_THROTTLING_MAX_BUDGET 50        // 50ms
-#define DEFAULT_FOREGROUND_THROTTLING_MAX_BUDGET -1        // infinite
-#define DEFAULT_BUDGET_THROTTLING_MAX_DELAY 15000          // 15s
+#define DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR 1  // 1ms per 1ms
+#define DEFAULT_BACKGROUND_THROTTLING_MAX_BUDGET 50      // 50ms
+#define DEFAULT_FOREGROUND_THROTTLING_MAX_BUDGET -1      // infinite
+#define DEFAULT_BUDGET_THROTTLING_MAX_DELAY 15000        // 15s
 #define DEFAULT_ENABLE_BUDGET_TIMEOUT_THROTTLING false
-static int32_t gBackgroundBudgetRegenerationFactor = 0;
 static int32_t gForegroundBudgetRegenerationFactor = 0;
 static int32_t gBackgroundThrottlingMaxBudget = 0;
 static int32_t gForegroundThrottlingMaxBudget = 0;
 static int32_t gBudgetThrottlingMaxDelay = 0;
 static bool gEnableBudgetTimeoutThrottling = false;
 
 // static
 const uint32_t TimeoutManager::InvalidFiringId = 0;
@@ -55,20 +53,21 @@ double GetRegenerationFactor(bool aIsBac
   // Lookup function for "dom.timeout.{background,
   // foreground}_budget_regeneration_rate".
 
   // Returns the rate of regeneration of the execution budget as a
   // fraction. If the value is 1.0, the amount of time regenerated is
   // equal to time passed. At this rate we regenerate 1ms/ms. If it is
   // 0.01 the amount regenerated is 1% of time passed. At this rate we
   // regenerate 1ms/100ms, etc.
-  double denominator =
-      std::max(aIsBackground ? gBackgroundBudgetRegenerationFactor
-                             : gForegroundBudgetRegenerationFactor,
-               1);
+  double denominator = std::max(
+      aIsBackground
+          ? StaticPrefs::dom_timeout_background_budget_regeneration_rate()
+          : gForegroundBudgetRegenerationFactor,
+      1);
   return 1.0 / denominator;
 }
 
 TimeDuration GetMaxBudget(bool aIsBackground) {
   // Lookup function for "dom.timeout.{background,
   // foreground}_throttling_max_budget".
 
   // Returns how high a budget can be regenerated before being
@@ -82,19 +81,21 @@ TimeDuration GetMaxBudget(bool aIsBackgr
 
 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
   // expected to be negative.
   return TimeDuration::FromMilliseconds(
       -gBudgetThrottlingMaxDelay /
-      std::max(aIsBackground ? gBackgroundBudgetRegenerationFactor
-                             : gForegroundBudgetRegenerationFactor,
-               1));
+      std::max(
+          aIsBackground
+              ? StaticPrefs::dom_timeout_background_budget_regeneration_rate()
+              : gForegroundBudgetRegenerationFactor,
+          1));
 }
 }  // namespace
 
 //
 
 bool TimeoutManager::IsBackground() const {
   return !IsActive() && mWindow.IsBackgroundInternal();
 }
@@ -448,19 +449,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  Preferences::AddIntVarCache(&gBackgroundBudgetRegenerationFactor,
-                              "dom.timeout.background_budget_regeneration_rate",
-                              DEFAULT_BACKGROUND_BUDGET_REGENERATION_FACTOR);
   Preferences::AddIntVarCache(&gForegroundBudgetRegenerationFactor,
                               "dom.timeout.foreground_budget_regeneration_rate",
                               DEFAULT_FOREGROUND_BUDGET_REGENERATION_FACTOR);
   Preferences::AddIntVarCache(&gBackgroundThrottlingMaxBudget,
                               "dom.timeout.background_throttling_max_budget",
                               DEFAULT_BACKGROUND_THROTTLING_MAX_BUDGET);
   Preferences::AddIntVarCache(&gForegroundThrottlingMaxBudget,
                               "dom.timeout.foreground_throttling_max_budget",
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1814,16 +1814,22 @@
   value: false
   mirror: always
 
 - name: dom.testing.structuredclonetester.enabled
   type: RelaxedAtomicBool
   value: false
   mirror: always
 
+# Time (in ms) that it takes to regenerate 1ms.
+- name: dom.timeout.background_budget_regeneration_rate
+  type: int32_t
+  value: 100
+  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,18 +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);
 
-// Time (in ms) that it takes to regenerate 1ms.
-pref("dom.timeout.background_budget_regeneration_rate", 100);
 // Maximum value (in ms) for the background budget. Only valid for
 // values greater than 0.
 pref("dom.timeout.background_throttling_max_budget", 50);
 // Time (in ms) that it takes to regenerate 1ms.
 pref("dom.timeout.foreground_budget_regeneration_rate", 1);
 // Maximum value (in ms) for the background budget. Only valid for
 // values greater than 0.
 pref("dom.timeout.foreground_throttling_max_budget", -1);