Bug 226946 - Lazily compute SecurityOrigin::m_isPotentiallyTrustworthy for performance
Summary: Lazily compute SecurityOrigin::m_isPotentiallyTrustworthy for performance
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-11 16:22 PDT by Chris Dumez
Modified: 2021-06-11 19:37 PDT (History)
5 users (show)

See Also:


Attachments
Patch (3.42 KB, patch)
2021-06-11 16:24 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (3.42 KB, patch)
2021-06-11 16:50 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (3.43 KB, patch)
2021-06-11 16:51 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (3.45 KB, patch)
2021-06-11 17:13 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-06-11 16:22:24 PDT
We currently initialize m_isPotentiallyTrustworthy in the SecurityOrigin constructor. However, it is a bit expensive to compute and shows on profiles, and we often don't actually use this data member. As a result, this patch makes it so that SecurityOrigin::m_isPotentiallyTrustworthy gets computed lazily.
Comment 1 Chris Dumez 2021-06-11 16:24:04 PDT
Created attachment 431240 [details]
Patch
Comment 2 Alex Christensen 2021-06-11 16:26:07 PDT
Comment on attachment 431240 [details]
Patch

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

> Source/WebCore/page/SecurityOrigin.cpp:496
> +    return m_isPotentiallyTrustworthy;

return *m_isPotentiallyTrustworthy;

> Source/WebCore/page/SecurityOrigin.h:246
> +    std::optional<bool> m_isPotentiallyTrustworthy;

This uses more memory.  To offset this, could you make some of the surrounding booleans bit fields?
Comment 3 Chris Dumez 2021-06-11 16:49:59 PDT
(In reply to Alex Christensen from comment #2)
> Comment on attachment 431240 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=431240&action=review
> 
> > Source/WebCore/page/SecurityOrigin.cpp:496
> > +    return m_isPotentiallyTrustworthy;
> 
> return *m_isPotentiallyTrustworthy;

Indeed, oops.

> 
> > Source/WebCore/page/SecurityOrigin.h:246
> > +    std::optional<bool> m_isPotentiallyTrustworthy;
> 
> This uses more memory.  To offset this, could you make some of the
> surrounding booleans bit fields?

sizeof(SecurityOrigin) is 64 before and after my change so let's not?
Comment 4 Chris Dumez 2021-06-11 16:50:27 PDT
Created attachment 431242 [details]
Patch
Comment 5 Chris Dumez 2021-06-11 16:51:07 PDT
Created attachment 431243 [details]
Patch
Comment 6 Chris Dumez 2021-06-11 17:13:53 PDT
Created attachment 431245 [details]
Patch
Comment 7 EWS 2021-06-11 19:36:38 PDT
Committed r278806 (238763@main): <https://commits.webkit.org/238763@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 431245 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-11 19:37:17 PDT
<rdar://problem/79228666>