Title: [211714] branches/safari-603-branch/Source
Revision
211714
Author
matthew_han...@apple.com
Date
2017-02-05 22:17:50 -0800 (Sun, 05 Feb 2017)

Log Message

Merge r211482. rdar://problem/29711409

Modified Paths

Diff

Modified: branches/safari-603-branch/Source/WTF/ChangeLog (211713 => 211714)


--- branches/safari-603-branch/Source/WTF/ChangeLog	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WTF/ChangeLog	2017-02-06 06:17:50 UTC (rev 211714)
@@ -1,3 +1,34 @@
+2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r211482. rdar://problem/29711409
+
+    2017-02-01  Andreas Kling  <akl...@apple.com>
+
+            Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS.
+            <https://webkit.org/b/167387>
+            <rdar://problem/29711409>
+
+            Reviewed by Antti Koivisto.
+
+            Add a new mechanism for overriding the max thread QoS level globally:
+
+                void setGlobalMaxQOSClass(qos_class_t)
+                qos_class_t adjustedQOSClass(qos_class_t)
+
+            The QoS cap applies to all newly created threads, threads that try to override
+            their QoS class manually, and also passed down to bmalloc.
+
+            * wtf/Threading.cpp:
+            (WTF::setCurrentThreadIsUserInteractive):
+            (WTF::setCurrentThreadIsUserInitiated):
+            (WTF::setGlobalMaxQOSClass):
+            (WTF::adjustedQOSClass):
+            * wtf/Threading.h:
+            * wtf/ThreadingPthreads.cpp:
+            (WTF::createThreadInternal):
+            * wtf/cocoa/WorkQueueCocoa.cpp:
+            (WTF::dispatchQOSClass):
+
 2017-01-27  Matthew Hanson  <matthew_han...@apple.com>
 
         Merge r211237. rdar://problem/30179506

Modified: branches/safari-603-branch/Source/WTF/wtf/Threading.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WTF/wtf/Threading.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WTF/wtf/Threading.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -30,6 +30,10 @@
 #include <cmath>
 #include <cstring>
 
+#if HAVE(QOS_CLASSES)
+#include <bmalloc/bmalloc.h>
+#endif
+
 namespace WTF {
 
 struct NewThreadContext {
@@ -89,7 +93,7 @@
 #if HAVE(QOS_CLASSES)
     ASSERT(relativePriority <= 0);
     ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
-    pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, relativePriority);
+    pthread_set_qos_class_self_np(adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE), relativePriority);
 #else
     UNUSED_PARAM(relativePriority);
 #endif
@@ -100,10 +104,27 @@
 #if HAVE(QOS_CLASSES)
     ASSERT(relativePriority <= 0);
     ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
-    pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, relativePriority);
+    pthread_set_qos_class_self_np(adjustedQOSClass(QOS_CLASS_USER_INITIATED), relativePriority);
 #else
     UNUSED_PARAM(relativePriority);
 #endif
 }
 
+#if HAVE(QOS_CLASSES)
+static qos_class_t globalMaxQOSclass { QOS_CLASS_UNSPECIFIED };
+
+void setGlobalMaxQOSClass(qos_class_t maxClass)
+{
+    bmalloc::api::setScavengerThreadQOSClass(maxClass);
+    globalMaxQOSclass = maxClass;
+}
+
+qos_class_t adjustedQOSClass(qos_class_t originalClass)
+{
+    if (globalMaxQOSclass != QOS_CLASS_UNSPECIFIED)
+        return std::min(originalClass, globalMaxQOSclass);
+    return originalClass;
+}
+#endif
+
 } // namespace WTF

Modified: branches/safari-603-branch/Source/WTF/wtf/Threading.h (211713 => 211714)


--- branches/safari-603-branch/Source/WTF/wtf/Threading.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WTF/wtf/Threading.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -77,6 +77,11 @@
 // Helpful for platforms where the thread name must be set from within the thread.
 void initializeCurrentThreadInternal(const char* threadName);
 
+#if HAVE(QOS_CLASSES)
+WTF_EXPORT_PRIVATE void setGlobalMaxQOSClass(qos_class_t);
+WTF_EXPORT_PRIVATE qos_class_t adjustedQOSClass(qos_class_t);
+#endif
+
 } // namespace WTF
 
 using WTF::ThreadIdentifier;
@@ -86,4 +91,9 @@
 using WTF::detachThread;
 using WTF::waitForThreadCompletion;
 
+#if HAVE(QOS_CLASSES)
+using WTF::setGlobalMaxQOSClass;
+using WTF::adjustedQOSClass;
+#endif
+
 #endif // Threading_h

Modified: branches/safari-603-branch/Source/WTF/wtf/ThreadingPthreads.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WTF/wtf/ThreadingPthreads.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WTF/wtf/ThreadingPthreads.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -172,7 +172,7 @@
     pthread_attr_t attr;
     pthread_attr_init(&attr);
 #if HAVE(QOS_CLASSES)
-    pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INITIATED, 0);
+    pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0);
 #endif
     int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get());
     pthread_attr_destroy(&attr);

Modified: branches/safari-603-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -49,15 +49,15 @@
 {
     switch (qos) {
     case WorkQueue::QOS::UserInteractive:
-        return QOS_CLASS_USER_INTERACTIVE;
+        return adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE);
     case WorkQueue::QOS::UserInitiated:
-        return QOS_CLASS_USER_INITIATED;
+        return adjustedQOSClass(QOS_CLASS_USER_INITIATED);
     case WorkQueue::QOS::Default:
-        return QOS_CLASS_DEFAULT;
+        return adjustedQOSClass(QOS_CLASS_DEFAULT);
     case WorkQueue::QOS::Utility:
-        return QOS_CLASS_UTILITY;
+        return adjustedQOSClass(QOS_CLASS_UTILITY);
     case WorkQueue::QOS::Background:
-        return QOS_CLASS_BACKGROUND;
+        return adjustedQOSClass(QOS_CLASS_BACKGROUND);
     }
 }
 #else

Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-02-06 06:17:50 UTC (rev 211714)
@@ -1,5 +1,49 @@
 2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r211482. rdar://problem/29711409
+
+    2017-02-01  Andreas Kling  <akl...@apple.com>
+
+            Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS.
+            <https://webkit.org/b/167387>
+            <rdar://problem/29711409>
+
+            Reviewed by Antti Koivisto.
+
+            Remove the old ProcessThrottlerClient implementation of alwaysRunsAtBackgroundPriority
+            and replace it with WTF::setGlobalMaxQOSClass().
+
+            If the setting is enabled, it's passed over to each WK2 child process along with its
+            bootstrap parameter, and we notify WTF in XPCServiceInitializer(), before anything
+            too threading related happens.
+
+            * Platform/IPC/Connection.cpp:
+            (IPC::Connection::processIncomingMessage):
+            * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+            (WebKit::XPCServiceInitializer):
+            * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+            (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
+            * UIProcess/API/APIProcessPoolConfiguration.h:
+            * UIProcess/ChildProcessProxy.cpp:
+            (WebKit::ChildProcessProxy::ChildProcessProxy):
+            (WebKit::ChildProcessProxy::getLaunchOptions):
+            * UIProcess/ChildProcessProxy.h:
+            * UIProcess/Databases/DatabaseProcessProxy.cpp:
+            (WebKit::DatabaseProcessProxy::DatabaseProcessProxy):
+            * UIProcess/Network/NetworkProcessProxy.cpp:
+            (WebKit::NetworkProcessProxy::NetworkProcessProxy):
+            (WebKit::NetworkProcessProxy::alwaysRunsAtBackgroundPriority): Deleted.
+            * UIProcess/Network/NetworkProcessProxy.h:
+            * UIProcess/ProcessThrottler.cpp:
+            (WebKit::ProcessThrottler::assertionState):
+            * UIProcess/ProcessThrottlerClient.h:
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::WebProcessProxy):
+            (WebKit::WebProcessProxy::alwaysRunsAtBackgroundPriority): Deleted.
+            * UIProcess/WebProcessProxy.h:
+
+2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211569. rdar://problem/30229990
 
     2017-02-02  Chris Dumez  <cdu...@apple.com>

Modified: branches/safari-603-branch/Source/WebKit2/Platform/IPC/Connection.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/Platform/IPC/Connection.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/Platform/IPC/Connection.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -671,7 +671,7 @@
 
 #if HAVE(QOS_CLASSES)
     if (message->isSyncMessage() && m_shouldBoostMainThreadOnSyncMessage) {
-        pthread_override_t override = pthread_override_qos_class_start_np(m_mainThread, QOS_CLASS_USER_INTERACTIVE, 0);
+        pthread_override_t override = pthread_override_qos_class_start_np(m_mainThread, adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE), 0);
         message->setQOSClassOverride(override);
     }
 #endif

Modified: branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -101,6 +101,11 @@
     voucher_replace_default_voucher();
 #endif
 
+#if HAVE(QOS_CLASSES)
+    if (parameters.extraInitializationData.contains(ASCIILiteral("always-runs-at-background-priority")))
+        setGlobalMaxQOSClass(QOS_CLASS_UTILITY);
+#endif
+
     XPCServiceType::singleton().initialize(parameters);
 }
 

Modified: branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm	2017-02-06 06:17:50 UTC (rev 211714)
@@ -103,6 +103,10 @@
             extraInitializationData.add(ASCIILiteral("user-directory-suffix"), userDirectorySuffix);
     }
 
+    String alwaysRunsAtBackgroundPriority = xpc_dictionary_get_string(extraDataInitializationDataObject, "always-runs-at-background-priority");
+    if (!alwaysRunsAtBackgroundPriority.isEmpty())
+        extraInitializationData.add(ASCIILiteral("always-runs-at-background-priority"), alwaysRunsAtBackgroundPriority);
+
     return true;
 }
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -31,7 +31,8 @@
 
 namespace WebKit {
 
-ChildProcessProxy::ChildProcessProxy()
+ChildProcessProxy::ChildProcessProxy(bool alwaysRunsAtBackgroundPriority)
+    : m_alwaysRunsAtBackgroundPriority(alwaysRunsAtBackgroundPriority)
 {
 }
 
@@ -51,6 +52,9 @@
     if (const char* userDirectorySuffix = getenv("DIRHELPER_USER_DIR_SUFFIX"))
         launchOptions.extraInitializationData.add(ASCIILiteral("user-directory-suffix"), userDirectorySuffix);
 
+    if (m_alwaysRunsAtBackgroundPriority)
+        launchOptions.extraInitializationData.add(ASCIILiteral("always-runs-at-background-priority"), "true");
+
 #if ENABLE(DEVELOPER_MODE) && (PLATFORM(GTK) || PLATFORM(EFL))
     const char* varname;
     switch (launchOptions.processType) {

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.h (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -36,8 +36,10 @@
 class ChildProcessProxy : ProcessLauncher::Client, public IPC::Connection::Client, public ThreadSafeRefCounted<ChildProcessProxy> {
     WTF_MAKE_NONCOPYABLE(ChildProcessProxy);
 
+protected:
+    explicit ChildProcessProxy(bool alwaysRunsAtBackgroundPriority = false);
+
 public:
-    ChildProcessProxy();
     virtual ~ChildProcessProxy();
 
     void connect();
@@ -93,6 +95,7 @@
     RefPtr<ProcessLauncher> m_processLauncher;
     RefPtr<IPC::Connection> m_connection;
     IPC::MessageReceiverMap m_messageReceiverMap;
+    bool m_alwaysRunsAtBackgroundPriority { false };
 };
 
 template<typename T>

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -52,7 +52,8 @@
 }
 
 DatabaseProcessProxy::DatabaseProcessProxy(WebProcessPool* processPool)
-    : m_processPool(processPool)
+    : ChildProcessProxy(processPool->alwaysRunsAtBackgroundPriority())
+    , m_processPool(processPool)
     , m_numPendingConnectionRequests(0)
 {
     connect();

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -65,7 +65,8 @@
 }
 
 NetworkProcessProxy::NetworkProcessProxy(WebProcessPool& processPool)
-    : m_processPool(processPool)
+    : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
+    , m_processPool(processPool)
     , m_numPendingConnectionRequests(0)
     , m_customProtocolManagerProxy(this, processPool)
     , m_throttler(*this)
@@ -387,11 +388,6 @@
         send(Messages::NetworkProcess::ProcessDidResume(), 0);
 }
 
-bool NetworkProcessProxy::alwaysRunsAtBackgroundPriority()
-{
-    return m_processPool.alwaysRunsAtBackgroundPriority();
-}
-
 void NetworkProcessProxy::processReadyToSuspend()
 {
     m_throttler.processReadyToSuspend();

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -92,7 +92,6 @@
     void sendPrepareToSuspend() override;
     void sendCancelPrepareToSuspend() override;
     void sendProcessDidResume() override;
-    bool alwaysRunsAtBackgroundPriority() override;
     void didSetAssertionState(AssertionState) override;
 
     // IPC::Connection::Client

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottler.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottler.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottler.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -47,7 +47,7 @@
     ASSERT(!m_suspendTimer.isActive());
     
     if (m_foregroundCounter.value())
-        return m_process.alwaysRunsAtBackgroundPriority() ? AssertionState::Background : AssertionState::Foreground;
+        return AssertionState::Foreground;
     if (m_backgroundCounter.value())
         return AssertionState::Background;
     return AssertionState::Suspended;

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottlerClient.h (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottlerClient.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottlerClient.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -38,7 +38,6 @@
     virtual void sendPrepareToSuspend() = 0;
     virtual void sendCancelPrepareToSuspend() = 0;
     virtual void sendProcessDidResume() = 0;
-    virtual bool alwaysRunsAtBackgroundPriority() = 0;
     virtual void didSetAssertionState(AssertionState) = 0;
 };
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -94,7 +94,8 @@
 }
 
 WebProcessProxy::WebProcessProxy(WebProcessPool& processPool)
-    : m_responsivenessTimer(*this)
+    : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
+    , m_responsivenessTimer(*this)
     , m_processPool(processPool)
     , m_mayHaveUniversalFileReadSandboxExtension(false)
     , m_numberOfTimesSuddenTerminationWasDisabled(0)
@@ -923,11 +924,6 @@
         send(Messages::WebProcess::ProcessDidResume(), 0);
 }
 
-bool WebProcessProxy::alwaysRunsAtBackgroundPriority()
-{
-    return m_processPool->alwaysRunsAtBackgroundPriority();
-}
-
 void WebProcessProxy::processReadyToSuspend()
 {
     m_throttler.processReadyToSuspend();

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.h (211713 => 211714)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -207,7 +207,6 @@
     void sendPrepareToSuspend() override;
     void sendCancelPrepareToSuspend() override;
     void sendProcessDidResume() override;
-    bool alwaysRunsAtBackgroundPriority() override;
     void didSetAssertionState(AssertionState) override;
 
     // ProcessLauncher::Client

Modified: branches/safari-603-branch/Source/bmalloc/ChangeLog (211713 => 211714)


--- branches/safari-603-branch/Source/bmalloc/ChangeLog	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/bmalloc/ChangeLog	2017-02-06 06:17:50 UTC (rev 211714)
@@ -1,3 +1,27 @@
+2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
+
+        Merge r211482. rdar://problem/29711409
+
+    2017-02-01  Andreas Kling  <akl...@apple.com>
+
+            Implement the alwaysRunsAtBackgroundPriority WK2 setting using thread QoS.
+            <https://webkit.org/b/167387>
+            <rdar://problem/29711409>
+
+            Reviewed by Antti Koivisto.
+
+            Support changing the QoS level of the scavenger thread asynchronously through
+            a request variable. This is not the most elegant thing in the world, but since
+            threads are only allowed to change their own QoS class, our options are limited.
+
+            * bmalloc/Heap.cpp:
+            (bmalloc::Heap::concurrentScavenge):
+            * bmalloc/Heap.h:
+            (bmalloc::Heap::takeRequestedScavengerThreadQOSClass):
+            (bmalloc::Heap::setScavengerThreadQOSClass):
+            * bmalloc/bmalloc.h:
+            (bmalloc::api::setScavengerThreadQOSClass):
+
 2016-12-15  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Sort Xcode project files

Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.cpp (211713 => 211714)


--- branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.cpp	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.cpp	2017-02-06 06:17:50 UTC (rev 211714)
@@ -104,6 +104,12 @@
 void Heap::concurrentScavenge()
 {
     std::unique_lock<StaticMutex> lock(PerProcess<Heap>::mutex());
+
+#if BOS(DARWIN)
+    if (auto requestedQOSClass = PerProcess<Heap>::getFastCase()->takeRequestedScavengerThreadQOSClass())
+        pthread_set_qos_class_self_np(requestedQOSClass, 0);
+#endif
+
     scavenge(lock, scavengeSleepDuration);
 }
 

Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.h (211713 => 211714)


--- branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -67,6 +67,11 @@
 
     void scavenge(std::unique_lock<StaticMutex>&, std::chrono::milliseconds sleepDuration);
 
+#if BOS(DARWIN)
+    qos_class_t takeRequestedScavengerThreadQOSClass() { return std::exchange(m_requestedScavengerThreadQOSClass, QOS_CLASS_UNSPECIFIED); }
+    void setScavengerThreadQOSClass(qos_class_t overrideClass) { m_requestedScavengerThreadQOSClass = overrideClass; }
+#endif
+
 private:
     struct LargeObjectHash {
         static unsigned hash(void* key)
@@ -118,6 +123,10 @@
     Environment m_environment;
 
     VMHeap m_vmHeap;
+
+#if BOS(DARWIN)
+    qos_class_t m_requestedScavengerThreadQOSClass { QOS_CLASS_UNSPECIFIED };
+#endif
 };
 
 inline void Heap::allocateSmallBumpRanges(

Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/bmalloc.h (211713 => 211714)


--- branches/safari-603-branch/Source/bmalloc/bmalloc/bmalloc.h	2017-02-06 06:17:42 UTC (rev 211713)
+++ branches/safari-603-branch/Source/bmalloc/bmalloc/bmalloc.h	2017-02-06 06:17:50 UTC (rev 211714)
@@ -85,5 +85,13 @@
     return PerProcess<Heap>::getFastCase()->environment().isBmallocEnabled();
 }
 
+#if BOS(DARWIN)
+inline void setScavengerThreadQOSClass(qos_class_t overrideClass)
+{
+    std::unique_lock<StaticMutex> lock(PerProcess<Heap>::mutex());
+    PerProcess<Heap>::getFastCase()->setScavengerThreadQOSClass(overrideClass);
+}
+#endif
+
 } // namespace api
 } // namespace bmalloc
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to