Title: [166184] trunk/Source
Revision
166184
Author
[email protected]
Date
2014-03-24 12:25:32 -0700 (Mon, 24 Mar 2014)

Log Message

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

Reviewed by Andreas Kling.

Source/_javascript_Core: 

* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::blockFreeingThreadStartFunc):
    - block freeing is a utility activity.

Source/WTF: 

* wtf/FastMalloc.cpp:
(WTF::TCMalloc_PageHeap::runScavengerThread):
    - block freeing is a utility activity.
* wtf/Threading.h:
    - declaration.
* wtf/ThreadingPthreads.cpp:
(WTF::createThreadInternal):
    - default to interactive.
(WTF::setCurrentThreadQOSUtility):
    - implementation.
* wtf/ThreadingWin.cpp:
(WTF::setCurrentThreadQOSUtility):
    - no-op implementation.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (166183 => 166184)


--- trunk/Source/_javascript_Core/ChangeLog	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-03-24 19:25:32 UTC (rev 166184)
@@ -1,3 +1,14 @@
+2014-03-24  Gavin Barraclough  <[email protected]>
+
+        Add support for thread QoS
+        https://bugs.webkit.org/show_bug.cgi?id=130688
+
+        Reviewed by Andreas Kling.
+
+        * heap/BlockAllocator.cpp:
+        (JSC::BlockAllocator::blockFreeingThreadStartFunc):
+            - block freeing is a utility activity.
+
 2014-03-24  Filip Pizlo  <[email protected]>
 
         Unreviewed, fix CLOOP build.

Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.cpp (166183 => 166184)


--- trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2014-03-24 19:25:32 UTC (rev 166184)
@@ -32,6 +32,7 @@
 #include "JSCInlines.h"
 #include "WeakBlock.h"
 #include <wtf/CurrentTime.h>
+#include <wtf/Threading.h>
 
 namespace JSC {
 
@@ -117,6 +118,7 @@
 
 void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator)
 {
+    setCurrentThreadQOSUtility();
     static_cast<BlockAllocator*>(blockAllocator)->blockFreeingThreadMain();
 }
 

Modified: trunk/Source/WTF/ChangeLog (166183 => 166184)


--- trunk/Source/WTF/ChangeLog	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/WTF/ChangeLog	2014-03-24 19:25:32 UTC (rev 166184)
@@ -1,3 +1,24 @@
+2014-03-24  Gavin Barraclough  <[email protected]>
+
+        Add support for thread QoS
+        https://bugs.webkit.org/show_bug.cgi?id=130688
+
+        Reviewed by Andreas Kling.
+
+        * wtf/FastMalloc.cpp:
+        (WTF::TCMalloc_PageHeap::runScavengerThread):
+            - block freeing is a utility activity.
+        * wtf/Threading.h:
+            - declaration.
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::createThreadInternal):
+            - default to interactive.
+        (WTF::setCurrentThreadQOSUtility):
+            - implementation.
+        * wtf/ThreadingWin.cpp:
+        (WTF::setCurrentThreadQOSUtility):
+            - no-op implementation.
+
 2014-03-23  Hyowon Kim  <[email protected]>
 
         Move all EFL typedefs into EflTypedefs.h.

Modified: trunk/Source/WTF/wtf/FastMalloc.cpp (166183 => 166184)


--- trunk/Source/WTF/wtf/FastMalloc.cpp	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/WTF/wtf/FastMalloc.cpp	2014-03-24 19:25:32 UTC (rev 166184)
@@ -79,6 +79,7 @@
 
 #include "Assertions.h"
 #include "CurrentTime.h"
+#include "Threading.h"
 
 #include <limits>
 #if OS(WINDOWS)
@@ -2058,6 +2059,8 @@
 
 void* TCMalloc_PageHeap::runScavengerThread(void* context)
 {
+    setCurrentThreadQOSUtility();
+
     static_cast<TCMalloc_PageHeap*>(context)->scavengerThread();
 #if (COMPILER(MSVC) || COMPILER(SUNCC))
     // Without this, Visual Studio and Sun Studio will complain that this method does not return a value.

Modified: trunk/Source/WTF/wtf/Threading.h (166183 => 166184)


--- trunk/Source/WTF/wtf/Threading.h	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/WTF/wtf/Threading.h	2014-03-24 19:25:32 UTC (rev 166184)
@@ -89,6 +89,7 @@
 void initializeCurrentThreadInternal(const char* threadName);
 
 WTF_EXPORT_PRIVATE ThreadIdentifier currentThread();
+WTF_EXPORT_PRIVATE void setCurrentThreadQOSUtility();
 WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int);
 WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
 WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
@@ -99,6 +100,7 @@
 using WTF::createThread;
 using WTF::currentThread;
 using WTF::changeThreadPriority;
+using WTF::setCurrentThreadQOSUtility;
 using WTF::detachThread;
 using WTF::waitForThreadCompletion;
 

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (166183 => 166184)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-03-24 19:25:32 UTC (rev 166184)
@@ -173,7 +173,15 @@
 {
     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 __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+    pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE, 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;
     }
@@ -225,7 +233,14 @@
 
     pthread_setschedparam(pthreadHandle, policy, &param);
 }
-    
+
+void setCurrentThreadQOSUtility()
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+    pthread_set_qos_class_np(pthread_self(), QOS_CLASS_UTILITY, 0);
+#endif
+}
+
 int waitForThreadCompletion(ThreadIdentifier threadID)
 {
     pthread_t pthreadHandle;

Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (166183 => 166184)


--- trunk/Source/WTF/wtf/ThreadingWin.cpp	2014-03-24 18:58:22 UTC (rev 166183)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp	2014-03-24 19:25:32 UTC (rev 166184)
@@ -257,6 +257,10 @@
     SetThreadPriority(threadHandle, THREAD_PRIORITY_NORMAL + delta);
 }
 
+void setCurrentThreadQOSUtility()
+{
+}
+
 int waitForThreadCompletion(ThreadIdentifier threadID)
 {
     ASSERT(threadID);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to