Title: [186756] branches/safari-601.1-branch/Source

Diff

Modified: branches/safari-601.1-branch/Source/WebCore/ChangeLog (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebCore/ChangeLog	2015-07-13 06:54:36 UTC (rev 186756)
@@ -1,5 +1,23 @@
 2015-07-12  Babak Shafiei  <bshaf...@apple.com>
 
+        Merge r186707.
+
+    2015-07-10  Chris Dumez  <cdu...@apple.com>
+
+            [WK2] Diagnostic logging messages are causing too much IPC
+            https://bugs.webkit.org/show_bug.cgi?id=146873
+            <rdar://problem/21779205>
+
+            Reviewed by Ryosuke Niwa.
+
+            Move shouldLogAfterSampling() utility function to DiagnosticLoggingClient
+            so it can be easily reused.
+
+            * page/DiagnosticLoggingClient.h:
+            (WebCore::DiagnosticLoggingClient::shouldLogAfterSampling):
+
+2015-07-12  Babak Shafiei  <bshaf...@apple.com>
+
         Merge r186684.
 
     2015-07-10  Zalan Bujtas  <za...@apple.com>

Modified: branches/safari-601.1-branch/Source/WebCore/page/DiagnosticLoggingClient.h (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebCore/page/DiagnosticLoggingClient.h	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebCore/page/DiagnosticLoggingClient.h	2015-07-13 06:54:36 UTC (rev 186756)
@@ -28,6 +28,7 @@
 
 #include "DiagnosticLoggingResultType.h"
 #include <wtf/Forward.h>
+#include <wtf/RandomNumber.h>
 
 namespace WebCore {
 
@@ -41,10 +42,21 @@
 
     virtual void mainFrameDestroyed() = 0;
 
+    static bool shouldLogAfterSampling(ShouldSample);
+
 protected:
     virtual ~DiagnosticLoggingClient() { }
 };
 
+inline bool DiagnosticLoggingClient::shouldLogAfterSampling(ShouldSample shouldSample)
+{
+    if (shouldSample == ShouldSample::No)
+        return true;
+
+    static const double selectionProbability = 0.05;
+    return randomNumber() <= selectionProbability;
 }
 
+}
+
 #endif

Modified: branches/safari-601.1-branch/Source/WebKit2/ChangeLog (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/ChangeLog	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/ChangeLog	2015-07-13 06:54:36 UTC (rev 186756)
@@ -1,5 +1,46 @@
 2015-07-12  Babak Shafiei  <bshaf...@apple.com>
 
+        Merge r186707.
+
+    2015-07-10  Chris Dumez  <cdu...@apple.com>
+
+            [WK2] Diagnostic logging messages are causing too much IPC
+            https://bugs.webkit.org/show_bug.cgi?id=146873
+            <rdar://problem/21779205>
+
+            Reviewed by Ryosuke Niwa.
+
+            Diagnostic logging messages are causing too much IPC. To address the
+            problem, we now do the sampling of the senders' side (WebContent
+            process and Networking process) instead of the receiver's side
+            (UIProcess).
+
+            * NetworkProcess/NetworkProcess.cpp:
+            (WebKit::NetworkProcess::logDiagnosticMessage):
+            (WebKit::NetworkProcess::logDiagnosticMessageWithResult):
+            (WebKit::NetworkProcess::logDiagnosticMessageWithValue):
+            * UIProcess/Network/NetworkProcessProxy.cpp:
+            (WebKit::NetworkProcessProxy::logSampledDiagnosticMessage):
+            (WebKit::NetworkProcessProxy::logSampledDiagnosticMessageWithResult):
+            (WebKit::NetworkProcessProxy::logSampledDiagnosticMessageWithValue):
+            * UIProcess/Network/NetworkProcessProxy.h:
+            * UIProcess/Network/NetworkProcessProxy.messages.in:
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::logDiagnosticMessage):
+            (WebKit::WebPageProxy::logDiagnosticMessageWithResult):
+            (WebKit::WebPageProxy::logDiagnosticMessageWithValue):
+            (WebKit::WebPageProxy::logSampledDiagnosticMessage):
+            (WebKit::WebPageProxy::logSampledDiagnosticMessageWithResult):
+            (WebKit::WebPageProxy::logSampledDiagnosticMessageWithValue):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp:
+            (WebKit::WebDiagnosticLoggingClient::logDiagnosticMessage):
+            (WebKit::WebDiagnosticLoggingClient::logDiagnosticMessageWithResult):
+            (WebKit::WebDiagnosticLoggingClient::logDiagnosticMessageWithValue):
+
+2015-07-12  Babak Shafiei  <bshaf...@apple.com>
+
         Merge r186703.
 
     2015-07-10  Dean Jackson  <d...@apple.com>

Modified: branches/safari-601.1-branch/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2015-07-13 06:54:36 UTC (rev 186756)
@@ -46,6 +46,7 @@
 #include "WebCookieManager.h"
 #include "WebProcessPoolMessages.h"
 #include "WebsiteData.h"
+#include <WebCore/DiagnosticLoggingClient.h>
 #include <WebCore/Logging.h>
 #include <WebCore/PlatformCookieJar.h>
 #include <WebCore/ResourceRequest.h>
@@ -478,17 +479,26 @@
 
 void NetworkProcess::logDiagnosticMessage(uint64_t webPageID, const String& message, const String& description, WebCore::ShouldSample shouldSample)
 {
-    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessage(webPageID, message, description, shouldSample == ShouldSample::Yes), 0);
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample))
+        return;
+
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogSampledDiagnosticMessage(webPageID, message, description), 0);
 }
 
 void NetworkProcess::logDiagnosticMessageWithResult(uint64_t webPageID, const String& message, const String& description, WebCore::DiagnosticLoggingResultType result, WebCore::ShouldSample shouldSample)
 {
-    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessageWithResult(webPageID, message, description, result, shouldSample == ShouldSample::Yes), 0);
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample))
+        return;
+
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogSampledDiagnosticMessageWithResult(webPageID, message, description, result), 0);
 }
 
 void NetworkProcess::logDiagnosticMessageWithValue(uint64_t webPageID, const String& message, const String& description, const String& value, WebCore::ShouldSample shouldSample)
 {
-    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogDiagnosticMessageWithValue(webPageID, message, description, value, shouldSample == ShouldSample::Yes), 0);
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample))
+        return;
+
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::LogSampledDiagnosticMessageWithValue(webPageID, message, description, value), 0);
 }
 
 void NetworkProcess::terminate()

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2015-07-13 06:54:36 UTC (rev 186756)
@@ -285,7 +285,7 @@
 #endif
 }
 
-void NetworkProcessProxy::logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, bool shouldSample)
+void NetworkProcessProxy::logSampledDiagnosticMessage(uint64_t pageID, const String& message, const String& description)
 {
     WebPageProxy* page = WebProcessProxy::webPage(pageID);
     // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
@@ -293,10 +293,10 @@
     if (!page)
         return;
 
-    page->logDiagnosticMessage(message, description, shouldSample);
+    page->logSampledDiagnosticMessage(message, description);
 }
 
-void NetworkProcessProxy::logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, bool shouldSample)
+void NetworkProcessProxy::logSampledDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result)
 {
     WebPageProxy* page = WebProcessProxy::webPage(pageID);
     // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
@@ -304,10 +304,10 @@
     if (!page)
         return;
 
-    page->logDiagnosticMessageWithResult(message, description, result, shouldSample);
+    page->logSampledDiagnosticMessageWithResult(message, description, result);
 }
 
-void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value, bool shouldSample)
+void NetworkProcessProxy::logSampledDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value)
 {
     WebPageProxy* page = WebProcessProxy::webPage(pageID);
     // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
@@ -315,7 +315,7 @@
     if (!page)
         return;
 
-    page->logDiagnosticMessageWithValue(message, description, value, shouldSample);
+    page->logSampledDiagnosticMessageWithValue(message, description, value);
 }
 
 void NetworkProcessProxy::sendProcessWillSuspendImminently()

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2015-07-13 06:54:36 UTC (rev 186756)
@@ -109,9 +109,9 @@
     void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
     void didDeleteWebsiteData(uint64_t callbackID);
     void didDeleteWebsiteDataForOrigins(uint64_t callbackID);
-    void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, bool shouldSample);
-    void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, bool shouldSample);
-    void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value, bool shouldSample);
+    void logSampledDiagnosticMessage(uint64_t pageID, const String& message, const String& description);
+    void logSampledDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result);
+    void logSampledDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, const String& value);
 
     // ProcessLauncher::Client
     virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in	2015-07-13 06:54:36 UTC (rev 186756)
@@ -36,9 +36,9 @@
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
 
     # Diagnostic messages logging
-    LogDiagnosticMessage(uint64_t pageID, String message, String description, bool shouldSample)
-    LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, bool shouldSample)
-    LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, String value, bool shouldSample)
+    LogSampledDiagnosticMessage(uint64_t pageID, String message, String description)
+    LogSampledDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result)
+    LogSampledDiagnosticMessageWithValue(uint64_t pageID, String message, String description, String value)
 }
 
 #endif // ENABLE(NETWORK_PROCESS)

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2015-07-13 06:54:36 UTC (rev 186756)
@@ -101,6 +101,7 @@
 #include "WebUserContentControllerProxy.h"
 #include "WebsiteDataStore.h"
 #include <WebCore/BitmapImage.h>
+#include <WebCore/DiagnosticLoggingClient.h>
 #include <WebCore/DragController.h>
 #include <WebCore/DragData.h>
 #include <WebCore/FloatRect.h>
@@ -114,7 +115,6 @@
 #include <WebCore/WindowFeatures.h>
 #include <stdio.h>
 #include <wtf/NeverDestroyed.h>
-#include <wtf/RandomNumber.h>
 #include <wtf/text/StringView.h>
 
 #if ENABLE(ASYNC_SCROLLING)
@@ -4717,33 +4717,45 @@
 }
 #endif
 
-static bool shouldLogDiagnosticMessage(bool shouldSample)
+void WebPageProxy::logDiagnosticMessage(const String& message, const String& description, bool shouldSample)
 {
-    if (!shouldSample)
-        return true;
-    // Log 5% of messages when sampling.
-    static const double selectionProbability = 0.05;
-    return randomNumber() <= selectionProbability;
-}
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample ? ShouldSample::Yes : ShouldSample::No))
+        return;
 
-void WebPageProxy::logDiagnosticMessage(const String& message, const String& description, bool shouldSample)
-{
-    if (shouldLogDiagnosticMessage(shouldSample))
-        m_diagnosticLoggingClient->logDiagnosticMessage(this, message, description);
+    logSampledDiagnosticMessage(message, description);
 }
 
 void WebPageProxy::logDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result, bool shouldSample)
 {
-    if (shouldLogDiagnosticMessage(shouldSample))
-        m_diagnosticLoggingClient->logDiagnosticMessageWithResult(this, message, description, static_cast<WebCore::DiagnosticLoggingResultType>(result));
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample ? ShouldSample::Yes : ShouldSample::No))
+        return;
+
+    logSampledDiagnosticMessageWithResult(message, description, static_cast<WebCore::DiagnosticLoggingResultType>(result));
 }
 
 void WebPageProxy::logDiagnosticMessageWithValue(const String& message, const String& description, const String& value, bool shouldSample)
 {
-    if (shouldLogDiagnosticMessage(shouldSample))
-        m_diagnosticLoggingClient->logDiagnosticMessageWithValue(this, message, description, value);
+    if (!DiagnosticLoggingClient::shouldLogAfterSampling(shouldSample ? ShouldSample::Yes : ShouldSample::No))
+        return;
+
+    logSampledDiagnosticMessageWithValue(message, description, value);
 }
 
+void WebPageProxy::logSampledDiagnosticMessage(const String& message, const String& description)
+{
+    m_diagnosticLoggingClient->logDiagnosticMessage(this, message, description);
+}
+
+void WebPageProxy::logSampledDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result)
+{
+    m_diagnosticLoggingClient->logDiagnosticMessageWithResult(this, message, description, static_cast<WebCore::DiagnosticLoggingResultType>(result));
+}
+
+void WebPageProxy::logSampledDiagnosticMessageWithValue(const String& message, const String& description, const String& value)
+{
+    m_diagnosticLoggingClient->logDiagnosticMessageWithValue(this, message, description, value);
+}
+
 void WebPageProxy::rectForCharacterRangeCallback(const IntRect& rect, const EditingRange& actualRange, uint64_t callbackID)
 {
     MESSAGE_CHECK(actualRange.isValid());

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2015-07-13 06:54:36 UTC (rev 186756)
@@ -1060,6 +1060,9 @@
     void logDiagnosticMessage(const String& message, const String& description, bool shouldSample);
     void logDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result, bool shouldSample);
     void logDiagnosticMessageWithValue(const String& message, const String& description, const String& value, bool shouldSample);
+    void logSampledDiagnosticMessage(const String& message, const String& description);
+    void logSampledDiagnosticMessageWithResult(const String& message, const String& description, uint32_t result);
+    void logSampledDiagnosticMessageWithValue(const String& message, const String& description, const String& value);
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
     void addPlaybackTargetPickerClient(uint64_t);

Modified: branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2015-07-13 06:54:36 UTC (rev 186756)
@@ -226,9 +226,9 @@
     ExecuteUndoRedo(uint32_t action) -> (bool result)
 
     # Diagnostic messages logging
-    LogDiagnosticMessage(String message, String description, bool shouldSample)
-    LogDiagnosticMessageWithResult(String message, String description, uint32_t result, bool shouldSample)
-    LogDiagnosticMessageWithValue(String message, String description, String value, bool shouldSample)
+    LogSampledDiagnosticMessage(String message, String description)
+    LogSampledDiagnosticMessageWithResult(String message, String description, uint32_t result)
+    LogSampledDiagnosticMessageWithValue(String message, String description, String value)
 
     # Editor notifications
     EditorStateChanged(struct WebKit::EditorState editorState)

Modified: branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp (186755 => 186756)


--- branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp	2015-07-13 06:52:30 UTC (rev 186755)
+++ branches/safari-601.1-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebDiagnosticLoggingClient.cpp	2015-07-13 06:54:36 UTC (rev 186756)
@@ -43,32 +43,38 @@
 
 void WebDiagnosticLoggingClient::logDiagnosticMessage(const String& message, const String& description, WebCore::ShouldSample shouldSample)
 {
-    if (!m_page.corePage() || !m_page.corePage()->settings().diagnosticLoggingEnabled())
+    ASSERT(!m_page.corePage() || m_page.corePage()->settings().diagnosticLoggingEnabled());
+
+    if (!shouldLogAfterSampling(shouldSample))
         return;
 
     // FIXME: Remove this injected bundle API.
     m_page.injectedBundleDiagnosticLoggingClient().logDiagnosticMessage(&m_page, message, description);
-    m_page.send(Messages::WebPageProxy::LogDiagnosticMessage(message, description, shouldSample == WebCore::ShouldSample::Yes));
+    m_page.send(Messages::WebPageProxy::LogSampledDiagnosticMessage(message, description));
 }
 
 void WebDiagnosticLoggingClient::logDiagnosticMessageWithResult(const String& message, const String& description, WebCore::DiagnosticLoggingResultType result, WebCore::ShouldSample shouldSample)
 {
-    if (!m_page.corePage() || !m_page.corePage()->settings().diagnosticLoggingEnabled())
+    ASSERT(!m_page.corePage() || m_page.corePage()->settings().diagnosticLoggingEnabled());
+
+    if (!shouldLogAfterSampling(shouldSample))
         return;
 
     // FIXME: Remove this injected bundle API.
     m_page.injectedBundleDiagnosticLoggingClient().logDiagnosticMessageWithResult(&m_page, message, description, result);
-    m_page.send(Messages::WebPageProxy::LogDiagnosticMessageWithResult(message, description, result, shouldSample == WebCore::ShouldSample::Yes));
+    m_page.send(Messages::WebPageProxy::LogSampledDiagnosticMessageWithResult(message, description, result));
 }
 
 void WebDiagnosticLoggingClient::logDiagnosticMessageWithValue(const String& message, const String& description, const String& value, WebCore::ShouldSample shouldSample)
 {
-    if (!m_page.corePage() || !m_page.corePage()->settings().diagnosticLoggingEnabled())
+    ASSERT(!m_page.corePage() || m_page.corePage()->settings().diagnosticLoggingEnabled());
+
+    if (!shouldLogAfterSampling(shouldSample))
         return;
 
     // FIXME: Remove this injected bundle API.
     m_page.injectedBundleDiagnosticLoggingClient().logDiagnosticMessageWithValue(&m_page, message, description, value);
-    m_page.send(Messages::WebPageProxy::LogDiagnosticMessageWithValue(message, description, value, shouldSample == WebCore::ShouldSample::Yes));
+    m_page.send(Messages::WebPageProxy::LogSampledDiagnosticMessageWithValue(message, description, value));
 }
 
 void WebDiagnosticLoggingClient::mainFrameDestroyed()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to