Bug 45486 - Pass CachedMetadata on ResourceResponse instead of in a separate call
Summary: Pass CachedMetadata on ResourceResponse instead of in a separate call
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Tony Gentilcore
URL:
Keywords:
: 45483 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-09 12:47 PDT by Tony Gentilcore
Modified: 2013-10-02 12:27 PDT (History)
9 users (show)

See Also:


Attachments
Patch (29.67 KB, patch)
2010-09-09 13:09 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Build fix (30.23 KB, patch)
2010-09-09 16:48 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Patch (27.71 KB, patch)
2010-09-22 11:31 PDT, Tony Gentilcore
ap: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Gentilcore 2010-09-09 12:47:39 PDT
Pass CachedMetadata on ResourceResponse instead of in a separate call
Comment 1 Tony Gentilcore 2010-09-09 13:09:31 PDT
Created attachment 67084 [details]
Patch
Comment 2 Tony Gentilcore 2010-09-09 13:10:52 PDT
You were right, this is cleaner and should be more efficient.
Comment 3 Early Warning System Bot 2010-09-09 13:36:31 PDT
Attachment 67084 [details] did not build on qt:
Build output: http://queues.webkit.org/results/3914353
Comment 4 Eric Seidel (no email) 2010-09-09 15:41:52 PDT
Attachment 67084 [details] did not build on mac:
Build output: http://queues.webkit.org/results/3947336
Comment 5 WebKit Review Bot 2010-09-09 16:19:18 PDT
Attachment 67084 [details] did not build on gtk:
Build output: http://queues.webkit.org/results/3932338
Comment 6 Tony Gentilcore 2010-09-09 16:48:59 PDT
Created attachment 67118 [details]
Build fix
Comment 7 Eric Seidel (no email) 2010-09-09 17:39:19 PDT
Attachment 67118 [details] did not build on mac:
Build output: http://queues.webkit.org/results/3897338
Comment 8 Tony Gentilcore 2010-09-14 14:56:32 PDT
*** Bug 45483 has been marked as a duplicate of this bug. ***
Comment 9 Darin Fisher (:fishd, Google) 2010-09-14 22:29:44 PDT
Comment on attachment 67118 [details]
Build fix

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

> WebCore/loader/CachedMetadata.h:64
> +        RefPtr<CachedMetadata> cachedMetadata = create(dataTypeID(), data(), size());
don't create functions normally return PassRefPtr?  why bother with the intermediate cachedMetadata variable?

> WebCore/loader/CachedMetadata.h:68
> +    bool operator==(const CachedMetadata& other) const
not that it really matters here, but normally it is better to define operator== and operator!= at global scope so that
type coercion works properly.  as member functions, only the right-hand-side argument can be coerced.

> WebKit/chromium/public/WebCachedMetadata.h:41
> +class WebCachedMetadata {
would it make sense to use WebData in place of defining this new class?  note: WebData can be converted to a RefPtr<SharedBuffer> without any cost.

i ask because this class just looks like a wrapper for an array of bytes.  that's what WebData is.


otherwise, looks great to me!
Comment 10 Tony Gentilcore 2010-09-22 11:31:25 PDT
Created attachment 68403 [details]
Patch
Comment 11 Eric Seidel (no email) 2010-09-22 12:45:52 PDT
Attachment 68403 [details] did not build on mac:
Build output: http://queues.webkit.org/results/3999092
Comment 12 Adam Barth 2010-09-26 22:19:35 PDT
Comment on attachment 68403 [details]
Patch

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

> WebCore/loader/CachedMetadata.h:132
> +    return a.serialize() == b.serialize();

Woah, that looks expensive.
Comment 13 Eric Seidel (no email) 2010-12-14 01:57:18 PST
What's the status on this patch, Tony?
Comment 14 Tony Gentilcore 2010-12-14 09:25:11 PST
(In reply to comment #13)
> What's the status on this patch, Tony?

Thanks for the ping. I'm missing a file needed a on mac. I'll get it synced up and landed this week.
Comment 15 Alexey Proskuryakov 2010-12-14 11:02:15 PST
Wait, why is this a good thing? This seems to be going in a wrong direction of adding non-network data to network classes.
Comment 16 Adam Barth 2010-12-14 12:22:24 PST
(In reply to comment #15)
> Wait, why is this a good thing? This seems to be going in a wrong direction of adding non-network data to network classes.

The CachedMetadata is meta data about the response that we'd like to store in the HTTP cache.  For example, it might contain a post-parsing representation of a JavaScript script so we don't have to parse it again if we get a cache hit.
Comment 17 Alexey Proskuryakov 2010-12-14 12:42:54 PST
But that's exactly what CachedScript is doing.
Comment 18 Adam Barth 2010-12-14 14:05:11 PST
(In reply to comment #17)
> But that's exactly what CachedScript is doing.

Right, but we want to store it on disk.
Comment 19 Alexey Proskuryakov 2010-12-14 14:35:53 PST
I've been told that we want to store CachedResource to disk, in fact. I think that moving CachedResource behaviors down to ResourceRequest/Response is going in a wrong direction, and conflicts with work being done in CachedResource land.
Comment 20 Adam Barth 2010-12-14 14:40:23 PST
> I've been told that we want to store CachedResource to disk, in fact. I think that moving CachedResource behaviors down to ResourceRequest/Response is going in a wrong direction, and conflicts with work being done in CachedResource land.

The approach in this work is to integrate the disk storage with the HTTP disk cache so that the two objects can be managed together.  For example, when the we evict the resource from the HTTP disk cache, we want to evict the metadata too.

If we were to re-implement disk storage at the MemoryCache layer, we'd just be re-inventing all the mechanisms of the HTTP disk cache.
Comment 21 Alexey Proskuryakov 2010-12-14 15:00:36 PST
Comment on attachment 68403 [details]
Patch

This seems to need deeper discussion. I've already Cc'ed Antti; marking r- to reflect that discussion is needed.
Comment 22 Tony Gentilcore 2010-12-14 15:55:51 PST
I can explain some background. V8's PreCompile() method generates some metadata that makes future calls to Compile() faster (it is basically just the offset of each brace). On a particular collection of web pages, we found that about 7% of the overall page load time in chromium is spent preparsing JavaScript. So to speed up future loads we store this as metadata on CachedResource. It is stored as a generic bucket of bytes so that other CachedResource types may use this mechanism as well.

But just saving it in the memory cache is of limited usefulness. To increase the number of cases where this metadata is available, we notify the embedding application via didReceiveCachedMetadata() so that it may save it into its disk cache.

However, for chromium that ends up resulting in two IPC calls: didReceiveResponse and didReceiveCachedMetadata. The goal of this patch was to merge those into a single IPC by simply making the metadata available on the ResourceResponse which is already passed to didReceiveResponse.

I'm completely open to other ways to accomplish the same thing. Do you have time to describe the changes that are happening regarding saving CachedResources to disk?