<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211714] branches/safari-603-branch/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211714">211714</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2017-02-05 22:17:50 -0800 (Sun, 05 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/211482">r211482</a>. rdar://problem/29711409</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari603branchSourceWTFChangeLog">branches/safari-603-branch/Source/WTF/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWTFwtfThreadingcpp">branches/safari-603-branch/Source/WTF/wtf/Threading.cpp</a></li>
<li><a href="#branchessafari603branchSourceWTFwtfThreadingh">branches/safari-603-branch/Source/WTF/wtf/Threading.h</a></li>
<li><a href="#branchessafari603branchSourceWTFwtfThreadingPthreadscpp">branches/safari-603-branch/Source/WTF/wtf/ThreadingPthreads.cpp</a></li>
<li><a href="#branchessafari603branchSourceWTFwtfcocoaWorkQueueCocoacpp">branches/safari-603-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2ChangeLog">branches/safari-603-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWebKit2PlatformIPCConnectioncpp">branches/safari-603-branch/Source/WebKit2/Platform/IPC/Connection.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh">branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h</a></li>
<li><a href="#branchessafari603branchSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm">branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessChildProcessProxycpp">branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessChildProcessProxyh">branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.h</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessDatabasesDatabaseProcessProxycpp">branches/safari-603-branch/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessNetworkNetworkProcessProxycpp">branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessNetworkNetworkProcessProxyh">branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessProcessThrottlercpp">branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottler.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessProcessThrottlerClienth">branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottlerClient.h</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessWebProcessProxycpp">branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebKit2UIProcessWebProcessProxyh">branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.h</a></li>
<li><a href="#branchessafari603branchSourcebmallocChangeLog">branches/safari-603-branch/Source/bmalloc/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourcebmallocbmallocHeapcpp">branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.cpp</a></li>
<li><a href="#branchessafari603branchSourcebmallocbmallocHeaph">branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.h</a></li>
<li><a href="#branchessafari603branchSourcebmallocbmallocbmalloch">branches/safari-603-branch/Source/bmalloc/bmalloc/bmalloc.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari603branchSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WTF/ChangeLog (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2017-02-05 Matthew Hanson <matthew_hanson@apple.com>
+
+ Merge r211482. rdar://problem/29711409
+
+ 2017-02-01 Andreas Kling <akling@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):
+
</ins><span class="cx"> 2017-01-27 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r211237. rdar://problem/30179506
</span></span></pre></div>
<a id="branchessafari603branchSourceWTFwtfThreadingcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WTF/wtf/Threading.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -30,6 +30,10 @@
</span><span class="cx"> #include <cmath>
</span><span class="cx"> #include <cstring>
</span><span class="cx">
</span><ins>+#if HAVE(QOS_CLASSES)
+#include <bmalloc/bmalloc.h>
+#endif
+
</ins><span class="cx"> namespace WTF {
</span><span class="cx">
</span><span class="cx"> struct NewThreadContext {
</span><span class="lines">@@ -89,7 +93,7 @@
</span><span class="cx"> #if HAVE(QOS_CLASSES)
</span><span class="cx"> ASSERT(relativePriority <= 0);
</span><span class="cx"> ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
</span><del>- pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, relativePriority);
</del><ins>+ pthread_set_qos_class_self_np(adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE), relativePriority);
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(relativePriority);
</span><span class="cx"> #endif
</span><span class="lines">@@ -100,10 +104,27 @@
</span><span class="cx"> #if HAVE(QOS_CLASSES)
</span><span class="cx"> ASSERT(relativePriority <= 0);
</span><span class="cx"> ASSERT(relativePriority >= QOS_MIN_RELATIVE_PRIORITY);
</span><del>- pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, relativePriority);
</del><ins>+ pthread_set_qos_class_self_np(adjustedQOSClass(QOS_CLASS_USER_INITIATED), relativePriority);
</ins><span class="cx"> #else
</span><span class="cx"> UNUSED_PARAM(relativePriority);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#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
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="branchessafari603branchSourceWTFwtfThreadingh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WTF/wtf/Threading.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -77,6 +77,11 @@
</span><span class="cx"> // Helpful for platforms where the thread name must be set from within the thread.
</span><span class="cx"> void initializeCurrentThreadInternal(const char* threadName);
</span><span class="cx">
</span><ins>+#if HAVE(QOS_CLASSES)
+WTF_EXPORT_PRIVATE void setGlobalMaxQOSClass(qos_class_t);
+WTF_EXPORT_PRIVATE qos_class_t adjustedQOSClass(qos_class_t);
+#endif
+
</ins><span class="cx"> } // namespace WTF
</span><span class="cx">
</span><span class="cx"> using WTF::ThreadIdentifier;
</span><span class="lines">@@ -86,4 +91,9 @@
</span><span class="cx"> using WTF::detachThread;
</span><span class="cx"> using WTF::waitForThreadCompletion;
</span><span class="cx">
</span><ins>+#if HAVE(QOS_CLASSES)
+using WTF::setGlobalMaxQOSClass;
+using WTF::adjustedQOSClass;
+#endif
+
</ins><span class="cx"> #endif // Threading_h
</span></span></pre></div>
<a id="branchessafari603branchSourceWTFwtfThreadingPthreadscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WTF/wtf/ThreadingPthreads.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx"> pthread_attr_t attr;
</span><span class="cx"> pthread_attr_init(&attr);
</span><span class="cx"> #if HAVE(QOS_CLASSES)
</span><del>- pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INITIATED, 0);
</del><ins>+ pthread_attr_set_qos_class_np(&attr, adjustedQOSClass(QOS_CLASS_USER_INITIATED), 0);
</ins><span class="cx"> #endif
</span><span class="cx"> int error = pthread_create(&threadHandle, &attr, wtfThreadEntryPoint, invocation.get());
</span><span class="cx"> pthread_attr_destroy(&attr);
</span></span></pre></div>
<a id="branchessafari603branchSourceWTFwtfcocoaWorkQueueCocoacpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -49,15 +49,15 @@
</span><span class="cx"> {
</span><span class="cx"> switch (qos) {
</span><span class="cx"> case WorkQueue::QOS::UserInteractive:
</span><del>- return QOS_CLASS_USER_INTERACTIVE;
</del><ins>+ return adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE);
</ins><span class="cx"> case WorkQueue::QOS::UserInitiated:
</span><del>- return QOS_CLASS_USER_INITIATED;
</del><ins>+ return adjustedQOSClass(QOS_CLASS_USER_INITIATED);
</ins><span class="cx"> case WorkQueue::QOS::Default:
</span><del>- return QOS_CLASS_DEFAULT;
</del><ins>+ return adjustedQOSClass(QOS_CLASS_DEFAULT);
</ins><span class="cx"> case WorkQueue::QOS::Utility:
</span><del>- return QOS_CLASS_UTILITY;
</del><ins>+ return adjustedQOSClass(QOS_CLASS_UTILITY);
</ins><span class="cx"> case WorkQueue::QOS::Background:
</span><del>- return QOS_CLASS_BACKGROUND;
</del><ins>+ return adjustedQOSClass(QOS_CLASS_BACKGROUND);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> #else
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,49 @@
</span><span class="cx"> 2017-02-05 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r211482. rdar://problem/29711409
+
+ 2017-02-01 Andreas Kling <akling@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_hanson@apple.com>
+
</ins><span class="cx"> Merge r211569. rdar://problem/30229990
</span><span class="cx">
</span><span class="cx"> 2017-02-02 Chris Dumez <cdumez@apple.com>
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2PlatformIPCConnectioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/Platform/IPC/Connection.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -671,7 +671,7 @@
</span><span class="cx">
</span><span class="cx"> #if HAVE(QOS_CLASSES)
</span><span class="cx"> if (message->isSyncMessage() && m_shouldBoostMainThreadOnSyncMessage) {
</span><del>- pthread_override_t override = pthread_override_qos_class_start_np(m_mainThread, QOS_CLASS_USER_INTERACTIVE, 0);
</del><ins>+ pthread_override_t override = pthread_override_qos_class_start_np(m_mainThread, adjustedQOSClass(QOS_CLASS_USER_INTERACTIVE), 0);
</ins><span class="cx"> message->setQOSClassOverride(override);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -101,6 +101,11 @@
</span><span class="cx"> voucher_replace_default_voucher();
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if HAVE(QOS_CLASSES)
+ if (parameters.extraInitializationData.contains(ASCIILiteral("always-runs-at-background-priority")))
+ setGlobalMaxQOSClass(QOS_CLASS_UTILITY);
+#endif
+
</ins><span class="cx"> XPCServiceType::singleton().initialize(parameters);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -103,6 +103,10 @@
</span><span class="cx"> extraInitializationData.add(ASCIILiteral("user-directory-suffix"), userDirectorySuffix);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ String alwaysRunsAtBackgroundPriority = xpc_dictionary_get_string(extraDataInitializationDataObject, "always-runs-at-background-priority");
+ if (!alwaysRunsAtBackgroundPriority.isEmpty())
+ extraInitializationData.add(ASCIILiteral("always-runs-at-background-priority"), alwaysRunsAtBackgroundPriority);
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessChildProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -31,7 +31,8 @@
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><del>-ChildProcessProxy::ChildProcessProxy()
</del><ins>+ChildProcessProxy::ChildProcessProxy(bool alwaysRunsAtBackgroundPriority)
+ : m_alwaysRunsAtBackgroundPriority(alwaysRunsAtBackgroundPriority)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -51,6 +52,9 @@
</span><span class="cx"> if (const char* userDirectorySuffix = getenv("DIRHELPER_USER_DIR_SUFFIX"))
</span><span class="cx"> launchOptions.extraInitializationData.add(ASCIILiteral("user-directory-suffix"), userDirectorySuffix);
</span><span class="cx">
</span><ins>+ if (m_alwaysRunsAtBackgroundPriority)
+ launchOptions.extraInitializationData.add(ASCIILiteral("always-runs-at-background-priority"), "true");
+
</ins><span class="cx"> #if ENABLE(DEVELOPER_MODE) && (PLATFORM(GTK) || PLATFORM(EFL))
</span><span class="cx"> const char* varname;
</span><span class="cx"> switch (launchOptions.processType) {
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessChildProcessProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ChildProcessProxy.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -36,8 +36,10 @@
</span><span class="cx"> class ChildProcessProxy : ProcessLauncher::Client, public IPC::Connection::Client, public ThreadSafeRefCounted<ChildProcessProxy> {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(ChildProcessProxy);
</span><span class="cx">
</span><ins>+protected:
+ explicit ChildProcessProxy(bool alwaysRunsAtBackgroundPriority = false);
+
</ins><span class="cx"> public:
</span><del>- ChildProcessProxy();
</del><span class="cx"> virtual ~ChildProcessProxy();
</span><span class="cx">
</span><span class="cx"> void connect();
</span><span class="lines">@@ -93,6 +95,7 @@
</span><span class="cx"> RefPtr<ProcessLauncher> m_processLauncher;
</span><span class="cx"> RefPtr<IPC::Connection> m_connection;
</span><span class="cx"> IPC::MessageReceiverMap m_messageReceiverMap;
</span><ins>+ bool m_alwaysRunsAtBackgroundPriority { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> template<typename T>
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessDatabasesDatabaseProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -52,7 +52,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> DatabaseProcessProxy::DatabaseProcessProxy(WebProcessPool* processPool)
</span><del>- : m_processPool(processPool)
</del><ins>+ : ChildProcessProxy(processPool->alwaysRunsAtBackgroundPriority())
+ , m_processPool(processPool)
</ins><span class="cx"> , m_numPendingConnectionRequests(0)
</span><span class="cx"> {
</span><span class="cx"> connect();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessNetworkNetworkProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -65,7 +65,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> NetworkProcessProxy::NetworkProcessProxy(WebProcessPool& processPool)
</span><del>- : m_processPool(processPool)
</del><ins>+ : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
+ , m_processPool(processPool)
</ins><span class="cx"> , m_numPendingConnectionRequests(0)
</span><span class="cx"> , m_customProtocolManagerProxy(this, processPool)
</span><span class="cx"> , m_throttler(*this)
</span><span class="lines">@@ -387,11 +388,6 @@
</span><span class="cx"> send(Messages::NetworkProcess::ProcessDidResume(), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool NetworkProcessProxy::alwaysRunsAtBackgroundPriority()
-{
- return m_processPool.alwaysRunsAtBackgroundPriority();
-}
-
</del><span class="cx"> void NetworkProcessProxy::processReadyToSuspend()
</span><span class="cx"> {
</span><span class="cx"> m_throttler.processReadyToSuspend();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessNetworkNetworkProcessProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -92,7 +92,6 @@
</span><span class="cx"> void sendPrepareToSuspend() override;
</span><span class="cx"> void sendCancelPrepareToSuspend() override;
</span><span class="cx"> void sendProcessDidResume() override;
</span><del>- bool alwaysRunsAtBackgroundPriority() override;
</del><span class="cx"> void didSetAssertionState(AssertionState) override;
</span><span class="cx">
</span><span class="cx"> // IPC::Connection::Client
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessProcessThrottlercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottler.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> ASSERT(!m_suspendTimer.isActive());
</span><span class="cx">
</span><span class="cx"> if (m_foregroundCounter.value())
</span><del>- return m_process.alwaysRunsAtBackgroundPriority() ? AssertionState::Background : AssertionState::Foreground;
</del><ins>+ return AssertionState::Foreground;
</ins><span class="cx"> if (m_backgroundCounter.value())
</span><span class="cx"> return AssertionState::Background;
</span><span class="cx"> return AssertionState::Suspended;
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessProcessThrottlerClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ProcessThrottlerClient.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> virtual void sendPrepareToSuspend() = 0;
</span><span class="cx"> virtual void sendCancelPrepareToSuspend() = 0;
</span><span class="cx"> virtual void sendProcessDidResume() = 0;
</span><del>- virtual bool alwaysRunsAtBackgroundPriority() = 0;
</del><span class="cx"> virtual void didSetAssertionState(AssertionState) = 0;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -94,7 +94,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebProcessProxy::WebProcessProxy(WebProcessPool& processPool)
</span><del>- : m_responsivenessTimer(*this)
</del><ins>+ : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
+ , m_responsivenessTimer(*this)
</ins><span class="cx"> , m_processPool(processPool)
</span><span class="cx"> , m_mayHaveUniversalFileReadSandboxExtension(false)
</span><span class="cx"> , m_numberOfTimesSuddenTerminationWasDisabled(0)
</span><span class="lines">@@ -923,11 +924,6 @@
</span><span class="cx"> send(Messages::WebProcess::ProcessDidResume(), 0);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool WebProcessProxy::alwaysRunsAtBackgroundPriority()
-{
- return m_processPool->alwaysRunsAtBackgroundPriority();
-}
-
</del><span class="cx"> void WebProcessProxy::processReadyToSuspend()
</span><span class="cx"> {
</span><span class="cx"> m_throttler.processReadyToSuspend();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebProcessProxy.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -207,7 +207,6 @@
</span><span class="cx"> void sendPrepareToSuspend() override;
</span><span class="cx"> void sendCancelPrepareToSuspend() override;
</span><span class="cx"> void sendProcessDidResume() override;
</span><del>- bool alwaysRunsAtBackgroundPriority() override;
</del><span class="cx"> void didSetAssertionState(AssertionState) override;
</span><span class="cx">
</span><span class="cx"> // ProcessLauncher::Client
</span></span></pre></div>
<a id="branchessafari603branchSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/bmalloc/ChangeLog (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2017-02-05 Matthew Hanson <matthew_hanson@apple.com>
+
+ Merge r211482. rdar://problem/29711409
+
+ 2017-02-01 Andreas Kling <akling@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):
+
</ins><span class="cx"> 2016-12-15 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> Sort Xcode project files
</span></span></pre></div>
<a id="branchessafari603branchSourcebmallocbmallocHeapcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.cpp (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -104,6 +104,12 @@
</span><span class="cx"> void Heap::concurrentScavenge()
</span><span class="cx"> {
</span><span class="cx"> std::unique_lock<StaticMutex> lock(PerProcess<Heap>::mutex());
</span><ins>+
+#if BOS(DARWIN)
+ if (auto requestedQOSClass = PerProcess<Heap>::getFastCase()->takeRequestedScavengerThreadQOSClass())
+ pthread_set_qos_class_self_np(requestedQOSClass, 0);
+#endif
+
</ins><span class="cx"> scavenge(lock, scavengeSleepDuration);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari603branchSourcebmallocbmallocHeaph"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/Heap.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -67,6 +67,11 @@
</span><span class="cx">
</span><span class="cx"> void scavenge(std::unique_lock<StaticMutex>&, std::chrono::milliseconds sleepDuration);
</span><span class="cx">
</span><ins>+#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
+
</ins><span class="cx"> private:
</span><span class="cx"> struct LargeObjectHash {
</span><span class="cx"> static unsigned hash(void* key)
</span><span class="lines">@@ -118,6 +123,10 @@
</span><span class="cx"> Environment m_environment;
</span><span class="cx">
</span><span class="cx"> VMHeap m_vmHeap;
</span><ins>+
+#if BOS(DARWIN)
+ qos_class_t m_requestedScavengerThreadQOSClass { QOS_CLASS_UNSPECIFIED };
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline void Heap::allocateSmallBumpRanges(
</span></span></pre></div>
<a id="branchessafari603branchSourcebmallocbmallocbmalloch"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/bmalloc/bmalloc/bmalloc.h (211713 => 211714)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -85,5 +85,13 @@
</span><span class="cx"> return PerProcess<Heap>::getFastCase()->environment().isBmallocEnabled();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if BOS(DARWIN)
+inline void setScavengerThreadQOSClass(qos_class_t overrideClass)
+{
+ std::unique_lock<StaticMutex> lock(PerProcess<Heap>::mutex());
+ PerProcess<Heap>::getFastCase()->setScavengerThreadQOSClass(overrideClass);
+}
+#endif
+
</ins><span class="cx"> } // namespace api
</span><span class="cx"> } // namespace bmalloc
</span></span></pre>
</div>
</div>
</body>
</html>