Bug 226982 - Reduce sizeof(NetworkLoadMetrics)
Summary: Reduce sizeof(NetworkLoadMetrics)
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: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-14 12:02 PDT by Alex Christensen
Modified: 2021-09-21 17:27 PDT (History)
16 users (show)

See Also:


Attachments
Patch (12.31 KB, patch)
2021-06-14 12:05 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (50.64 KB, patch)
2021-08-19 17:12 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch including soup implementation (55.64 KB, patch)
2021-08-20 02:33 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (60.40 KB, patch)
2021-08-24 18:02 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (60.86 KB, patch)
2021-08-24 19:26 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (63.55 KB, patch)
2021-08-31 16:44 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (64.34 KB, patch)
2021-09-21 16:22 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2021-06-14 12:02:33 PDT
Use bit fields to reduce sizeof(SecurityOrigin) and sizeof(NetworkLoadMetrics)
Comment 1 Alex Christensen 2021-06-14 12:05:46 PDT
Created attachment 431351 [details]
Patch
Comment 2 Chris Dumez 2021-06-14 12:11:08 PDT
Comment on attachment 431351 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Use bit fields to reduce sizeof(SecurityOrigin) and sizeof(NetworkLoadMetrics)

Why? Do we keep a lot of SecurityOrigins in memory? I did not expect us to.
I don't think we should use bitfields unless there is a strong argument to reduce memory usage, given that it makes the code less readable/convenient.
Comment 3 Radar WebKit Bug Importer 2021-06-21 12:03:46 PDT
<rdar://problem/79573792>
Comment 4 Alex Christensen 2021-08-19 17:12:36 PDT
Created attachment 435928 [details]
Patch
Comment 5 Carlos Garcia Campos 2021-08-20 02:33:28 PDT
Created attachment 435959 [details]
Patch including soup implementation

It also fixes a couple of redundant move in return statement issues.
Comment 6 Fujii Hironori 2021-08-24 18:02:33 PDT
Created attachment 436357 [details]
Patch
Comment 7 Fujii Hironori 2021-08-24 19:26:20 PDT
Created attachment 436366 [details]
Patch
Comment 8 Alex Christensen 2021-08-31 16:44:43 PDT
Created attachment 436964 [details]
Patch
Comment 9 Alex Christensen 2021-09-01 12:26:10 PDT
After r281860 this needs rebasing which will add another use of emptyMetrics, but please review.
Comment 10 Don Olmstead 2021-09-01 17:44:22 PDT
The cURL side looks fine from our side.
Comment 11 Chris Dumez 2021-09-21 15:38:48 PDT
Comment on attachment 436964 [details]
Patch

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

r=me with changes

> Source/WebCore/platform/network/NetworkLoadMetrics.h:67
> +    NetworkLoadMetrics(const NetworkLoadMetrics&) = default;

Why do we need these? What prevents the fault ones from being generated?

> Source/WebCore/platform/network/NetworkLoadMetrics.h:116
> +struct AdditionalNetworkLoadMetricsForWebInspector : public RefCounted<AdditionalNetworkLoadMetricsForWebInspector> {

Given that this subclasses RefCounted, we should make the constructor private and have a public create() function. It is too error-prone otherwise.

Alternatively, looking at your patch, I don't think we need to subclass RefCounted at all as it doesn't seem we ever share ownership of such objects? If so, I would just not subclass RefCounted and use makeUnique / unique_ptr.
Comment 12 Alex Christensen 2021-09-21 15:49:36 PDT
(In reply to Chris Dumez from comment #11)
> Comment on attachment 436964 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=436964&action=review
> 
> r=me with changes
> 
> > Source/WebCore/platform/network/NetworkLoadMetrics.h:67
> > +    NetworkLoadMetrics(const NetworkLoadMetrics&) = default;
> 
> Why do we need these? What prevents the fault ones from being generated?
I tried to remove the copy constructor in an earlier version of the patch, and I think this change isn't necessary now.  Will remove.

> > Source/WebCore/platform/network/NetworkLoadMetrics.h:116
> > +struct AdditionalNetworkLoadMetricsForWebInspector : public RefCounted<AdditionalNetworkLoadMetricsForWebInspector> {
> 
> Given that this subclasses RefCounted, we should make the constructor
> private and have a public create() function. It is too error-prone otherwise.
> 
> Alternatively, looking at your patch, I don't think we need to subclass
> RefCounted at all as it doesn't seem we ever share ownership of such
> objects? If so, I would just not subclass RefCounted and use makeUnique /
> unique_ptr.
The copy constructor copies a reference.  It would be an unnecessary copy if it were a unique_ptr.
Comment 13 Alex Christensen 2021-09-21 16:22:26 PDT
Created attachment 438882 [details]
Patch
Comment 14 EWS 2021-09-21 17:27:31 PDT
Committed r282853 (241984@main): <https://commits.webkit.org/241984@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 438882 [details].