This is a large patch which tries to switch many of the external consumers of
nsGlobalWindow to instead use the new Inner or Outer variants.
MozReview-Commit-ID: 99648Lm46T5
Don't consider WebSockets, IndexedDB, etc when considering background
tabs for ordinary throttling since that makes us throttle way less
than we used to.
Deduct timeout execution time from a continuously regenerating
execution budget. Then throttle timeouts by using that budget in
TimeoutManager::MinSchedulingDelay to adjust the minimum value if
the budget is negative. The minimum value is adjusted to be a
value where the budget would have regenerated to be +0 ms.
The execution budget is clamped by values in ms defined in prefs:
* dom.timeout.background_throttling_max_budget: 50
* dom.timeout.foreground_throttling_max_budget: -1
A value equal or less than 0 means that the budget is infinite.
The regeneration rate can be controlled by the following prefs:
* dom.timeout.background_budget_regeneration_rate
* dom.timeout.foreground_budget_regeneration_rate
one each for foreground and background throttling.
To not starve timeouts indefinitely we clamp the minimum delay using
the pref:
* dom.timeout.budget_throttling_max_delay: 15000
The feature is behind the pref:
* dom.timeout.enable_budget_timer_throttling
Expose the utility framework for computing runnable execution time for
telemetry to be able to use it for managing budget times.
--HG--
extra : rebase_source : c7aba3d039116ed10597e7b58e2c6e7911cb493d
Measure execution time by adding telemetry probes for tracking
foreground, tracking background, non-tracking foreground and
non-tracking background timeouts.
--HG--
extra : source : 69439c0cd3e6d118681d1bb6586cb0a7b4bb85fc
Measure execution time by adding telemetry probes for tracking
foreground, tracking background, non-tracking foreground and
non-tracking background timeouts.
--HG--
extra : rebase_source : f638cc4422a777bbd093d5bbb2d5852c19b1c9d1
Clear the throttle tracking timer in ClearAllTimeouts. Also clear it
in Suspend, and if mThrottleTrackingTimeouts isn't set restart the
timer if the document hasn't loaded.
--HG--
extra : rebase_source : 8be5570265adda22775f6bf7528e39dde855429f
For simplicity, this test is being added to test_classifier.html which
already has all of the infrastructure necessary for setting up a test
domain as a tracking domain.
This will allow us to schedule these timers differently in the future.
This patch only performs the refactoring, and is not intended to change
any behavior. Specifically, this patch doesn't change the order in
which timeouts are fired -- they should still all be fired according to
the mWhen field.
The implementation works by splitting timeout storage per window into
two Timeouts objects, mNormalTimeouts and mTrackingTimeouts. The ForEach
helper methods are extended to deal with both of these objects, and as a
result, most of the algorithms operating on the list of timeouts work
correctly without any modification, with the notable exception of
RunTimeout.
In RunTimeout(), the order in which Timeout objects are processed does
matter, so for that case we use the OrderedTimeoutIterator class to
iterate over both linked lists simultaneously in the mWhen order. Also,
inserting the dummy timeout when running the timeouts is only necessary
for the linked list where the last expired timeout is coming from, so we
only inject the dummy timer into the corresponding list, therefore we
remember which list we picked the last expired timeout from when
looking for it.
With this patch, all of the methods which loop over the timeouts
are refactored in preparation for splitting the list of timeouts
into a tracking and a normal list.
These generic loops need to run in the same way for both normal and
tracking timeouts. This refactoring allows us to only change the
TimeoutManager ForEach helpers to loop over both linked lists when
splitting the timeouts into two separate lists without needing to
modify each call site separately.
This code now lives in TimeoutManager. Note that this is a transition
state, the Timeout list management code also needs to be refactored out
later.
In order to simplify the lifetime management of the new class, its
lifetime is equal to the lifetime of its containing nsGlobalWindow. In
a few places where we need to dispatch runnables to do asynchronous work
on this object, we hold the containing window alive to guarantee safety.
This patch also removes a bit of dead code that was left over from the
code removed in bug 1281793. See:
https://hg.mozilla.org/mozilla-central/rev/0ac748f4d677#l1.63