Title: [292348] branches/safari-613-branch
Revision
292348
Author
[email protected]
Date
2022-04-04 14:56:40 -0700 (Mon, 04 Apr 2022)

Log Message

Cherry-pick r292242. rdar://91259284

    Change one-shot maxTimerNestingLevel from 5 to 10
    https://bugs.webkit.org/show_bug.cgi?id=237168

    Reviewed by Sam Weinig, Saam Barati, and Cameron McCormack .

    Source/WebCore:

    Recently, we found from Chromium change[1] that changing this from 5 to 10 offers 10% Speedometer2 improvement
    because Speedometer2's setTimeout nesting level is typically 7-8. We discussed with folks including Chris, Maciej,
    Saam, and Cameron and for now, we increase this from 5 to 10 to align to Blink's change to keep these kind of web
    content fast. This is not aligned to the spec, and currently, we only apply it to one-shot timer.

    [1]: https://chromium-review.googlesource.com/c/chromium/src/+/3473463

    page/DOMTimer.cpp:
    (WebCore::DOMTimer::intervalClampedToMinimum const):
    (WebCore::DOMTimer::alignedFireTime const):

    LayoutTests:

    fast/dom/timer-increase-min-interval.html:
    fast/dom/timer-throttling-hidden-page-expected.txt:
    fast/dom/timer-throttling-hidden-page.html:

Modified Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/fast/dom/timer-increase-min-interval.html (292347 => 292348)


--- branches/safari-613-branch/LayoutTests/fast/dom/timer-increase-min-interval.html	2022-04-04 21:56:37 UTC (rev 292347)
+++ branches/safari-613-branch/LayoutTests/fast/dom/timer-increase-min-interval.html	2022-04-04 21:56:40 UTC (rev 292348)
@@ -17,7 +17,8 @@
 function slowTimeoutHandler() {
     // Note: the count threshold is tied somewhat to the
     // maxTimerNestingLevel in DOMTimer.cpp.
-    if (count < 10)
+    // Up to 10, we use 1ms, and after that, it becomes 500ms. So, it should be 12.
+    if (count < 12)
         log("PASS");
     else
         log("FAIL -- timeout ran " + count + " times");

Modified: branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page-expected.txt (292347 => 292348)


--- branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page-expected.txt	2022-04-04 21:56:37 UTC (rev 292347)
+++ branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page-expected.txt	2022-04-04 21:56:40 UTC (rev 292348)
@@ -8,6 +8,11 @@
 PASS internals.isTimerThrottled(timerHandle) is false
 PASS internals.isTimerThrottled(timerHandle) is false
 PASS internals.isTimerThrottled(timerHandle) is false
+PASS internals.isTimerThrottled(timerHandle) is false
+PASS internals.isTimerThrottled(timerHandle) is false
+PASS internals.isTimerThrottled(timerHandle) is false
+PASS internals.isTimerThrottled(timerHandle) is false
+PASS internals.isTimerThrottled(timerHandle) is false
 PASS internals.isTimerThrottled(timerHandle) is true
 PASS successfullyParsed is true
 

Modified: branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page.html (292347 => 292348)


--- branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page.html	2022-04-04 21:56:37 UTC (rev 292347)
+++ branches/safari-613-branch/LayoutTests/fast/dom/timer-throttling-hidden-page.html	2022-04-04 21:56:40 UTC (rev 292348)
@@ -7,7 +7,7 @@
 
         let timerCount = 0;
         const timeoutInterval = 10;
-        const maxNestingLevel = 5;
+        const maxNestingLevel = 10;
         let timerHandle = 0;
 
         function testTimer()

Modified: branches/safari-613-branch/Source/WebCore/page/DOMTimer.cpp (292347 => 292348)


--- branches/safari-613-branch/Source/WebCore/page/DOMTimer.cpp	2022-04-04 21:56:37 UTC (rev 292347)
+++ branches/safari-613-branch/Source/WebCore/page/DOMTimer.cpp	2022-04-04 21:56:40 UTC (rev 292348)
@@ -48,10 +48,12 @@
 
 namespace WebCore {
 
-static const Seconds minIntervalForNonUserObservableChangeTimers { 1_s }; // Empirically determined to maximize battery life.
-static const Seconds minIntervalForOneShotTimers { 0_ms };
-static const Seconds minIntervalForRepeatingTimers { 1_ms };
-static const int maxTimerNestingLevel = 5;
+static constexpr Seconds minIntervalForNonUserObservableChangeTimers { 1_s }; // Empirically determined to maximize battery life.
+static constexpr Seconds minIntervalForOneShotTimers { 0_ms };
+static constexpr Seconds minIntervalForRepeatingTimers { 1_ms };
+static constexpr int maxTimerNestingLevel = 10;
+static constexpr int maxTimerNestingLevelForOneShotTimers = 10;
+static constexpr int maxTimerNestingLevelForRepeatingTimers = 5;
 
 class DOMTimerFireState {
 public:
@@ -385,7 +387,7 @@
     Seconds interval = std::max(m_oneShot ? minIntervalForOneShotTimers : minIntervalForRepeatingTimers, m_originalInterval);
 
     // Only apply throttling to repeating timers.
-    if (m_nestingLevel < maxTimerNestingLevel)
+    if (m_nestingLevel < (m_oneShot ? maxTimerNestingLevelForOneShotTimers : maxTimerNestingLevelForRepeatingTimers))
         return interval;
 
     // Apply two throttles - the global (per Page) minimum, and also a per-timer throttle.
@@ -397,7 +399,7 @@
 
 std::optional<MonotonicTime> DOMTimer::alignedFireTime(MonotonicTime fireTime) const
 {
-    Seconds alignmentInterval = scriptExecutionContext()->domTimerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel);
+    Seconds alignmentInterval = scriptExecutionContext()->domTimerAlignmentInterval(m_nestingLevel >= (m_oneShot ? maxTimerNestingLevelForOneShotTimers : maxTimerNestingLevelForRepeatingTimers));
     if (!alignmentInterval)
         return std::nullopt;
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to