Bug 1569004 - Convert dom.timeout.budget_throttling_max_delay to static pref. r=njn
authorKristen Wright <kwright@mozilla.com>
Fri, 26 Jul 2019 21:11:41 +0000
changeset 485164 760fd1f569808515a578292a661a06aa93f649e8
parent 485163 ba7879d877738e0d676cc6504bab2e4c7d581f03
child 485165 0a9a0b8b35fa6c7fc4a8a8ab15d189673e241604
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.budget_throttling_max_delay to static pref. r=njn Converts dom.timeout.budget_throttling_max_delay varcache pref to static pref, removes entry from all.js, and adds entry to StaticPrefList.yaml Differential Revision: https://phabricator.services.mozilla.com/D39451
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,19 +29,17 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 LazyLogModule gTimeoutLog("Timeout");
 
 static int32_t gRunningTimeoutDepth = 0;
 
-#define DEFAULT_BUDGET_THROTTLING_MAX_DELAY 15000  // 15s
 #define DEFAULT_ENABLE_BUDGET_TIMEOUT_THROTTLING false
-static int32_t gBudgetThrottlingMaxDelay = 0;
 static bool gEnableBudgetTimeoutThrottling = false;
 
 // static
 const uint32_t TimeoutManager::InvalidFiringId = 0;
 
 namespace {
 double GetRegenerationFactor(bool aIsBackground) {
   // Lookup function for "dom.timeout.{background,
@@ -76,17 +74,17 @@ 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 /
+      -StaticPrefs::dom_timeout_budget_throttling_max_delay() /
       std::max(
           aIsBackground
               ? StaticPrefs::dom_timeout_background_budget_regeneration_rate()
               : StaticPrefs::dom_timeout_foreground_budget_regeneration_rate(),
           1));
 }
 }  // namespace
 
@@ -218,17 +216,18 @@ TimeDuration TimeoutManager::MinScheduli
   // The value that we compute is the time in the future when we again
   // have a positive execution budget. We do this by taking the
   // execution budget into account, which if it positive implies that
   // we have time left to execute, and if it is negative implies that
   // we should throttle it until the budget again is positive. The
   // factor used is the rate of budget regeneration.
   //
   // We clamp the delay to be less than or equal to
-  // gBudgetThrottlingMaxDelay to not entirely starve the timeouts.
+  // "dom.timeout.budget_throttling_max_delay" to not entirely starve
+  // the timeouts.
   //
   // Consider these examples assuming we should throttle using
   // budgets:
   //
   // mExecutionBudget is 20ms
   // factor is 1, which is 1 ms/ms
   // delay is 0ms
   // then we will compute the minimum delay:
@@ -445,19 +444,16 @@ TimeoutManager::~TimeoutManager() {
   mIdleExecutor->Shutdown();
 
   MOZ_LOG(gTimeoutLog, LogLevel::Debug,
           ("TimeoutManager %p destroyed\n", this));
 }
 
 /* static */
 void TimeoutManager::Initialize() {
-  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);
 }
 
 uint32_t TimeoutManager::GetTimeoutId(Timeout::Reason aReason) {
   switch (aReason) {
     case Timeout::Reason::eIdleCallbackTimeout:
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -1840,16 +1840,22 @@
 
 # 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
 
+# The maximum amount a timeout can be delayed by budget throttling.
+- name: dom.timeout.budget_throttling_max_delay
+  type: int32_t
+  value: 15000
+  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);
 
-// 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);
 
 // Enable <input type=color> by default. It will be turned off for remaining
 // platforms which don't have a color picker implemented yet.