Bug 207747 - NetworkLoadMetrics should be shared by multiple ResourceResponse instances
Summary: NetworkLoadMetrics should be shared by multiple ResourceResponse instances
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-13 23:24 PST by Yusuke Suzuki
Modified: 2020-02-14 11:53 PST (History)
11 users (show)

See Also:


Attachments
Patch (34.06 KB, patch)
2020-02-13 23:40 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (47.35 KB, patch)
2020-02-14 00:59 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (45.66 KB, patch)
2020-02-14 01:06 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (45.85 KB, patch)
2020-02-14 01:15 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (48.40 KB, patch)
2020-02-14 01:21 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (51.12 KB, patch)
2020-02-14 01:36 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (50.95 KB, patch)
2020-02-14 02:13 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (50.97 KB, patch)
2020-02-14 04:32 PST, Yusuke Suzuki
keith_miller: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2020-02-13 23:24:09 PST
NetworkLoadMetrics should be shared by multiple ResourceResponse instances
Comment 1 Yusuke Suzuki 2020-02-13 23:40:24 PST
Created attachment 390732 [details]
Patch
Comment 2 Yusuke Suzuki 2020-02-13 23:40:57 PST
Comment on attachment 390732 [details]
Patch

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

> Source/WebCore/ChangeLog:10
> +        has Vector<ResourceResponse> to replay response dispatching in the case of loading from BackForwardCache. The problem is

Note that this is one of the largest Vector in Membuster.
Comment 3 Radar WebKit Bug Importer 2020-02-13 23:47:11 PST
<rdar://problem/59452102>
Comment 4 Yusuke Suzuki 2020-02-14 00:59:31 PST
Created attachment 390737 [details]
Patch
Comment 5 Yusuke Suzuki 2020-02-14 01:06:53 PST
Created attachment 390738 [details]
Patch
Comment 6 Yusuke Suzuki 2020-02-14 01:15:31 PST
Created attachment 390739 [details]
Patch
Comment 7 Yusuke Suzuki 2020-02-14 01:21:36 PST
Created attachment 390740 [details]
Patch
Comment 8 Yusuke Suzuki 2020-02-14 01:36:16 PST
Created attachment 390741 [details]
Patch
Comment 9 Yusuke Suzuki 2020-02-14 02:13:33 PST
Created attachment 390743 [details]
Patch
Comment 10 Yusuke Suzuki 2020-02-14 02:16:01 PST
I'm also considering that making ResourceResponse RefCounted<>, but as a first step, I'll do NetworkLoadMetrics part.

I think we could make ResourceResponse RefCounted<> without changing much of things.
Due to WebKit2, we already initialize all the fields of ResourceResponse anyway.
So, we could make almost all part as immutable.
Comment 11 Yusuke Suzuki 2020-02-14 04:32:25 PST
Created attachment 390755 [details]
Patch
Comment 12 Keith Miller 2020-02-14 11:33:15 PST
Comment on attachment 390755 [details]
Patch

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

r=me with nits.

> Source/WebCore/ChangeLog:13
> +        While we sometimes copies it to modify some part of it, NetworkLoadMetrics is immutable. It is set when response is created,

nit: copies => copy

Also, what is "it" in "copies it"? A NeworkLoadMetrics or a ResourceResponse?

> Source/WebCore/ChangeLog:17
> +        This patch puts Box<NetworkLoadMetrics> in ResourceResponse to share it by all copied ResourceResponses. We do not make NetworkLoadMetrics

Nit: share it by => hare it with.

> Source/WebCore/ChangeLog:18
> +        RefCounted<> for now since some legit data structure embeds NetworkLoadMetrics. This patch adds ArgumentCoder for Box so that we

Nit: data structure embeds => data structures embed

Or did you mean that there is only on data structure that embed's NetworkLoadMetrics? If so can you name that class?

> Source/WebCore/platform/network/ResourceResponseBase.h:339
> +    if constexpr (Decoder::isIPCDecoder) {
> +        if (!decoder.decode(response.m_networkLoadMetrics))
> +            return false;
> +    }

Why bother with this change? Seems like the compiler will make this optimization anyway?

> Source/WebCore/platform/network/cocoa/NetworkLoadMetrics.mm:68
> +

Nit: remove newline here.
Comment 13 Yusuke Suzuki 2020-02-14 11:50:28 PST
Comment on attachment 390755 [details]
Patch

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

Thanks!

>> Source/WebCore/ChangeLog:13
>> +        While we sometimes copies it to modify some part of it, NetworkLoadMetrics is immutable. It is set when response is created,
> 
> nit: copies => copy
> 
> Also, what is "it" in "copies it"? A NeworkLoadMetrics or a ResourceResponse?

Fixed. DocumentLoader for example is copying ResourceResponse.

>> Source/WebCore/ChangeLog:17
>> +        This patch puts Box<NetworkLoadMetrics> in ResourceResponse to share it by all copied ResourceResponses. We do not make NetworkLoadMetrics
> 
> Nit: share it by => hare it with.

Fixed.

>> Source/WebCore/ChangeLog:18
>> +        RefCounted<> for now since some legit data structure embeds NetworkLoadMetrics. This patch adds ArgumentCoder for Box so that we
> 
> Nit: data structure embeds => data structures embed
> 
> Or did you mean that there is only on data structure that embed's NetworkLoadMetrics? If so can you name that class?

Fixed. Some of multiple classes are embedding NetworkLoadMetrics. So for now, I'm taking an easy path.

>> Source/WebCore/platform/network/ResourceResponseBase.h:339
>> +    }
> 
> Why bother with this change? Seems like the compiler will make this optimization anyway?

Encoder can be persistent coder (which generates bytes for disks).
We can omit implementation of persistent coder's NetworkLoadMetrics handling if we use `if constexpr`.

>> Source/WebCore/platform/network/cocoa/NetworkLoadMetrics.mm:68
>> +
> 
> Nit: remove newline here.

Fixed.
Comment 14 Yusuke Suzuki 2020-02-14 11:53:22 PST
Committed r256632: <https://trac.webkit.org/changeset/256632>