Title: [169926] trunk/Source
Revision
169926
Author
[email protected]
Date
2014-06-12 18:49:16 -0700 (Thu, 12 Jun 2014)

Log Message

Add support for thread/WorkQueue QoS
https://bugs.webkit.org/show_bug.cgi?id=130688

Reviewed by Anders Carlson & Simon Fraser.


Source/WebCore: 
WebCore's ScrollingThread should be UserInteractive.

* page/scrolling/ScrollingThread.cpp:
(WebCore::ScrollingThread::threadCallback):
    - ScrollingThread should be UserInteractive

Source/WebKit2: 
The EventDispatcher's WorkQueue should be UserInteractive.

* Platform/WorkQueue.cpp:
(WorkQueue::create):
    - pass QOS to constructor.
(WorkQueue::WorkQueue):
    - pass QOS to platformInitialize.
* Platform/WorkQueue.h:
    - added enum, arguments.
* Platform/efl/WorkQueueEfl.cpp:
(WorkQueue::platformInitialize):
    - has extra argument.
* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::platformInitialize):
    - has extra argument.
* Platform/mac/WorkQueueMac.cpp:
(platformQOS):
    - map from enum to platform type.
(WorkQueue::platformInitialize):
    - set the QoS of the dispatch queue.
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::EventDispatcher):
    - EventDispatcher's WorkQueue should be UserInteractive.
* config.h:
    - added HAVE_QOS_CLASSES

Source/WTF: 
Add the ability to mark threads as UserInteractive.

* wtf/Threading.cpp:
(WTF::setCurrentThreadIsUserInteractive):
    - added method to set QoS of current thread to UserInteractive.
* wtf/Threading.h:
    - added declaration.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (169925 => 169926)


--- trunk/Source/WTF/ChangeLog	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WTF/ChangeLog	2014-06-13 01:49:16 UTC (rev 169926)
@@ -1,3 +1,18 @@
+2014-06-12  Gavin Barraclough  <[email protected]>
+
+        Add support for thread/WorkQueue QoS
+        https://bugs.webkit.org/show_bug.cgi?id=130688
+
+        Reviewed by Anders Carlson & Simon Fraser.
+
+        Add the ability to mark threads as UserInteractive.
+
+        * wtf/Threading.cpp:
+        (WTF::setCurrentThreadIsUserInteractive):
+            - added method to set QoS of current thread to UserInteractive.
+        * wtf/Threading.h:
+            - added declaration.
+
 2014-06-12  Alexey Proskuryakov  <[email protected]>
 
         Fix Mac after r169880.

Modified: trunk/Source/WTF/wtf/Platform.h (169925 => 169926)


--- trunk/Source/WTF/wtf/Platform.h	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WTF/wtf/Platform.h	2014-06-13 01:49:16 UTC (rev 169926)
@@ -1000,6 +1000,11 @@
 #define WTF_USE_CONTENT_FILTERING 1
 #endif
 
+#ifndef HAVE_QOS_CLASSES
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+#define HAVE_QOS_CLASSES 1
+#endif
+#endif
 
 #define WTF_USE_GRAMMAR_CHECKING 1
 

Modified: trunk/Source/WTF/wtf/Threading.cpp (169925 => 169926)


--- trunk/Source/WTF/wtf/Threading.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WTF/wtf/Threading.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -84,6 +84,13 @@
     return createThreadInternal(threadEntryPoint, context, name);
 }
 
+void setCurrentThreadIsUserInteractive()
+{
+#if HAVE(QOS_CLASSES)
+    pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 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 (169925 => 169926)


--- trunk/Source/WTF/wtf/Threading.h	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WTF/wtf/Threading.h	2014-06-13 01:49:16 UTC (rev 169926)
@@ -81,6 +81,9 @@
 // The thread name must be a literal since on some platforms it's passed in to the thread.
 WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
 
+// Mark the current thread as requiring UI responsiveness.
+WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive();
+
 // Internal platform-specific createThread implementation.
 ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadName);
 

Modified: trunk/Source/WebCore/ChangeLog (169925 => 169926)


--- trunk/Source/WebCore/ChangeLog	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebCore/ChangeLog	2014-06-13 01:49:16 UTC (rev 169926)
@@ -1,3 +1,16 @@
+2014-06-12  Gavin Barraclough  <[email protected]>
+
+        Add support for thread/WorkQueue QoS
+        https://bugs.webkit.org/show_bug.cgi?id=130688
+
+        Reviewed by Anders Carlson & Simon Fraser.
+
+        WebCore's ScrollingThread should be UserInteractive.
+
+        * page/scrolling/ScrollingThread.cpp:
+        (WebCore::ScrollingThread::threadCallback):
+            - ScrollingThread should be UserInteractive
+
 2014-06-12  Brent Fulgham  <[email protected]>
 
         [Mac] Build fix after r169919.

Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp (169925 => 169926)


--- trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -91,6 +91,7 @@
 
 void ScrollingThread::threadCallback(void* scrollingThread)
 {
+    WTF::setCurrentThreadIsUserInteractive();
     static_cast<ScrollingThread*>(scrollingThread)->threadBody();
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (169925 => 169926)


--- trunk/Source/WebKit2/ChangeLog	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-13 01:49:16 UTC (rev 169926)
@@ -1,3 +1,36 @@
+2014-06-12  Gavin Barraclough  <[email protected]>
+
+        Add support for thread/WorkQueue QoS
+        https://bugs.webkit.org/show_bug.cgi?id=130688
+
+        Reviewed by Anders Carlson & Simon Fraser.
+
+        The EventDispatcher's WorkQueue should be UserInteractive.
+
+        * Platform/WorkQueue.cpp:
+        (WorkQueue::create):
+            - pass QOS to constructor.
+        (WorkQueue::WorkQueue):
+            - pass QOS to platformInitialize.
+        * Platform/WorkQueue.h:
+            - added enum, arguments.
+        * Platform/efl/WorkQueueEfl.cpp:
+        (WorkQueue::platformInitialize):
+            - has extra argument.
+        * Platform/gtk/WorkQueueGtk.cpp:
+        (WorkQueue::platformInitialize):
+            - has extra argument.
+        * Platform/mac/WorkQueueMac.cpp:
+        (platformQOS):
+            - map from enum to platform type.
+        (WorkQueue::platformInitialize):
+            - set the QoS of the dispatch queue.
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::EventDispatcher):
+            - EventDispatcher's WorkQueue should be UserInteractive.
+        * config.h:
+            - added HAVE_QOS_CLASSES
+
 2014-06-12  Simon Fraser  <[email protected]>
 
         [iOS] Tiny hack to fix WebKitTestRunner view visibility

Modified: trunk/Source/WebKit2/Platform/WorkQueue.cpp (169925 => 169926)


--- trunk/Source/WebKit2/Platform/WorkQueue.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/Platform/WorkQueue.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -26,14 +26,14 @@
 #include "config.h"
 #include "WorkQueue.h"
 
-PassRefPtr<WorkQueue> WorkQueue::create(const char* name)
+PassRefPtr<WorkQueue> WorkQueue::create(const char* name, QOS qos)
 {
-    return adoptRef(new WorkQueue(name));
+    return adoptRef(new WorkQueue(name, qos));
 }
 
-WorkQueue::WorkQueue(const char* name)
+WorkQueue::WorkQueue(const char* name, QOS qos)
 {
-    platformInitialize(name);
+    platformInitialize(name, qos);
 }
 
 WorkQueue::~WorkQueue()

Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (169925 => 169926)


--- trunk/Source/WebKit2/Platform/WorkQueue.h	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h	2014-06-13 01:49:16 UTC (rev 169926)
@@ -53,7 +53,15 @@
 
 class WorkQueue : public ThreadSafeRefCounted<WorkQueue> {
 public:
-    static PassRefPtr<WorkQueue> create(const char* name);
+    enum class QOS {
+        UserInteractive,
+        UserInitiated,
+        Default,
+        Utility,
+        Background
+    };
+    
+    static PassRefPtr<WorkQueue> create(const char* name, QOS = QOS::Default);
     ~WorkQueue();
 
     void dispatch(std::function<void ()>);
@@ -70,9 +78,9 @@
 #endif
 
 private:
-    explicit WorkQueue(const char* name);
+    explicit WorkQueue(const char* name, QOS);
 
-    void platformInitialize(const char* name);
+    void platformInitialize(const char* name, QOS);
     void platformInvalidate();
 
 #if OS(DARWIN)

Modified: trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp (169925 => 169926)


--- trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/Platform/efl/WorkQueueEfl.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -23,7 +23,7 @@
 #include <DispatchQueueEfl.h>
 #include <DispatchQueueWorkItemEfl.h>
 
-void WorkQueue::platformInitialize(const char* name)
+void WorkQueue::platformInitialize(const char* name, QOS)
 {
     m_dispatchQueue = DispatchQueue::create(name);
 }

Modified: trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp (169925 => 169926)


--- trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -32,7 +32,7 @@
 
 static const size_t kVisualStudioThreadNameLimit = 31;
 
-void WorkQueue::platformInitialize(const char* name)
+void WorkQueue::platformInitialize(const char* name, QOS)
 {
     m_eventContext = adoptGRef(g_main_context_new());
     ASSERT(m_eventContext);

Modified: trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp (169925 => 169926)


--- trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -44,9 +44,31 @@
     });
 }
 
-void WorkQueue::platformInitialize(const char* name)
+#if HAVE(QOS_CLASSES)
+static dispatch_qos_class_t dispatchQOSClass(WorkQueue::QOS qos)
 {
-    m_dispatchQueue = dispatch_queue_create(name, 0);
+    switch (qos) {
+    case WorkQueue::QOS::UserInteractive:
+        return QOS_CLASS_USER_INTERACTIVE;
+    case WorkQueue::QOS::UserInitiated:
+        return QOS_CLASS_USER_INITIATED;
+    case WorkQueue::QOS::Default:
+        return QOS_CLASS_DEFAULT;
+    case WorkQueue::QOS::Utility:
+        return QOS_CLASS_UTILITY;
+    case WorkQueue::QOS::Background:
+        return QOS_CLASS_BACKGROUND;
+    }
+}
+#endif
+
+void WorkQueue::platformInitialize(const char* name, QOS qos)
+{
+    dispatch_queue_attr_t attr = 0;
+#if HAVE(QOS_CLASSES)
+    attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, dispatchQOSClass(qos), 0);
+#endif
+    m_dispatchQueue = dispatch_queue_create(name, attr);
     dispatch_set_context(m_dispatchQueue, this);
 }
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (169925 => 169926)


--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2014-06-13 00:55:54 UTC (rev 169925)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp	2014-06-13 01:49:16 UTC (rev 169926)
@@ -52,7 +52,7 @@
 }
 
 EventDispatcher::EventDispatcher()
-    : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher"))
+    : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::QOS::UserInteractive))
     , m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
 #if ENABLE(IOS_TOUCH_EVENTS)
     , m_touchEventsLock(SPINLOCK_INITIALIZER)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to