Diff
Modified: trunk/Source/WebCore/ChangeLog (167852 => 167853)
--- trunk/Source/WebCore/ChangeLog 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebCore/ChangeLog 2014-04-27 11:53:43 UTC (rev 167853)
@@ -1,3 +1,12 @@
+2014-04-27 Antti Koivisto <[email protected]>
+
+ Coalesce responses on network process side
+ https://bugs.webkit.org/show_bug.cgi?id=132229
+
+ Reviewed by Andreas Kling.
+
+ * WebCore.exp.in:
+
2014-04-27 David Kilzer <[email protected]>
Roll out changes not part of the patch reviewed for Bug 132089
Modified: trunk/Source/WebCore/WebCore.exp.in (167852 => 167853)
--- trunk/Source/WebCore/WebCore.exp.in 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-04-27 11:53:43 UTC (rev 167853)
@@ -233,6 +233,7 @@
__ZN7WebCore12SharedBuffer12createNSDataEv
__ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE
__ZN7WebCore12SharedBuffer6appendEPKcj
+__ZN7WebCore12SharedBuffer6appendEPS0_
__ZN7WebCore12SharedBufferC1EPKcj
__ZN7WebCore12SharedBufferC1EPKhj
__ZN7WebCore12SharedBufferC1Ev
Modified: trunk/Source/WebKit2/ChangeLog (167852 => 167853)
--- trunk/Source/WebKit2/ChangeLog 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/ChangeLog 2014-04-27 11:53:43 UTC (rev 167853)
@@ -1,3 +1,34 @@
+2014-04-27 Antti Koivisto <[email protected]>
+
+ Coalesce responses on network process side
+ https://bugs.webkit.org/show_bug.cgi?id=132229
+
+ Reviewed by Andreas Kling.
+
+ To reduce IPC we should coalesce response data in the network process and send it over with single IPC call.
+
+ * NetworkProcess/AsynchronousNetworkLoaderClient.cpp:
+ (WebKit::AsynchronousNetworkLoaderClient::AsynchronousNetworkLoaderClient):
+ (WebKit::AsynchronousNetworkLoaderClient::didReceiveResponse):
+ (WebKit::AsynchronousNetworkLoaderClient::didReceiveBuffer):
+ (WebKit::AsynchronousNetworkLoaderClient::didFinishLoading):
+ (WebKit::AsynchronousNetworkLoaderClient::didFail):
+ (WebKit::AsynchronousNetworkLoaderClient::dispatchPartialCoalescedResponse):
+ (WebKit::AsynchronousNetworkLoaderClient::clearCoalescedResponse):
+ (WebKit::AsynchronousNetworkLoaderClient::responseCoalesceTimerFired):
+
+ Coalesce the response. Completed response is sent on didFinishLoading. If the coalesce timer fires
+ before that the data accumulated so far is dispatched.
+
+ * NetworkProcess/AsynchronousNetworkLoaderClient.h:
+ * NetworkProcess/NetworkResourceLoader.h:
+ * WebProcess/Network/WebResourceLoader.cpp:
+ (WebKit::WebResourceLoader::didReceiveCompleteResponse):
+ * WebProcess/Network/WebResourceLoader.h:
+ * WebProcess/Network/WebResourceLoader.messages.in:
+
+ Add a new message type that covers didReceiveResponse, didReceiveBuffer and didFinishLoading in a single message.
+
2014-04-26 Tim Horton <[email protected]>
REGRESSION (r167775): Safari crashes in ViewSnapshotStore::pruneSnapshots after loading 20 pages
Modified: trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.cpp (167852 => 167853)
--- trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.cpp 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.cpp 2014-04-27 11:53:43 UTC (rev 167853)
@@ -42,6 +42,9 @@
namespace WebKit {
AsynchronousNetworkLoaderClient::AsynchronousNetworkLoaderClient()
+ : m_responseCoalescingTimer(RunLoop::main(), this, &AsynchronousNetworkLoaderClient::responseCoalescingTimerFired)
+ , m_coalescingLoader(nullptr)
+ , m_coalescingResponseEncodedDataLength(0)
{
}
@@ -63,6 +66,17 @@
void AsynchronousNetworkLoaderClient::didReceiveResponse(NetworkResourceLoader* loader, const ResourceResponse& response)
{
+ if (!loader->isLoadingMainResource()) {
+ ASSERT(!m_coalescingLoader);
+ m_coalescingResponse = response;
+ m_coalescingLoader = loader;
+
+ // FIXME: Some resources can only be used when completely loaded. We should always delay those until completion.
+ static const double responseCoalescingTime = 0.1;
+ m_responseCoalescingTimer.startOneShot(responseCoalescingTime);
+ return;
+ }
+
loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(response, CertificateInfo(response), loader->isLoadingMainResource()));
}
@@ -72,6 +86,12 @@
ShareableResource::Handle shareableResourceHandle;
NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(shareableResourceHandle, buffer);
if (!shareableResourceHandle.isNull()) {
+ if (m_responseCoalescingTimer.isActive()) {
+ ASSERT(!m_coalescingResponse.isNull());
+ ASSERT(!m_coalescingResponseData);
+ loader->send(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(m_coalescingResponse, CertificateInfo(m_coalescingResponse), false));
+ clearCoalescedResponse();
+ }
// Since we're delivering this resource by ourselves all at once and don't need anymore data or callbacks from the network layer, abort the loader.
loader->abort();
loader->send(Messages::WebResourceLoader::DidReceiveResource(shareableResourceHandle, currentTime()));
@@ -79,6 +99,17 @@
}
#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ if (m_responseCoalescingTimer.isActive()) {
+ ASSERT(m_coalescingLoader == loader);
+ ASSERT(!m_coalescingResponse.isNull());
+ if (m_coalescingResponseData)
+ m_coalescingResponseData->append(buffer);
+ else
+ m_coalescingResponseData = buffer;
+ m_coalescingResponseEncodedDataLength += encodedDataLength;
+ return;
+ }
+
IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength));
}
@@ -90,14 +121,58 @@
void AsynchronousNetworkLoaderClient::didFinishLoading(NetworkResourceLoader* loader, double finishTime)
{
+ if (m_responseCoalescingTimer.isActive()) {
+ ASSERT(!m_coalescingResponse.isNull());
+ IPC::DataReference dataReference;
+ if (m_coalescingResponseData)
+ dataReference = IPC::DataReference(reinterpret_cast<const uint8_t*>(m_coalescingResponseData->data()), m_coalescingResponseData->size());
+
+ loader->send(Messages::WebResourceLoader::DidReceiveCompleteResponse(m_coalescingResponse, CertificateInfo(m_coalescingResponse), dataReference, m_coalescingResponseEncodedDataLength, finishTime));
+ clearCoalescedResponse();
+ return;
+ }
+
loader->send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime));
}
void AsynchronousNetworkLoaderClient::didFail(NetworkResourceLoader* loader, const ResourceError& error)
{
+ if (m_responseCoalescingTimer.isActive())
+ dispatchPartialCoalescedResponse(loader);
+
loader->send(Messages::WebResourceLoader::DidFailResourceLoad(error));
}
+void AsynchronousNetworkLoaderClient::dispatchPartialCoalescedResponse(NetworkResourceLoader* loader)
+{
+ ASSERT(m_coalescingLoader == loader);
+ ASSERT(!m_coalescingResponse.isNull());
+ loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(m_coalescingResponse, CertificateInfo(m_coalescingResponse), false));
+
+ if (m_coalescingResponseData) {
+ IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(m_coalescingResponseData->data()), m_coalescingResponseData->size());
+ loader->sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveData(dataReference, m_coalescingResponseEncodedDataLength));
+ }
+
+ clearCoalescedResponse();
+}
+
+void AsynchronousNetworkLoaderClient::clearCoalescedResponse()
+{
+ m_coalescingResponse = ResourceResponse();
+ m_coalescingLoader = nullptr;
+ m_coalescingResponseData = nullptr;
+ m_coalescingResponseEncodedDataLength = 0;
+ m_responseCoalescingTimer.stop();
+}
+
+void AsynchronousNetworkLoaderClient::responseCoalescingTimerFired()
+{
+ ASSERT(m_coalescingLoader);
+ dispatchPartialCoalescedResponse(m_coalescingLoader);
+}
+
+
} // namespace WebKit
#endif // ENABLE(NETWORK_PROCESS)
Modified: trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.h (167852 => 167853)
--- trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.h 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/NetworkProcess/AsynchronousNetworkLoaderClient.h 2014-04-27 11:53:43 UTC (rev 167853)
@@ -28,6 +28,8 @@
#include "NetworkLoaderClient.h"
#include "ShareableResource.h"
+#include <WebCore/ResourceResponse.h>
+#include <wtf/RunLoop.h>
#if ENABLE(NETWORK_PROCESS)
@@ -47,6 +49,16 @@
virtual void didSendData(NetworkResourceLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
virtual void didFinishLoading(NetworkResourceLoader*, double finishTime) override;
virtual void didFail(NetworkResourceLoader*, const WebCore::ResourceError&) override;
+
+ void dispatchPartialCoalescedResponse(NetworkResourceLoader*);
+ void clearCoalescedResponse();
+ void responseCoalescingTimerFired();
+
+ RunLoop::Timer<AsynchronousNetworkLoaderClient> m_responseCoalescingTimer;
+ NetworkResourceLoader* m_coalescingLoader;
+ WebCore::ResourceResponse m_coalescingResponse;
+ RefPtr<WebCore::SharedBuffer> m_coalescingResponseData;
+ long long m_coalescingResponseEncodedDataLength;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (167852 => 167853)
--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h 2014-04-27 11:53:43 UTC (rev 167853)
@@ -35,6 +35,7 @@
#include <WebCore/ResourceHandleClient.h>
#include <WebCore/ResourceLoaderOptions.h>
#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
#include <WebCore/SessionID.h>
#include <wtf/MainThread.h>
#include <wtf/RunLoop.h>
Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (167852 => 167853)
--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp 2014-04-27 11:53:43 UTC (rev 167853)
@@ -130,6 +130,22 @@
send(Messages::NetworkResourceLoader::ContinueDidReceiveResponse());
}
+void WebResourceLoader::didReceiveCompleteResponse(const ResourceResponse& response, const CertificateInfo& certificateInfo, const IPC::DataReference& data, int64_t encodedDataLength, double finishTime)
+{
+ LOG(Network, "(WebProcess) WebResourceLoader::didReceiveCompleteResponse for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode());
+
+ Ref<WebResourceLoader> protect(*this);
+
+ didReceiveResponseWithCertificateInfo(response, certificateInfo, false);
+ if (!m_coreLoader)
+ return;
+ if (!data.isEmpty())
+ didReceiveData(data, encodedDataLength);
+ if (!m_coreLoader)
+ return;
+ didFinishResourceLoad(finishTime);
+}
+
void WebResourceLoader::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength)
{
LOG(Network, "(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'", (int)data.size(), m_coreLoader->url().string().utf8().data());
Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h (167852 => 167853)
--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h 2014-04-27 11:53:43 UTC (rev 167853)
@@ -81,6 +81,7 @@
void willSendRequest(const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
void didSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent);
void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const WebCore::CertificateInfo&, bool needsContinueDidReceiveResponseMessage);
+ void didReceiveCompleteResponse(const WebCore::ResourceResponse&, const WebCore::CertificateInfo&, const IPC::DataReference&, int64_t encodedDataLength, double finishTime);
void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength);
void didFinishResourceLoad(double finishTime);
void didFailResourceLoad(const WebCore::ResourceError&);
Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in (167852 => 167853)
--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in 2014-04-27 08:15:13 UTC (rev 167852)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in 2014-04-27 11:53:43 UTC (rev 167853)
@@ -30,6 +30,7 @@
WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent)
DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebCore::CertificateInfo certificateInfo, bool needsContinueDidReceiveResponseMessage)
+ DidReceiveCompleteResponse(WebCore::ResourceResponse response, WebCore::CertificateInfo certificateInfo, IPC::DataReference data, int64_t encodedDataLength, double finishTime)
DidReceiveData(IPC::DataReference data, int64_t encodedDataLength)
DidFinishResourceLoad(double finishTime)
DidFailResourceLoad(WebCore::ResourceError error)