Title: [170065] trunk/Source
Revision
170065
Author
[email protected]
Date
2014-06-17 12:03:04 -0700 (Tue, 17 Jun 2014)

Log Message

Web process main thread priority is lower than some network process threads.
<https://webkit.org/b/133987>
<rdar://problem/17330300>

Source/WebKit2:
Mark the main thread as "user initiated" in process entry.

Reviewed by Maciej Stachowiak.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::initialize):

Source/WTF:
Bring all of our threads to the appropriate priority level by opting in to the
threading QoS APIs. By marking them "user initiated", they still yield to UI
interaction, but take priority over background tasks.

Reviewed by Maciej Stachowiak.

* wtf/Platform.h:
* wtf/Threading.cpp:
(WTF::setCurrentThreadIsUserInitiated):
* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::createThreadInternal):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (170064 => 170065)


--- trunk/Source/WTF/ChangeLog	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WTF/ChangeLog	2014-06-17 19:03:04 UTC (rev 170065)
@@ -1,3 +1,22 @@
+2014-06-17  Andreas Kling  <[email protected]>
+
+        Web process main thread priority is lower than some network process threads.
+        <https://webkit.org/b/133987>
+        <rdar://problem/17330300>
+
+        Bring all of our threads to the appropriate priority level by opting in to the
+        threading QoS APIs. By marking them "user initiated", they still yield to UI
+        interaction, but take priority over background tasks.
+
+        Reviewed by Maciej Stachowiak.
+
+        * wtf/Platform.h:
+        * wtf/Threading.cpp:
+        (WTF::setCurrentThreadIsUserInitiated):
+        * wtf/Threading.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::createThreadInternal):
+
 2014-06-17  Alex Christensen  <[email protected]>
 
         Enable css jit for armv7 on iOS.

Modified: trunk/Source/WTF/wtf/Platform.h (170064 => 170065)


--- trunk/Source/WTF/wtf/Platform.h	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WTF/wtf/Platform.h	2014-06-17 19:03:04 UTC (rev 170065)
@@ -1001,7 +1001,7 @@
 #endif
 
 #ifndef HAVE_QOS_CLASSES
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)
 #define HAVE_QOS_CLASSES 1
 #endif
 #endif

Modified: trunk/Source/WTF/wtf/Threading.cpp (170064 => 170065)


--- trunk/Source/WTF/wtf/Threading.cpp	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WTF/wtf/Threading.cpp	2014-06-17 19:03:04 UTC (rev 170065)
@@ -91,6 +91,13 @@
 #endif
 }
 
+void setCurrentThreadIsUserInitiated()
+{
+#if HAVE(QOS_CLASSES)
+    pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0);
+#endif
+}
+
 #if PLATFORM(MAC) || PLATFORM(WIN)
 
 // For ABI compatibility with Safari on Mac / Windows: Safari uses the private

Modified: trunk/Source/WTF/wtf/Threading.h (170064 => 170065)


--- trunk/Source/WTF/wtf/Threading.h	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WTF/wtf/Threading.h	2014-06-17 19:03:04 UTC (rev 170065)
@@ -84,6 +84,8 @@
 // Mark the current thread as requiring UI responsiveness.
 WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive();
 
+WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInitiated();
+
 // Internal platform-specific createThread implementation.
 ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadName);
 

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (170064 => 170065)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-06-17 19:03:04 UTC (rev 170065)
@@ -175,7 +175,14 @@
 {
     auto invocation = std::make_unique<ThreadFunctionInvocation>(entryPoint, data);
     pthread_t threadHandle;
-    if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get())) {
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+#if HAVE(QOS_CLASSES)
+    pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INITIATED, 0);
+#endif
+    int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get());
+    pthread_attr_destroy(&attr);
+    if (error) {
         LOG_ERROR("Failed to create pthread at entry point %p with data %p", wtfThreadEntryPoint, invocation.get());
         return 0;
     }

Modified: trunk/Source/WebKit2/ChangeLog (170064 => 170065)


--- trunk/Source/WebKit2/ChangeLog	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-17 19:03:04 UTC (rev 170065)
@@ -1,3 +1,16 @@
+2014-06-17  Andreas Kling  <[email protected]>
+
+        Web process main thread priority is lower than some network process threads.
+        <https://webkit.org/b/133987>
+        <rdar://problem/17330300>
+
+        Mark the main thread as "user initiated" in process entry.
+
+        Reviewed by Maciej Stachowiak.
+
+        * Shared/ChildProcess.cpp:
+        (WebKit::ChildProcess::initialize):
+
 2014-06-17  Anders Carlsson  <[email protected]>
 
         Add SPI to get the NSURLRequest from a WKNavigationResponse

Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (170064 => 170065)


--- trunk/Source/WebKit2/Shared/ChildProcess.cpp	2014-06-17 19:01:55 UTC (rev 170064)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp	2014-06-17 19:03:04 UTC (rev 170065)
@@ -61,6 +61,8 @@
 {
     platformInitialize();
 
+    WTF::setCurrentThreadIsUserInitiated();
+
     initializeProcess(parameters);
     initializeProcessName(parameters);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to