<!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>[193756] trunk/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/193756">193756</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-12-08 09:39:46 -0800 (Tue, 08 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add diagnostic logging to measure speculative revalidation accuracy
https://bugs.webkit.org/show_bug.cgi?id=151953
&lt;rdar://problem/23092196&gt;

Reviewed by Darin Adler.

Source/WebCore:

Add diagnostic logging to measure speculative revalidation accuracy.

* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey):
(WebCore::DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey):
(WebCore::DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey):
(WebCore::DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey):
(WebCore::DiagnosticLoggingKeys::unknownEntryRequestKey):
(WebCore::DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey):
(WebCore::DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey):
* page/DiagnosticLoggingKeys.h:

Source/WebKit2:

We track the following:
1. Resources we knew about AND did not get requested
   A. We did not speculate (Good)
   B. We speculated but did not go to network (Bad)
   C. We speculated and went to network (Very bad)
2. Resources we did not know about (Neutral)
3. Resources we knew about AND got requested
   A. We did not speculate (Bad)
   B. We speculated but did not go to network (Good)
   C. We speculated and went to network (Very good)

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::retrieve):
* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::allSpeculativeLoadingDiagnosticMessages):
(WebKit::NetworkCache::printSpeculativeLoadingDiagnosticMessageCounts):
(WebKit::NetworkCache::logSpeculativeLoadingDiagnosticMessage):
(WebKit::NetworkCache::SpeculativeLoadManager::ExpiringEntry::ExpiringEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::PreloadedEntry::PreloadedEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::PreloadedEntry::wasRevalidated):
(WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::markLoadAsCompleted):
(WebKit::NetworkCache::SpeculativeLoadManager::retrieve):
(WebKit::NetworkCache::SpeculativeLoadManager::addPreloadedEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::revalidateEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::startSpeculativeRevalidation):
(WebKit::NetworkCache::makeSubresourcesKey): Deleted.
(WebKit::NetworkCache::constructRevalidationRequest): Deleted.
(WebKit::NetworkCache::responseNeedsRevalidation): Deleted.
(WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::saveToDiskIfReady): Deleted.
(WebKit::NetworkCache::SpeculativeLoadManager::retrieveEntryFromStorage): Deleted.
(WebKit::NetworkCache::SpeculativeLoadManager::satisfyPendingRequests): Deleted.
* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeyscpp">trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeysh">trunk/Source/WebCore/page/DiagnosticLoggingKeys.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagercpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagerh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebCore/ChangeLog        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2015-12-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Add diagnostic logging to measure speculative revalidation accuracy
+        https://bugs.webkit.org/show_bug.cgi?id=151953
+        &lt;rdar://problem/23092196&gt;
+
+        Reviewed by Darin Adler.
+
+        Add diagnostic logging to measure speculative revalidation accuracy.
+
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey):
+        (WebCore::DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey):
+        (WebCore::DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey):
+        (WebCore::DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey):
+        (WebCore::DiagnosticLoggingKeys::unknownEntryRequestKey):
+        (WebCore::DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey):
+        (WebCore::DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey):
+        * page/DiagnosticLoggingKeys.h:
+
</ins><span class="cx"> 2015-12-08  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: storage/indexeddb/index-cursor.html fails.
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeyscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -103,6 +103,16 @@
</span><span class="cx">     return ASCIILiteral(&quot;engineFailedToLoad&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey()
+{
+    return ASCIILiteral(&quot;entryRightlyNotWarmedUp&quot;);
+}
+
+String DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey()
+{
+    return ASCIILiteral(&quot;entryWronglyNotWarmedUp&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::navigationKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;navigation&quot;);
</span><span class="lines">@@ -418,6 +428,16 @@
</span><span class="cx">     return ASCIILiteral(&quot;styleSheet&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey()
+{
+    return ASCIILiteral(&quot;successfulSpeculativeWarmupWithRevalidation&quot;);
+}
+
+String DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey()
+{
+    return ASCIILiteral(&quot;successfulSpeculativeWarmupWithoutRevalidation&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::svgDocumentKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;svgDocument&quot;);
</span><span class="lines">@@ -433,6 +453,11 @@
</span><span class="cx">     return ASCIILiteral(&quot;underMemoryPressure&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::unknownEntryRequestKey()
+{
+    return ASCIILiteral(&quot;unknownEntryRequest&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::unlikelyToReuseKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;unlikelyToReuse&quot;);
</span><span class="lines">@@ -513,6 +538,16 @@
</span><span class="cx">     return ASCIILiteral(&quot;video&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey()
+{
+    return ASCIILiteral(&quot;wastedSpeculativeWarmupWithRevalidation&quot;);
+}
+
+String DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey()
+{
+    return ASCIILiteral(&quot;wastedSpeculativeWarmupWithoutRevalidation&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::webViewKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;webView&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeysh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">     static String diskCacheAfterValidationKey();
</span><span class="cx">     static String documentLoaderStoppingKey();
</span><span class="cx">     static String engineFailedToLoadKey();
</span><ins>+    WEBCORE_EXPORT static String entryRightlyNotWarmedUpKey();
+    WEBCORE_EXPORT static String entryWronglyNotWarmedUpKey();
</ins><span class="cx">     static String expiredKey();
</span><span class="cx">     static String fontKey();
</span><span class="cx">     static String hasPluginsKey();
</span><span class="lines">@@ -115,9 +117,12 @@
</span><span class="cx">     static String sourceKey();
</span><span class="cx">     WEBCORE_EXPORT static String streamingMedia();
</span><span class="cx">     static String styleSheetKey();
</span><ins>+    WEBCORE_EXPORT static String successfulSpeculativeWarmupWithRevalidationKey();
+    WEBCORE_EXPORT static String successfulSpeculativeWarmupWithoutRevalidationKey();
</ins><span class="cx">     static String svgDocumentKey();
</span><span class="cx">     WEBCORE_EXPORT static String uncacheableStatusCodeKey();
</span><span class="cx">     static String underMemoryPressureKey();
</span><ins>+    WEBCORE_EXPORT static String unknownEntryRequestKey();
</ins><span class="cx">     WEBCORE_EXPORT static String unlikelyToReuseKey();
</span><span class="cx">     WEBCORE_EXPORT static String unsupportedHTTPMethodKey();
</span><span class="cx">     static String unsuspendableDOMObjectKey();
</span><span class="lines">@@ -134,6 +139,8 @@
</span><span class="cx">     WEBCORE_EXPORT static String userKey();
</span><span class="cx">     WEBCORE_EXPORT static String varyingHeaderMismatchKey();
</span><span class="cx">     static String videoKey();
</span><ins>+    WEBCORE_EXPORT static String wastedSpeculativeWarmupWithRevalidationKey();
+    WEBCORE_EXPORT static String wastedSpeculativeWarmupWithoutRevalidationKey();
</ins><span class="cx">     WEBCORE_EXPORT static String webViewKey();
</span><span class="cx">     WEBCORE_EXPORT static String zoomedKey();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2015-12-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Add diagnostic logging to measure speculative revalidation accuracy
+        https://bugs.webkit.org/show_bug.cgi?id=151953
+        &lt;rdar://problem/23092196&gt;
+
+        Reviewed by Darin Adler.
+
+        We track the following:
+        1. Resources we knew about AND did not get requested
+           A. We did not speculate (Good)
+           B. We speculated but did not go to network (Bad)
+           C. We speculated and went to network (Very bad)
+        2. Resources we did not know about (Neutral)
+        3. Resources we knew about AND got requested
+           A. We did not speculate (Bad)
+           B. We speculated but did not go to network (Good)
+           C. We speculated and went to network (Very good)
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::retrieve):
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        (WebKit::NetworkCache::allSpeculativeLoadingDiagnosticMessages):
+        (WebKit::NetworkCache::printSpeculativeLoadingDiagnosticMessageCounts):
+        (WebKit::NetworkCache::logSpeculativeLoadingDiagnosticMessage):
+        (WebKit::NetworkCache::SpeculativeLoadManager::ExpiringEntry::ExpiringEntry):
+        (WebKit::NetworkCache::SpeculativeLoadManager::PreloadedEntry::PreloadedEntry):
+        (WebKit::NetworkCache::SpeculativeLoadManager::PreloadedEntry::wasRevalidated):
+        (WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::markLoadAsCompleted):
+        (WebKit::NetworkCache::SpeculativeLoadManager::retrieve):
+        (WebKit::NetworkCache::SpeculativeLoadManager::addPreloadedEntry):
+        (WebKit::NetworkCache::SpeculativeLoadManager::revalidateEntry):
+        (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
+        (WebKit::NetworkCache::SpeculativeLoadManager::startSpeculativeRevalidation):
+        (WebKit::NetworkCache::makeSubresourcesKey): Deleted.
+        (WebKit::NetworkCache::constructRevalidationRequest): Deleted.
+        (WebKit::NetworkCache::responseNeedsRevalidation): Deleted.
+        (WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::saveToDiskIfReady): Deleted.
+        (WebKit::NetworkCache::SpeculativeLoadManager::retrieveEntryFromStorage): Deleted.
+        (WebKit::NetworkCache::SpeculativeLoadManager::satisfyPendingRequests): Deleted.
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h:
+
</ins><span class="cx"> 2015-12-08  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] REGRESSION(r173394): MiniBrowser stucked in an infinite loop if NETWORK_CACHE is disabled
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -370,7 +370,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
</span><del>-    if (m_speculativeLoadManager &amp;&amp; m_speculativeLoadManager-&gt;retrieve(storageKey, [originalRequest, completionHandler](std::unique_ptr&lt;Entry&gt; entry) {
</del><ins>+    if (m_speculativeLoadManager &amp;&amp; m_speculativeLoadManager-&gt;retrieve(frameID, storageKey, [originalRequest, completionHandler](std::unique_ptr&lt;Entry&gt; entry) {
</ins><span class="cx">         if (entry &amp;&amp; verifyVaryingRequestHeaders(entry-&gt;varyingRequestHeaders(), originalRequest))
</span><span class="cx">             completionHandler(WTF::move(entry));
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -32,7 +32,10 @@
</span><span class="cx"> #include &quot;NetworkCacheEntry.h&quot;
</span><span class="cx"> #include &quot;NetworkCacheSpeculativeLoad.h&quot;
</span><span class="cx"> #include &quot;NetworkCacheSubresourcesEntry.h&quot;
</span><ins>+#include &quot;NetworkProcess.h&quot;
+#include &lt;WebCore/DiagnosticLoggingKeys.h&gt;
</ins><span class="cx"> #include &lt;WebCore/HysteresisActivity.h&gt;
</span><ins>+#include &lt;wtf/HashCountedSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="lines">@@ -45,6 +48,30 @@
</span><span class="cx"> 
</span><span class="cx"> static const auto preloadedEntryLifetime = 10_s;
</span><span class="cx"> 
</span><ins>+#if !LOG_DISABLED
+static HashCountedSet&lt;String&gt;&amp; allSpeculativeLoadingDiagnosticMessages()
+{
+    static NeverDestroyed&lt;HashCountedSet&lt;String&gt;&gt; messages;
+    return messages;
+}
+
+static void printSpeculativeLoadingDiagnosticMessageCounts()
+{
+    LOG(NetworkCacheSpeculativePreloading, &quot;-- Speculative loading statistics --&quot;);
+    for (auto&amp; pair : allSpeculativeLoadingDiagnosticMessages())
+        LOG(NetworkCacheSpeculativePreloading, &quot;%s: %u&quot;, pair.key.utf8().data(), pair.value);
+}
+#endif
+
+static void logSpeculativeLoadingDiagnosticMessage(const GlobalFrameID&amp; frameID, const String&amp; message)
+{
+#if !LOG_DISABLED
+    if (WebKit2LogNetworkCacheSpeculativePreloading.state == WTFLogChannelOn)
+        allSpeculativeLoadingDiagnosticMessages().add(message);
+#endif
+    NetworkProcess::singleton().logDiagnosticMessage(frameID.first, WebCore::DiagnosticLoggingKeys::networkCacheKey(), message, WebCore::ShouldSample::Yes);
+}
+
</ins><span class="cx"> static const AtomicString&amp; subresourcesType()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><span class="lines">@@ -82,32 +109,39 @@
</span><span class="cx">     return age - lifetime &gt; 0_ms;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class SpeculativeLoadManager::PreloadedEntry {
</del><ins>+class SpeculativeLoadManager::ExpiringEntry {
</ins><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    PreloadedEntry(std::unique_ptr&lt;Entry&gt; entry, std::function&lt;void()&gt;&amp;&amp; lifetimeReachedHandler)
-        : m_entry(WTF::move(entry))
-        , m_lifetimeTimer(*this, &amp;PreloadedEntry::lifetimeTimerFired)
-        , m_lifetimeReachedHandler(WTF::move(lifetimeReachedHandler))
</del><ins>+    explicit ExpiringEntry(std::function&lt;void()&gt;&amp;&amp; expirationHandler)
+        : m_lifetimeTimer(WTF::move(expirationHandler))
</ins><span class="cx">     {
</span><span class="cx">         m_lifetimeTimer.startOneShot(preloadedEntryLifetime);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+private:
+    Timer m_lifetimeTimer;
+};
+
+class SpeculativeLoadManager::PreloadedEntry : private ExpiringEntry {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    PreloadedEntry(std::unique_ptr&lt;Entry&gt; entry, WasRevalidated wasRevalidated, std::function&lt;void()&gt;&amp;&amp; lifetimeReachedHandler)
+        : ExpiringEntry(WTF::move(lifetimeReachedHandler))
+        , m_entry(WTF::move(entry))
+        , m_wasRevalidated(wasRevalidated == WasRevalidated::Yes)
+    { }
+
</ins><span class="cx">     std::unique_ptr&lt;Entry&gt; takeCacheEntry()
</span><span class="cx">     {
</span><span class="cx">         ASSERT(m_entry);
</span><span class="cx">         return WTF::move(m_entry);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool wasRevalidated() const { return m_wasRevalidated; }
+
</ins><span class="cx"> private:
</span><del>-    void lifetimeTimerFired()
-    {
-        m_lifetimeReachedHandler();
-    }
-
</del><span class="cx">     std::unique_ptr&lt;Entry&gt; m_entry;
</span><del>-    Timer m_lifetimeTimer;
-    std::function&lt;void()&gt; m_lifetimeReachedHandler;
</del><ins>+    bool m_wasRevalidated;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class SpeculativeLoadManager::PendingFrameLoad : public RefCounted&lt;PendingFrameLoad&gt; {
</span><span class="lines">@@ -136,6 +170,10 @@
</span><span class="cx">         if (m_didFinishLoad)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><ins>+#if !LOG_DISABLED
+        printSpeculativeLoadingDiagnosticMessageCounts();
+#endif
+
</ins><span class="cx">         m_didFinishLoad = true;
</span><span class="cx">         saveToDiskIfReady();
</span><span class="cx">         m_loadCompletionHandler();
</span><span class="lines">@@ -201,18 +239,29 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool SpeculativeLoadManager::retrieve(const Key&amp; storageKey, const RetrieveCompletionHandler&amp; completionHandler)
</del><ins>+bool SpeculativeLoadManager::retrieve(const GlobalFrameID&amp; frameID, const Key&amp; storageKey, const RetrieveCompletionHandler&amp; completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     // Check already preloaded entries.
</span><span class="cx">     if (auto preloadedEntry = m_preloadedEntries.take(storageKey)) {
</span><span class="cx">         LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Retrieval: Using preloaded entry to satisfy request for '%s':&quot;, storageKey.identifier().utf8().data());
</span><ins>+        if (preloadedEntry-&gt;wasRevalidated())
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey());
+        else
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());
+
</ins><span class="cx">         completionHandler(preloadedEntry-&gt;takeCacheEntry());
</span><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Check pending speculative revalidations.
</span><del>-    if (!m_pendingPreloads.contains(storageKey))
</del><ins>+    if (!m_pendingPreloads.contains(storageKey)) {
+        if (m_notPreloadedEntries.remove(storageKey))
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::entryWronglyNotWarmedUpKey());
+        else
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::unknownEntryRequestKey());
+
</ins><span class="cx">         return false;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Retrieval: revalidation already in progress for '%s':&quot;, storageKey.identifier().utf8().data());
</span><span class="cx"> 
</span><span class="lines">@@ -260,13 +309,18 @@
</span><span class="cx">         pendingFrameLoad-&gt;registerSubresource(resourceKey);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SpeculativeLoadManager::addPreloadedEntry(std::unique_ptr&lt;Entry&gt; entry)
</del><ins>+void SpeculativeLoadManager::addPreloadedEntry(std::unique_ptr&lt;Entry&gt; entry, const GlobalFrameID&amp; frameID, WasRevalidated wasRevalidated)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(entry);
</span><span class="cx">     ASSERT(!entry-&gt;needsValidation());
</span><span class="cx">     auto key = entry-&gt;key();
</span><del>-    m_preloadedEntries.add(key, std::make_unique&lt;PreloadedEntry&gt;(WTF::move(entry), [this, key]() {
-        m_preloadedEntries.remove(key);
</del><ins>+    m_preloadedEntries.add(key, std::make_unique&lt;PreloadedEntry&gt;(WTF::move(entry), wasRevalidated, [this, key, frameID] {
+        auto preloadedEntry = m_preloadedEntries.take(key);
+        ASSERT(preloadedEntry);
+        if (preloadedEntry-&gt;wasRevalidated())
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithRevalidationKey());
+        else
+            logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::wastedSpeculativeWarmupWithoutRevalidationKey());
</ins><span class="cx">     }));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -316,16 +370,19 @@
</span><span class="cx"> 
</span><span class="cx">     auto key = entry-&gt;key();
</span><span class="cx">     LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Speculatively revalidating '%s':&quot;, key.identifier().utf8().data());
</span><del>-    auto revalidator = std::make_unique&lt;SpeculativeLoad&gt;(frameID, constructRevalidationRequest(*entry), WTF::move(entry), [this, key](std::unique_ptr&lt;Entry&gt; revalidatedEntry) {
</del><ins>+    auto revalidator = std::make_unique&lt;SpeculativeLoad&gt;(frameID, constructRevalidationRequest(*entry), WTF::move(entry), [this, key, frameID](std::unique_ptr&lt;Entry&gt; revalidatedEntry) {
</ins><span class="cx">         ASSERT(!revalidatedEntry || !revalidatedEntry-&gt;needsValidation());
</span><span class="cx">         auto protectRevalidator = m_pendingPreloads.take(key);
</span><span class="cx">         LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Speculative revalidation completed for '%s':&quot;, key.identifier().utf8().data());
</span><span class="cx"> 
</span><del>-        if (satisfyPendingRequests(key, revalidatedEntry.get()))
</del><ins>+        if (satisfyPendingRequests(key, revalidatedEntry.get())) {
+            if (revalidatedEntry)
+                logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithRevalidationKey());
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (revalidatedEntry)
</span><del>-            addPreloadedEntry(WTF::move(revalidatedEntry));
</del><ins>+            addPreloadedEntry(WTF::move(revalidatedEntry), frameID, WasRevalidated::Yes);
</ins><span class="cx">     });
</span><span class="cx">     m_pendingPreloads.add(key, WTF::move(revalidator));
</span><span class="cx"> }
</span><span class="lines">@@ -336,8 +393,11 @@
</span><span class="cx">     retrieveEntryFromStorage(key, [this, key, frameID](std::unique_ptr&lt;Entry&gt; entry) {
</span><span class="cx">         m_pendingPreloads.remove(key);
</span><span class="cx"> 
</span><del>-        if (satisfyPendingRequests(key, entry.get()))
</del><ins>+        if (satisfyPendingRequests(key, entry.get())) {
+            if (entry)
+                logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::successfulSpeculativeWarmupWithoutRevalidationKey());
</ins><span class="cx">             return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (!entry)
</span><span class="cx">             return;
</span><span class="lines">@@ -345,17 +405,23 @@
</span><span class="cx">         if (entry-&gt;needsValidation())
</span><span class="cx">             revalidateEntry(WTF::move(entry), frameID);
</span><span class="cx">         else
</span><del>-            addPreloadedEntry(WTF::move(entry));
</del><ins>+            addPreloadedEntry(WTF::move(entry), frameID, WasRevalidated::No);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SpeculativeLoadManager::startSpeculativeRevalidation(const GlobalFrameID&amp; frameID, SubresourcesEntry&amp; entry)
</span><span class="cx"> {
</span><span class="cx">     for (auto&amp; subresource : entry.subresources()) {
</span><ins>+        auto key = subresource.key;
</ins><span class="cx">         if (!subresource.value.isTransient)
</span><del>-            preloadEntry(subresource.key, frameID);
-        else
</del><ins>+            preloadEntry(key, frameID);
+        else {
</ins><span class="cx">             LOG(NetworkCacheSpeculativePreloading, &quot;(NetworkProcess) Not preloading '%s' because it is marked as transient&quot;, subresource.key.identifier().utf8().data());
</span><ins>+            m_notPreloadedEntries.add(key, std::make_unique&lt;ExpiringEntry&gt;([this, key, frameID] {
+                logSpeculativeLoadingDiagnosticMessage(frameID, DiagnosticLoggingKeys::entryRightlyNotWarmedUpKey());
+                m_notPreloadedEntries.remove(key);
+            }));
+        }
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheSpeculativeLoadManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h (193755 => 193756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h        2015-12-08 17:37:35 UTC (rev 193755)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.h        2015-12-08 17:39:46 UTC (rev 193756)
</span><span class="lines">@@ -50,10 +50,11 @@
</span><span class="cx">     void registerLoad(const GlobalFrameID&amp;, const WebCore::ResourceRequest&amp;, const Key&amp; resourceKey);
</span><span class="cx"> 
</span><span class="cx">     typedef std::function&lt;void (std::unique_ptr&lt;Entry&gt;)&gt; RetrieveCompletionHandler;
</span><del>-    bool retrieve(const Key&amp; storageKey, const RetrieveCompletionHandler&amp;);
</del><ins>+    bool retrieve(const GlobalFrameID&amp;, const Key&amp; storageKey, const RetrieveCompletionHandler&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void addPreloadedEntry(std::unique_ptr&lt;Entry&gt;);
</del><ins>+    enum class WasRevalidated { No, Yes };
+    void addPreloadedEntry(std::unique_ptr&lt;Entry&gt;, const GlobalFrameID&amp;, WasRevalidated);
</ins><span class="cx">     void preloadEntry(const Key&amp;, const GlobalFrameID&amp;);
</span><span class="cx">     void retrieveEntryFromStorage(const Key&amp;, const RetrieveCompletionHandler&amp;);
</span><span class="cx">     void revalidateEntry(std::unique_ptr&lt;Entry&gt;, const GlobalFrameID&amp;);
</span><span class="lines">@@ -71,6 +72,9 @@
</span><span class="cx"> 
</span><span class="cx">     class PreloadedEntry;
</span><span class="cx">     HashMap&lt;Key, std::unique_ptr&lt;PreloadedEntry&gt;&gt; m_preloadedEntries;
</span><ins>+
+    class ExpiringEntry;
+    HashMap&lt;Key, std::unique_ptr&lt;ExpiringEntry&gt;&gt; m_notPreloadedEntries; // For logging.
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace NetworkCache
</span></span></pre>
</div>
</div>

</body>
</html>