Title: [181816] trunk/Source/WebKit2
- Revision
- 181816
- Author
- [email protected]
- Date
- 2015-03-20 16:09:56 -0700 (Fri, 20 Mar 2015)
Log Message
[WK2] NetworkCache retrievals sometimes fail on browser startup
https://bugs.webkit.org/show_bug.cgi?id=142925
<rdar://problem/20245368>
Reviewed by Antti Koivisto.
NetworkCache retrievals sometimes fail on browser startup for resources
that are actually cached. The reason is that we are using a bloom filter
for performance reasons to avoid unnecessary disk I/O and this bloom
filter is populated on start up in a background thread by traversing the
cache files on disk. However, when restoring the tabs on start-up we
sometimes query this bloom filter before it is completely populated and
we thus fail to retrieve cached entries because we think they don't
exist and don't check the disk.
This patch adds an "isPopulatingContentsFilter" flag that is turned ON
on start up while we are populating the bloon filter. We then bypass
the bloom filter and send queries directly to disk on start up if this
flag is ON.
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::initialize):
(WebKit::NetworkCache::Storage::retrieve):
(WebKit::NetworkCache::Storage::dispatchPendingWriteOperations):
(WebKit::NetworkCache::Storage::dispatchHeaderWriteOperation):
* NetworkProcess/cache/NetworkCacheStorage.h:
(WebKit::NetworkCache::Storage::cacheMayContain):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (181815 => 181816)
--- trunk/Source/WebKit2/ChangeLog 2015-03-20 22:45:14 UTC (rev 181815)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-20 23:09:56 UTC (rev 181816)
@@ -1,5 +1,35 @@
2015-03-20 Chris Dumez <[email protected]>
+ [WK2] NetworkCache retrievals sometimes fail on browser startup
+ https://bugs.webkit.org/show_bug.cgi?id=142925
+ <rdar://problem/20245368>
+
+ Reviewed by Antti Koivisto.
+
+ NetworkCache retrievals sometimes fail on browser startup for resources
+ that are actually cached. The reason is that we are using a bloom filter
+ for performance reasons to avoid unnecessary disk I/O and this bloom
+ filter is populated on start up in a background thread by traversing the
+ cache files on disk. However, when restoring the tabs on start-up we
+ sometimes query this bloom filter before it is completely populated and
+ we thus fail to retrieve cached entries because we think they don't
+ exist and don't check the disk.
+
+ This patch adds an "isPopulatingContentsFilter" flag that is turned ON
+ on start up while we are populating the bloon filter. We then bypass
+ the bloom filter and send queries directly to disk on start up if this
+ flag is ON.
+
+ * NetworkProcess/cache/NetworkCacheStorage.cpp:
+ (WebKit::NetworkCache::Storage::initialize):
+ (WebKit::NetworkCache::Storage::retrieve):
+ (WebKit::NetworkCache::Storage::dispatchPendingWriteOperations):
+ (WebKit::NetworkCache::Storage::dispatchHeaderWriteOperation):
+ * NetworkProcess/cache/NetworkCacheStorage.h:
+ (WebKit::NetworkCache::Storage::cacheMayContain):
+
+2015-03-20 Chris Dumez <[email protected]>
+
[WK2] Allow stale content when restoring the browser's session state
https://bugs.webkit.org/show_bug.cgi?id=142916
<rdar://problem/20243493>
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (181815 => 181816)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2015-03-20 22:45:14 UTC (rev 181815)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp 2015-03-20 23:09:56 UTC (rev 181816)
@@ -92,6 +92,7 @@
WebCore::getFileSize(filePath, fileSize);
m_approximateSize += fileSize;
});
+ m_hasPopulatedContentsFilter = true;
});
}
@@ -372,7 +373,7 @@
return;
}
- if (!m_contentsFilter.mayContain(key.shortHash())) {
+ if (!cacheMayContain(key.shortHash())) {
completionHandler(nullptr);
return;
}
@@ -460,7 +461,7 @@
auto& write = *writeOperation;
m_activeWriteOperations.add(WTF::move(writeOperation));
- if (write.existingEntry && m_contentsFilter.mayContain(write.entry.key.shortHash())) {
+ if (write.existingEntry && cacheMayContain(write.entry.key.shortHash())) {
dispatchHeaderWriteOperation(write);
continue;
}
@@ -515,7 +516,7 @@
ASSERT(RunLoop::isMain());
ASSERT(write.existingEntry);
ASSERT(m_activeWriteOperations.contains(&write));
- ASSERT(m_contentsFilter.mayContain(write.entry.key.shortHash()));
+ ASSERT(cacheMayContain(write.entry.key.shortHash()));
// Try to update the header of an existing entry.
StringCapture cachePathCapture(m_directoryPath);
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h (181815 => 181816)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2015-03-20 22:45:14 UTC (rev 181815)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h 2015-03-20 23:09:56 UTC (rev 181816)
@@ -103,12 +103,16 @@
WorkQueue& backgroundIOQueue() { return m_backgroundIOQueue.get(); }
WorkQueue& serialBackgroundIOQueue() { return m_serialBackgroundIOQueue.get(); }
+ bool cacheMayContain(unsigned shortHash) { return !m_hasPopulatedContentsFilter || m_contentsFilter.mayContain(shortHash); }
+
const String m_baseDirectoryPath;
const String m_directoryPath;
size_t m_maximumSize { std::numeric_limits<size_t>::max() };
BloomFilter<20> m_contentsFilter;
+ std::atomic<bool> m_hasPopulatedContentsFilter { false };
+
std::atomic<size_t> m_approximateSize { 0 };
std::atomic<bool> m_shrinkInProgress { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes