Set the WebContent process's main thread QoS to USER-INTERACTIVE
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 20:46:57 +0000 (20:46 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Mar 2016 20:46:57 +0000 (20:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155595
<rdar://problem/22534965>

Reviewed by Antti Koivisto.

Source/WebKit2:

Increase the WebContent process main thread's QoS to USER-INTERACTIVE
instead of USER-INITIATED as it is drawing UI. However, use a relative
priority of -1 so that its priority is lower than the one of the
scrolling thread.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

Source/WTF:

Add a relativePriority parameter to setCurrentThreadIsUser*() so that
we can do more fine-grained prioritization of threads that have the
same QoS.

* wtf/Threading.cpp:
(WTF::setCurrentThreadIsUserInteractive):
(WTF::setCurrentThreadIsUserInitiated):
(WTF::createThread): Deleted.
* wtf/Threading.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198350 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Threading.cpp
Source/WTF/wtf/Threading.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebProcess.cpp

index 01815a0..f617086 100644 (file)
@@ -1,3 +1,21 @@
+2016-03-17  Chris Dumez  <cdumez@apple.com>
+
+        Set the WebContent process's main thread QoS to USER-INTERACTIVE
+        https://bugs.webkit.org/show_bug.cgi?id=155595
+        <rdar://problem/22534965>
+
+        Reviewed by Antti Koivisto.
+
+        Add a relativePriority parameter to setCurrentThreadIsUser*() so that
+        we can do more fine-grained prioritization of threads that have the
+        same QoS.
+
+        * wtf/Threading.cpp:
+        (WTF::setCurrentThreadIsUserInteractive):
+        (WTF::setCurrentThreadIsUserInitiated):
+        (WTF::createThread): Deleted.
+        * wtf/Threading.h:
+
 2016-03-17  Filip Pizlo  <fpizlo@apple.com>
 
         Silence leaks in ParkingLot
index 9550d07..2cc5979 100644 (file)
@@ -26,7 +26,9 @@
 #include "config.h"
 #include "Threading.h"
 
-#include <string.h>
+#include <algorithm>
+#include <cmath>
+#include <cstring>
 
 namespace WTF {
 
@@ -82,17 +84,25 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char*
     });
 }
 
-void setCurrentThreadIsUserInteractive()
+void setCurrentThreadIsUserInteractive(int relativePriority)
 {
 #if HAVE(QOS_CLASSES)
-    pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
+    ASSERT(relativePriority <= 0);
+    ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
+    pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, relativePriority);
+#else
+    UNUSED_PARAM(relativePriority);
 #endif
 }
 
-void setCurrentThreadIsUserInitiated()
+void setCurrentThreadIsUserInitiated(int relativePriority)
 {
 #if HAVE(QOS_CLASSES)
-    pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0);
+    ASSERT(relativePriority <= 0);
+    ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
+    pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, relativePriority);
+#else
+    UNUSED_PARAM(relativePriority);
 #endif
 }
 
index 5906ff7..31b32ce 100644 (file)
@@ -58,8 +58,9 @@ WTF_EXPORT_PRIVATE void initializeThreading();
 WTF_EXPORT_PRIVATE ThreadIdentifier createThread(const char* threadName, std::function<void()>);
 
 // Mark the current thread as requiring UI responsiveness.
-WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive();
-WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInitiated();
+// relativePriority is a value in the range [-15, 0] where a lower value indicates a lower priority.
+WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive(int relativePriority = 0);
+WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInitiated(int relativePriority = 0);
 
 WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
 WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int);
index 842af58..7e22f75 100644 (file)
@@ -1,3 +1,19 @@
+2016-03-17  Chris Dumez  <cdumez@apple.com>
+
+        Set the WebContent process's main thread QoS to USER-INTERACTIVE
+        https://bugs.webkit.org/show_bug.cgi?id=155595
+        <rdar://problem/22534965>
+
+        Reviewed by Antti Koivisto.
+
+        Increase the WebContent process main thread's QoS to USER-INTERACTIVE
+        instead of USER-INITIATED as it is drawing UI. However, use a relative
+        priority of -1 so that its priority is lower than the one of the
+        scrolling thread.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+
 2016-03-17  Alex Christensen  <achristensen@webkit.org>
 
         Support manually accepting invalid SSL certificates with NetworkSession
index 45c0261..7866667 100644 (file)
@@ -268,7 +268,8 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
 
     platformInitializeWebProcess(WTFMove(parameters));
 
-    WTF::setCurrentThreadIsUserInitiated();
+    // Match the QoS of the UIProcess and the scrolling thread but use a slightly lower priority.
+    WTF::setCurrentThreadIsUserInteractive(-1);
 
     m_suppressMemoryPressureHandler = parameters.shouldSuppressMemoryPressureHandler;
     if (!m_suppressMemoryPressureHandler)