Title: [197737] releases/WebKitGTK/webkit-2.12/Source/WebCore
Revision
197737
Author
[email protected]
Date
2016-03-08 00:16:29 -0800 (Tue, 08 Mar 2016)

Log Message

Merge r197415 - Timer alignment in separate web processes should not all sync up to the same point.
https://bugs.webkit.org/show_bug.cgi?id=154878

Reviewed by Chris Dumez.

For any given WebContent process it is desirable that timers are synchronized to a single
alignment point, but if all WebContent processes align to the same point then there may
be a thundering herd of processes waking up.

* page/DOMTimer.cpp:
(WebCore::DOMTimer::alignedFireTime):
    - align to a randomized point.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog (197736 => 197737)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-03-08 08:13:47 UTC (rev 197736)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/ChangeLog	2016-03-08 08:16:29 UTC (rev 197737)
@@ -1,3 +1,18 @@
+2016-03-01  Gavin Barraclough  <[email protected]>
+
+        Timer alignment in separate web processes should not all sync up to the same point.
+        https://bugs.webkit.org/show_bug.cgi?id=154878
+
+        Reviewed by Chris Dumez.
+
+        For any given WebContent process it is desirable that timers are synchronized to a single
+        alignment point, but if all WebContent processes align to the same point then there may
+        be a thundering herd of processes waking up.
+
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::alignedFireTime):
+            - align to a randomized point.
+
 2016-03-01  Andreas Kling  <[email protected]>
 
         REGRESSION (r154616): Accelerated drawing is off during the initial load

Modified: releases/WebKitGTK/webkit-2.12/Source/WebCore/page/DOMTimer.cpp (197736 => 197737)


--- releases/WebKitGTK/webkit-2.12/Source/WebCore/page/DOMTimer.cpp	2016-03-08 08:13:47 UTC (rev 197736)
+++ releases/WebKitGTK/webkit-2.12/Source/WebCore/page/DOMTimer.cpp	2016-03-08 08:16:29 UTC (rev 197737)
@@ -40,6 +40,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/MathExtras.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/RandomNumber.h>
 #include <wtf/StdLibExtras.h>
 
 #if PLATFORM(IOS)
@@ -422,8 +423,15 @@
 
 double DOMTimer::alignedFireTime(double fireTime) const
 {
-    if (double alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel))
-        return ceil(fireTime / alignmentInterval) * alignmentInterval;
+    if (double alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel)) {
+        // Don't mess with zero-delay timers.
+        if (!fireTime)
+            return fireTime;
+        static const double randomizedAlignment = randomNumber();
+        // Force alignment to randomizedAlignment fraction of the way between alignemntIntervals, e.g.
+        // if alignmentInterval is 10 and randomizedAlignment is 0.3 this will align to 3, 13, 23, ...
+        return (ceil(fireTime / alignmentInterval - randomizedAlignment) + randomizedAlignment) * alignmentInterval;
+    }
 
     return fireTime;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to