Bug 143879 - Network Cache: Read resource record and body in parallel
Summary: Network Cache: Read resource record and body in parallel
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-17 05:50 PDT by Antti Koivisto
Modified: 2015-04-17 10:10 PDT (History)
2 users (show)

See Also:


Attachments
patch (18.31 KB, patch)
2015-04-17 06:37 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
more thread safety (18.20 KB, patch)
2015-04-17 07:33 PDT, Antti Koivisto
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2015-04-17 05:50:23 PDT
We can lower retrieve latency by fetching in parallel.
Comment 1 Antti Koivisto 2015-04-17 06:37:46 PDT
Created attachment 251018 [details]
patch
Comment 2 Antti Koivisto 2015-04-17 07:33:30 PDT
Created attachment 251023 [details]
more thread safety
Comment 3 Chris Dumez 2015-04-17 09:39:41 PDT
Comment on attachment 251023 [details]
more thread safety

View in context: https://bugs.webkit.org/attachment.cgi?id=251023&action=review

r=me

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:122
>          auto filter = std::make_unique<ContentsFilter>();

Maybe rename this one to recordFilter now that we have another filter?

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:124
>          size_t size = 0;

Ditto, I would rename this to recordsSize for clarity as it doesn't account for bodies.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:189
>  bool Storage::mayContain(const Key& key) const

Maybe we can add a mayContainBodyBlob() now? For consistency. Then rename this one to mayContainRecord().
I know it is only used in one place right now but I still like it.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:421
> +void Storage::dispatchReadOperation(ReadOperation& read)

Not a big fan of 'read' variable name. Maybe something like readOperation would be more readable here.

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp:435
> +    bool shouldGetBodyBlob = !m_bodyBlobFilter || m_bodyBlobFilter->mayContain(read.key.hash());

I would use a utility function like we do for the records filter already.
Comment 4 Chris Dumez 2015-04-17 09:41:56 PDT
Comment on attachment 251023 [details]
more thread safety

View in context: https://bugs.webkit.org/attachment.cgi?id=251023&action=review

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:110
> +        std::atomic<unsigned> finishedCount { 0 };

Not sure it is best but maybe we could use 2 booleans instead (e.g. hasReadRecord, hasReadBody). Might be a little more readable than expecting this integer to be 2. Your call.
Comment 5 Antti Koivisto 2015-04-17 10:08:55 PDT
https://trac.webkit.org/r182954
Comment 6 Antti Koivisto 2015-04-17 10:10:04 PDT
(In reply to comment #4)
> Not sure it is best but maybe we could use 2 booleans instead (e.g.
> hasReadRecord, hasReadBody). Might be a little more readable than expecting
> this integer to be 2. Your call.

That's what the first patch had and it is actually difficult to make thread safe.