Title: [182028] trunk/Source/WebKit2
- Revision
- 182028
- Author
- [email protected]
- Date
- 2015-03-26 15:20:45 -0700 (Thu, 26 Mar 2015)
Log Message
[Darwin] Boost the web process QoS level while handling a synchronous IPC message.
<https://webkit.org/b/142988>
<rdar://problem/20264346>
Reviewed by Antti Koivisto and Anders Carlsson.
Add a mechanism for IPC::Connection to boost the main thread for the duration
of processing a synchronous message.
This fixes an issue where the UI process would block on a synchronous request
to the web process that was being carried out at a lower QoS level.
* Platform/IPC/Connection.cpp:
(IPC::Connection::Connection): Save the main thread's pthread_t while we have
a chance to retreive it.
(IPC::Connection::processIncomingMessage): Optionally boost the main thread when
processing an incoming message with the IsSyncMessage flag set.
* Platform/IPC/Connection.h:
(IPC::Connection::setShouldBoostMainThreadOnSyncMessage): Added. When this mode is
enabled, Connection will give a temporary QoS override to the main thread when
receiving a synchronous message. Ownership of the override is handed to the
MessageDecoder, which resets the main thread QoS in its destructor.
* Platform/IPC/MessageDecoder.cpp:
(IPC::MessageDecoder::~MessageDecoder): Remove any QoS override owned by this message.
* Platform/IPC/MessageDecoder.h:
(IPC::MessageDecoder::setQOSClassOverride): Added. Takes ownership of a QoS override
to make sure it stays in effect until this message has been dispatched.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeConnection): Set up main thread QoS boosting for the
web process's connection to the UI process.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (182027 => 182028)
--- trunk/Source/WebKit2/ChangeLog 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-26 22:20:45 UTC (rev 182028)
@@ -1,3 +1,41 @@
+2015-03-26 Andreas Kling <[email protected]>
+
+ [Darwin] Boost the web process QoS level while handling a synchronous IPC message.
+ <https://webkit.org/b/142988>
+ <rdar://problem/20264346>
+
+ Reviewed by Antti Koivisto and Anders Carlsson.
+
+ Add a mechanism for IPC::Connection to boost the main thread for the duration
+ of processing a synchronous message.
+
+ This fixes an issue where the UI process would block on a synchronous request
+ to the web process that was being carried out at a lower QoS level.
+
+ * Platform/IPC/Connection.cpp:
+ (IPC::Connection::Connection): Save the main thread's pthread_t while we have
+ a chance to retreive it.
+
+ (IPC::Connection::processIncomingMessage): Optionally boost the main thread when
+ processing an incoming message with the IsSyncMessage flag set.
+
+ * Platform/IPC/Connection.h:
+ (IPC::Connection::setShouldBoostMainThreadOnSyncMessage): Added. When this mode is
+ enabled, Connection will give a temporary QoS override to the main thread when
+ receiving a synchronous message. Ownership of the override is handed to the
+ MessageDecoder, which resets the main thread QoS in its destructor.
+
+ * Platform/IPC/MessageDecoder.cpp:
+ (IPC::MessageDecoder::~MessageDecoder): Remove any QoS override owned by this message.
+
+ * Platform/IPC/MessageDecoder.h:
+ (IPC::MessageDecoder::setQOSClassOverride): Added. Takes ownership of a QoS override
+ to make sure it stays in effect until this message has been dispatched.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeConnection): Set up main thread QoS boosting for the
+ web process's connection to the UI process.
+
2015-03-26 Ryosuke Niwa <[email protected]>
Cursor doesn't change back to pointer when leaving Mail
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.cpp (182027 => 182028)
--- trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.cpp 2015-03-26 22:20:45 UTC (rev 182028)
@@ -256,6 +256,11 @@
ASSERT(m_client);
platformInitialize(identifier);
+
+#if HAVE(QOS_CLASSES)
+ ASSERT(pthread_main_np());
+ m_mainThread = pthread_self();
+#endif
}
Connection::~Connection()
@@ -680,6 +685,13 @@
return;
}
+#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);
+ message->setQOSClassOverride(override);
+ }
+#endif
+
// Check if this is a sync message or if it's a message that should be dispatched even when waiting for
// a sync reply. If it is, and we're waiting for a sync reply this message needs to be dispatched.
// If we don't we'll end up with a deadlock where both sync message senders are stuck waiting for a reply.
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (182027 => 182028)
--- trunk/Source/WebKit2/Platform/IPC/Connection.h 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h 2015-03-26 22:20:45 UTC (rev 182028)
@@ -200,6 +200,10 @@
bool isValid() const { return m_client; }
+#if HAVE(QOS_CLASSES)
+ void setShouldBoostMainThreadOnSyncMessage(bool b) { m_shouldBoostMainThreadOnSyncMessage = b; }
+#endif
+
private:
Connection(Identifier, bool isServer, Client&, WTF::RunLoop& clientRunLoop);
void platformInitialize(Identifier);
@@ -304,6 +308,11 @@
typedef HashMap<uint64_t, SecondaryThreadPendingSyncReply*> SecondaryThreadPendingSyncReplyMap;
SecondaryThreadPendingSyncReplyMap m_secondaryThreadPendingSyncReplyMap;
+#if HAVE(QOS_CLASSES)
+ pthread_t m_mainThread { 0 };
+ bool m_shouldBoostMainThreadOnSyncMessage { false };
+#endif
+
#if OS(DARWIN)
// Called on the connection queue.
void receiveSourceEventHandler();
Modified: trunk/Source/WebKit2/Platform/IPC/MessageDecoder.cpp (182027 => 182028)
--- trunk/Source/WebKit2/Platform/IPC/MessageDecoder.cpp 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/Platform/IPC/MessageDecoder.cpp 2015-03-26 22:20:45 UTC (rev 182028)
@@ -39,6 +39,10 @@
MessageDecoder::~MessageDecoder()
{
+#if HAVE(QOS_CLASSES)
+ if (m_qosClassOverride)
+ pthread_override_qos_class_end_np(m_qosClassOverride);
+#endif
}
MessageDecoder::MessageDecoder(const DataReference& buffer, Vector<Attachment> attachments)
Modified: trunk/Source/WebKit2/Platform/IPC/MessageDecoder.h (182027 => 182028)
--- trunk/Source/WebKit2/Platform/IPC/MessageDecoder.h 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/Platform/IPC/MessageDecoder.h 2015-03-26 22:20:45 UTC (rev 182028)
@@ -34,6 +34,10 @@
#include <uuid/uuid.h>
#endif
+#if HAVE(QOS_CLASSES)
+#include <pthread/qos.h>
+#endif
+
namespace IPC {
class DataReference;
@@ -55,6 +59,10 @@
void setImportanceAssertion(std::unique_ptr<ImportanceAssertion>);
#endif
+#if HAVE(QOS_CLASSES)
+ void setQOSClassOverride(pthread_override_t override) { m_qosClassOverride = override; }
+#endif
+
#if HAVE(DTRACE)
void setMessageProcessingToken(std::unique_ptr<MessageRecorder::MessageProcessingToken> token) { m_processingToken = WTF::move(token); }
@@ -76,6 +84,10 @@
#if PLATFORM(MAC)
std::unique_ptr<ImportanceAssertion> m_importanceAssertion;
#endif
+
+#if HAVE(QOS_CLASSES)
+ pthread_override_t m_qosClassOverride { nullptr };
+#endif
};
} // namespace IPC
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (182027 => 182028)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2015-03-26 22:09:35 UTC (rev 182027)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2015-03-26 22:20:45 UTC (rev 182028)
@@ -223,6 +223,10 @@
connection->setShouldExitOnSyncMessageSendFailure(true);
+#if HAVE(QOS_CLASSES)
+ connection->setShouldBoostMainThreadOnSyncMessage(true);
+#endif
+
m_eventDispatcher->initializeConnection(connection);
#if PLATFORM(IOS)
m_viewUpdateDispatcher->initializeConnection(connection);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes