Commit 39fe48c5 authored by Francois Doray's avatar Francois Doray Committed by Chromium LUCI CQ

[blink scheduler] Cleanup the OptOutZeroTimeoutTimersFromThrottling feature.

Experiment results:
https://docs.google.com/document/d/1Fpq31rNHiMHorCygu_1krpIun_0J1ePfef6lf1l4PLA/edit?usp=sharing

Bug: 1075553
Change-Id: I63b893fb7e4fef9269d498c03f95b4cd201133b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568213Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833295}
parent 8536e2e3
......@@ -273,10 +273,6 @@ const base::Feature kWebRtcIgnoreUnspecifiedColorSpace{
const base::Feature kIntensiveWakeUpThrottling{
"IntensiveWakeUpThrottling", base::FEATURE_DISABLED_BY_DEFAULT};
// When enabled, timers with timeout=0 are not throttled.
const base::Feature kOptOutZeroTimeoutTimersFromThrottling{
"OptOutZeroTimeoutTimersFromThrottling", base::FEATURE_ENABLED_BY_DEFAULT};
// Name of the parameter that controls the grace period during which there is no
// intensive wake up throttling after a page is hidden. Defined here to allow
// access from about_flags.cc. The FeatureParam is defined in
......
......@@ -79,9 +79,6 @@ BLINK_COMMON_EXPORT extern const base::Feature kIntensiveWakeUpThrottling;
BLINK_COMMON_EXPORT extern const char
kIntensiveWakeUpThrottling_GracePeriodSeconds_Name[];
BLINK_COMMON_EXPORT extern const base::Feature
kOptOutZeroTimeoutTimersFromThrottling;
#if BUILDFLAG(RTC_USE_H264) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
BLINK_COMMON_EXPORT extern const base::Feature kWebRtcH264WithOpenH264FFmpeg;
#endif // BUILDFLAG(RTC_USE_H264) && BUILDFLAG(ENABLE_FFMPEG_VIDEO_DECODERS)
......
......@@ -19,9 +19,9 @@ pausable. Some internal task queues are not.
| MediaElementEvent | No | No | No | Yes | Yes | Yes |
| CanvasBlobSerialization | No | No | Yes | Yes | Yes | Yes |
| Microtask | No | No | Yes | Yes | Yes | Yes |
| JavascriptTimerDelayedLowNesting | Yes | No [^2] | Yes | Yes | Yes | Yes |
| JavascriptTimerDelayedHighNesting | Yes | Yes [^3] | Yes | Yes | Yes | Yes |
| JavascriptTimerImmediate | No [^1] | No | Yes | Yes | Yes | Yes |
| JavascriptTimerDelayedLowNesting | Yes | No [^1] | Yes | Yes | Yes | Yes |
| JavascriptTimerDelayedHighNesting | Yes | Yes [^2] | Yes | Yes | Yes | Yes |
| JavascriptTimerImmediate | No | No | Yes | Yes | Yes | Yes |
| RemoteEvent | No | No | Yes | Yes | Yes | Yes |
| WebSocket | No | No | Yes | Yes | Yes | Yes |
| PostedMessage | No | No | No | Yes | Yes | Yes |
......@@ -63,9 +63,7 @@ Internal Translation queue supports concept of it running only in the foreground
has been backgrounded for 5 minutes. See
[Chrome Platform Status entry](https://www.chromestatus.com/feature/4718288976216064).
[^1] "Yes" if the "OptOutZeroTimeoutTimersFromThrottling" feature is disabled.
[^2] "Yes" if the "IntensiveWakeUpThrottling" feature is enabled and the
[^1] "Yes" if the "IntensiveWakeUpThrottling" feature is enabled and the
"can_intensively_throttle_low_nesting_level" param is "true".
[^3] "No" if the "IntensiveWakeUpThrottling" feature is disabled.
[^2] "No" if the "IntensiveWakeUpThrottling" feature is disabled.
......@@ -139,63 +139,11 @@ TEST_F(BackgroundPageThrottlingTest, TimersThrottledInBackgroundPage) {
ElementsAre(console_message, console_message, console_message));
}
// Verify that a timer with timeout=0 is not throttled until its timeout is
// rounded up to 4ms.
TEST_F(BackgroundPageThrottlingTest,
ZeroTimeoutTimersThrottledInBackgroundPage) {
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
const String console_message = BuildTimerConsoleMessage();
main_resource.Complete(
String::Format("(<script>"
" function f(repetitions) {"
" if (repetitions == 0) return;"
" console.log('%s');"
" setTimeout(f, 0, repetitions - 1);"
" }"
" setTimeout(f, 0, 50);"
"</script>)",
console_message.Utf8().c_str()));
GetDocument().GetPage()->GetPageScheduler()->SetPageVisible(false);
// Initially, timeout is rounded up to 1ms and no throttling is applied
// (https://crbug.com/402694). After 4 executions, timeout is rounded up to
// 4ms and throttling is applied.
constexpr base::TimeDelta k10Ms = base::TimeDelta::FromMilliseconds(10);
platform_->RunForPeriod(k10Ms);
EXPECT_THAT(FilteredConsoleMessages(),
ElementsAre(console_message, console_message, console_message,
console_message));
platform_->RunForPeriod(base::TimeDelta::FromSeconds(1) - k10Ms);
EXPECT_THAT(FilteredConsoleMessages(),
ElementsAre(console_message, console_message, console_message,
console_message, console_message));
}
namespace {
class OptOutZeroTimeoutFromThrottlingTest : public ThrottlingTestBase {
public:
OptOutZeroTimeoutFromThrottlingTest() {
scoped_feature_list_.InitAndEnableFeature(
features::kOptOutZeroTimeoutTimersFromThrottling);
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
} // namespace
// Verify that in a hidden page, when the kOptOutZeroTimeoutTimersFromThrottling
// feature is enabled:
// Verify the execution time of non-nested timers on a hidden page.
// - setTimeout(..., 0) and setTimeout(..., -1) schedule their callback after
// 1ms. The 1 ms delay exists for historical reasons crbug.com/402694.
// - setTimeout(..., 5) schedules its callback at the next aligned time
TEST_F(OptOutZeroTimeoutFromThrottlingTest, WithoutNesting) {
TEST_F(BackgroundPageThrottlingTest, WithoutNesting) {
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
......@@ -228,10 +176,9 @@ TEST_F(OptOutZeroTimeoutFromThrottlingTest, WithoutNesting) {
timeout_5_message));
}
// Verify that in a hidden page, when the kOptOutZeroTimeoutTimersFromThrottling
// feature is enabled, a timer created with setTimeout(..., 0) is throttled
// after 5 nesting levels.
TEST_F(OptOutZeroTimeoutFromThrottlingTest, SetTimeoutNesting) {
// Verify that on a hidden page, a timer created with setTimeout(..., 0) is
// throttled after 5 nesting levels.
TEST_F(BackgroundPageThrottlingTest, NestedSetTimeoutZero) {
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
......@@ -262,10 +209,9 @@ TEST_F(OptOutZeroTimeoutFromThrottlingTest, SetTimeoutNesting) {
EXPECT_THAT(FilteredConsoleMessages(), Vector<String>(5, console_message));
}
// Verify that in a hidden page, when the kOptOutZeroTimeoutTimersFromThrottling
// feature is enabled, a timer created with setInterval(..., 0) is throttled
// after 5 nesting levels.
TEST_F(OptOutZeroTimeoutFromThrottlingTest, SetIntervalNesting) {
// Verify that in a hidden page, a timer created with setInterval(..., 0) is
// throttled after 5 nesting levels.
TEST_F(BackgroundPageThrottlingTest, NestedSetIntervalZero) {
SimRequest main_resource("https://example.com/", "text/html");
LoadURL("https://example.com/");
......
......@@ -384,11 +384,9 @@ QueueTraits FrameSchedulerImpl::CreateQueueTraitsForTaskType(TaskType type) {
QueueTraits::PrioritisationType::kJavaScriptTimer)
.SetCanBeIntensivelyThrottled(IsIntensiveWakeUpThrottlingEnabled());
case TaskType::kJavascriptTimerImmediate: {
return DeferrableTaskQueueTraits()
.SetPrioritisationType(
QueueTraits::PrioritisationType::kJavaScriptTimer)
.SetCanBeThrottled(!base::FeatureList::IsEnabled(
features::kOptOutZeroTimeoutTimersFromThrottling));
// Immediate timers are not throttled.
return DeferrableTaskQueueTraits().SetPrioritisationType(
QueueTraits::PrioritisationType::kJavaScriptTimer);
}
case TaskType::kInternalLoading:
case TaskType::kNetworking:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment