Bug 205774 - [WebCore] Shrink sizeof(RuleFeature)
Summary: [WebCore] Shrink sizeof(RuleFeature)
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-01-04 19:08 PST by Yusuke Suzuki
Modified: 2020-01-06 11:00 PST (History)
6 users (show)

See Also:


Attachments
Patch (8.70 KB, patch)
2020-01-04 19:11 PST, Yusuke Suzuki
dino: 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-01-04 19:08:19 PST
[WebCore] Shrink sizeof(RuleFeature)
Comment 1 Yusuke Suzuki 2020-01-04 19:11:59 PST
Created attachment 386779 [details]
Patch
Comment 2 Yusuke Suzuki 2020-01-04 19:15:22 PST
Comment on attachment 386779 [details]
Patch

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

> Source/WebCore/style/RuleFeature.h:42
>  struct RuleFeature {

I'm still thinking about further reduction of size.
1. matchElement is used in some specific places. Most of RuleFeature does not have this.
2. selectorListIndex is only used for CSSJIT. I think we could remove it, move it to other place, or recalculate it.
3. We could use PackedRefPtr<const StyleRule>, which is 6 byte.
If we do that, we could make RuleFeature,

struct RuleFeature {
    PackedRefPtr<const StyleRule> styleRule;
    uint16_t selectorIndex;
}; 

Then, sizeof(RuleFeature) is 8 bytes. For now, I postpone this.
Comment 3 Antti Koivisto 2020-01-05 14:55:53 PST
Comment on attachment 386779 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        We noticed that Vector<RuleFeature> is frequently allocated and kept. While sizeof(RuleFeature) is 32,

What sort of memory usage did you see here in the worst cases?
Comment 4 Yusuke Suzuki 2020-01-06 10:56:11 PST
Comment on attachment 386779 [details]
Patch

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

>> Source/WebCore/ChangeLog:8
>> +        We noticed that Vector<RuleFeature> is frequently allocated and kept. While sizeof(RuleFeature) is 32,
> 
> What sort of memory usage did you see here in the worst cases?

In Gmail, it is using 100KB + 56KB + ...
Comment 5 Yusuke Suzuki 2020-01-06 10:59:43 PST
Committed r254065: <https://trac.webkit.org/changeset/254065>
Comment 6 Radar WebKit Bug Importer 2020-01-06 11:00:32 PST
<rdar://problem/58347222>