Title: [257142] trunk/Source/WTF
Revision
257142
Author
[email protected]
Date
2020-02-21 09:51:40 -0800 (Fri, 21 Feb 2020)

Log Message

REGRESSION(r257072): MotionMark | Mac | -10%
https://bugs.webkit.org/show_bug.cgi?id=208054
<rdar://problem/59664582>

Reviewed by Geoffrey Garen.

With rAF and slow scripts, suspended functions may pile up in RunLoop because every cycle does a rendering update.

* wtf/RunLoop.cpp:
(WTF::RunLoop::performWork):
(WTF::RunLoop::suspendFunctionDispatchForCurrentCycle):

Don't suspend if there are already pending suspended functions.

* wtf/RunLoop.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (257141 => 257142)


--- trunk/Source/WTF/ChangeLog	2020-02-21 17:47:58 UTC (rev 257141)
+++ trunk/Source/WTF/ChangeLog	2020-02-21 17:51:40 UTC (rev 257142)
@@ -1,3 +1,21 @@
+2020-02-21  Antti Koivisto  <[email protected]>
+
+        REGRESSION(r257072): MotionMark | Mac | -10%
+        https://bugs.webkit.org/show_bug.cgi?id=208054
+        <rdar://problem/59664582>
+
+        Reviewed by Geoffrey Garen.
+
+        With rAF and slow scripts, suspended functions may pile up in RunLoop because every cycle does a rendering update.
+
+        * wtf/RunLoop.cpp:
+        (WTF::RunLoop::performWork):
+        (WTF::RunLoop::suspendFunctionDispatchForCurrentCycle):
+
+        Don't suspend if there are already pending suspended functions.
+
+        * wtf/RunLoop.h:
+
 2020-02-20  Jiewen Tan  <[email protected]>
 
         [WebAuthn] Replace DeviceIdentity.framework

Modified: trunk/Source/WTF/wtf/RunLoop.cpp (257141 => 257142)


--- trunk/Source/WTF/wtf/RunLoop.cpp	2020-02-21 17:47:58 UTC (rev 257141)
+++ trunk/Source/WTF/wtf/RunLoop.cpp	2020-02-21 17:51:40 UTC (rev 257142)
@@ -92,7 +92,7 @@
     // we guarantee to occasionally return from the run loop so other event sources will be allowed to spin.
 
     size_t functionsToHandle = 1;
-    bool hasNonEmptySuspendedQueue = false;
+    bool didSuspendFunctions = false;
 
     for (size_t functionsHandled = 0; functionsHandled < functionsToHandle; ++functionsHandled) {
         Function<void ()> function;
@@ -106,7 +106,7 @@
                 break;
 
             if (m_isFunctionDispatchSuspended) {
-                hasNonEmptySuspendedQueue = true;
+                didSuspendFunctions = true;
                 break;
             }
 
@@ -121,8 +121,9 @@
 
     // Suspend only for a single cycle.
     m_isFunctionDispatchSuspended = false;
+    m_hasSuspendedFunctions = didSuspendFunctions;
 
-    if (hasNonEmptySuspendedQueue)
+    if (m_hasSuspendedFunctions)
         wakeUp();
 }
 
@@ -138,7 +139,8 @@
 
 void RunLoop::suspendFunctionDispatchForCurrentCycle()
 {
-    if (m_isFunctionDispatchSuspended)
+    // Don't suspend if there are already suspended functions to avoid unexecuted function pile-up.
+    if (m_isFunctionDispatchSuspended || m_hasSuspendedFunctions)
         return;
 
     m_isFunctionDispatchSuspended = true;

Modified: trunk/Source/WTF/wtf/RunLoop.h (257141 => 257142)


--- trunk/Source/WTF/wtf/RunLoop.h	2020-02-21 17:47:58 UTC (rev 257141)
+++ trunk/Source/WTF/wtf/RunLoop.h	2020-02-21 17:51:40 UTC (rev 257142)
@@ -185,6 +185,7 @@
     Lock m_functionQueueLock;
     Deque<Function<void()>> m_functionQueue;
     bool m_isFunctionDispatchSuspended { false };
+    bool m_hasSuspendedFunctions { false };
 
 #if USE(WINDOWS_EVENT_LOOP)
     static LRESULT CALLBACK RunLoopWndProc(HWND, UINT, WPARAM, LPARAM);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to