RESOLVED FIXED 150221
[WK2] Generalize NetworkCacheStorage API so it can store different types of metadata
https://bugs.webkit.org/show_bug.cgi?id=150221
Summary [WK2] Generalize NetworkCacheStorage API so it can store different types of m...
Chris Dumez
Reported 2015-10-15 20:45:34 PDT
Generalize NetworkCacheStorage API so it can store different types of metadata alongside the network resources. This is a pre-requirement to making our NetworkCache smarter by storing information about the resources.
Attachments
WIP Patch (35.64 KB, patch)
2015-10-15 20:47 PDT, Chris Dumez
no flags
Patch (36.62 KB, patch)
2015-10-15 21:31 PDT, Chris Dumez
no flags
Patch (36.90 KB, patch)
2015-10-15 22:26 PDT, Chris Dumez
no flags
Patch (29.80 KB, patch)
2015-10-16 14:07 PDT, Chris Dumez
no flags
Patch (31.82 KB, patch)
2015-10-19 11:26 PDT, Chris Dumez
no flags
Patch (31.75 KB, patch)
2015-10-20 15:22 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2015-10-15 20:47:14 PDT
Chris Dumez
Comment 2 2015-10-15 20:47:56 PDT
Created attachment 263243 [details] WIP Patch
WebKit Commit Bot
Comment 3 2015-10-15 20:49:53 PDT
Attachment 263243 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:188: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:943: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:70: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:177: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 4 2015-10-15 21:31:14 PDT
WebKit Commit Bot
Comment 5 2015-10-15 21:33:42 PDT
Attachment 263244 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:188: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:948: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:70: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:177: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alexey Proskuryakov
Comment 6 2015-10-15 22:09:24 PDT
Comment on attachment 263244 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263244&action=review > Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:55 > + static NeverDestroyed<const String> resource(ASCIILiteral("resource")); I like to assert that we are on a known (usually main) thread in functions like this, to make sure that the code isn't accidentally used from a secondary thread. > Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:361 > + m_storage->retrieve(storageKey, resourceType(), priority, [this, originalRequest, completionHandler, startTime, storageKey, webPageID](std::unique_ptr<Storage::Record> record) { And here it looks like maybe it is?
Chris Dumez
Comment 7 2015-10-15 22:23:11 PDT
Comment on attachment 263244 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263244&action=review >> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:55 >> + static NeverDestroyed<const String> resource(ASCIILiteral("resource")); > > I like to assert that we are on a known (usually main) thread in functions like this, to make sure that the code isn't accidentally used from a secondary thread. This is a good idea, I'll add a check. >> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:361 >> + m_storage->retrieve(storageKey, resourceType(), priority, [this, originalRequest, completionHandler, startTime, storageKey, webPageID](std::unique_ptr<Storage::Record> record) { > > And here it looks like maybe it is? No, this is executed in the main thread.
Chris Dumez
Comment 8 2015-10-15 22:26:43 PDT
Chris Dumez
Comment 9 2015-10-15 22:27:03 PDT
Comment on attachment 263244 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263244&action=review >>> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:55 >>> + static NeverDestroyed<const String> resource(ASCIILiteral("resource")); >> >> I like to assert that we are on a known (usually main) thread in functions like this, to make sure that the code isn't accidentally used from a secondary thread. > > This is a good idea, I'll add a check. Done.
WebKit Commit Bot
Comment 10 2015-10-15 22:28:16 PDT
Attachment 263248 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:188: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:948: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:70: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:177: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Antti Koivisto
Comment 11 2015-10-16 06:01:01 PDT
Comment on attachment 263248 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263248&action=review > Source/WebKit2/ChangeLog:17 > + Generalize NetworkCacheStorage API so it can store different types of > + metadata alongside the network resources. This is a pre-requirement to > + making our NetworkCache smarter by storing information about the > + resources. > + > + To simplify the code, all cache entries now have a suffix, so that they > + all following the following format: > + - Regular entries: [hash]-[type] > + - Blobs: [hash]-[type]blob Not that I look this, wouldn't we get pretty much the same features by simply expanding Key to include the entry type? I was thinking of having single record file and multiple associated data blobs. That scheme would have advantage of having less files in general case. However may it is not worth the complexity. > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:60 > +static bool typeUsesBlobStorage(const String& type) > +{ > + return type == resourceType; > +} > + > +static bool typeUsesHeader(const String& type) > +{ > + return type == resourceType; > +} Are these necessary? Wouldn't the existing solution that just automatically inlines the data to record file if it is small (<16KB) work as is? > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:67 > + ReadOperation(const Key& key, const String& type, const RetrieveCompletionHandler& completionHandler) Type could be AtomicString (here and elsewhere).
Chris Dumez
Comment 12 2015-10-16 12:34:13 PDT
Comment on attachment 263248 [details] Patch Will re-upload another integration based on initial feedback.
Radar WebKit Bug Importer
Comment 13 2015-10-16 13:56:28 PDT
Chris Dumez
Comment 14 2015-10-16 14:07:15 PDT
Chris Dumez
Comment 15 2015-10-16 14:08:53 PDT
WebKit Commit Bot
Comment 16 2015-10-16 14:10:45 PDT
Attachment 263327 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:156: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:876: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:68: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:173: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 17 2015-10-18 16:14:54 PDT
Comment on attachment 263327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263327&action=review > Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:54 > +static const String resourceType() More efficient to return const String& to avoid reference count churn every time this is called.
Antti Koivisto
Comment 18 2015-10-19 05:49:10 PDT
Comment on attachment 263327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263327&action=review r=me as well, looks good. > Source/WebKit2/ChangeLog:18 > + - WebKitCache/Version 5/[Partition]/[Type]/[Hash]-bodyblob (Optional) "bodyblob" is bit strange. How about "blob" or "data"? >> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:54 >> +static const String resourceType() > > More efficient to return const String& to avoid reference count churn every time this is called. It would also make sense to use AtomicString for type identifier. Doesn't need to be in this patch if there are complications. > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:902 > deleteEmptyRecordsDirectories(recordsPath); I think this patch will leave empty partition directories behind. This can be solved separately though.
Chris Dumez
Comment 19 2015-10-19 11:26:48 PDT
Chris Dumez
Comment 20 2015-10-19 11:28:33 PDT
Comment on attachment 263327 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263327&action=review >> Source/WebKit2/ChangeLog:18 >> + - WebKitCache/Version 5/[Partition]/[Type]/[Hash]-bodyblob (Optional) > > "bodyblob" is bit strange. How about "blob" or "data"? Renamed to "blob" >>> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:54 >>> +static const String resourceType() >> >> More efficient to return const String& to avoid reference count churn every time this is called. > > It would also make sense to use AtomicString for type identifier. Doesn't need to be in this patch if there are complications. Ok, now returns a "const AtomicString&" >> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:902 >> deleteEmptyRecordsDirectories(recordsPath); > > I think this patch will leave empty partition directories behind. This can be solved separately though. Right, the last iteration updates deleteEmptyRecordsDirectories() to delete empty [type] subdirectories before attempting to delete the [partitition] ones.
WebKit Commit Bot
Comment 21 2015-10-19 11:28:48 PDT
Attachment 263496 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:156: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:888: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:68: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:173: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 22 2015-10-19 12:22:02 PDT
Comment on attachment 263496 [details] Patch Clearing flags on attachment: 263496 Committed r191306: <http://trac.webkit.org/changeset/191306>
WebKit Commit Bot
Comment 23 2015-10-19 12:22:07 PDT
All reviewed patches have been landed. Closing bug.
WebKit Commit Bot
Comment 24 2015-10-20 13:46:54 PDT
Re-opened since this is blocked by bug 150371
Chris Dumez
Comment 25 2015-10-20 15:22:18 PDT
Chris Dumez
Comment 26 2015-10-20 15:23:33 PDT
Comment on attachment 263496 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=263496&action=review > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:165 > + if (!actualType.isEmpty() && expectedType != actualType) This was supposed to be: if (! expectedType.isEmpty() && expectedType != actualType) > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:168 > + traverseDirectory(partitionPath, [&function, &recordDirectoryPath, &actualType](const String& fileName, DirectoryEntryType entryType) { Should pass recordDirectoryPath instead of partitionPath here.
WebKit Commit Bot
Comment 27 2015-10-20 15:24:40 PDT
Attachment 263621 [details] did not pass style-queue: ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:156: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:888: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:68: Extra space before ( in function call [whitespace/parens] [4] ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:173: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 4 in 7 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 28 2015-10-20 15:41:09 PDT
Waiting for bots to recover before I land again.
WebKit Commit Bot
Comment 29 2015-10-20 23:41:55 PDT
Comment on attachment 263621 [details] Patch Clearing flags on attachment: 263621 Committed r191377: <http://trac.webkit.org/changeset/191377>
WebKit Commit Bot
Comment 30 2015-10-20 23:42:03 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.