| Summary: | Wasted vector capacity in MatchedDeclarationsCache::MatchResult | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Simon Fraser (smfr) <simon.fraser> | ||||
| Component: | CSS | Assignee: | Simon Fraser (smfr) <simon.fraser> | ||||
| Status: | RESOLVED DUPLICATE | ||||||
| Severity: | Normal | CC: | darin, jonlee, koivisto, simon.fraser, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | Safari Technology Preview | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=224313 | ||||||
| Attachments: |
|
||||||
|
Description
Simon Fraser (smfr)
2021-04-03 12:48:12 PDT
Created attachment 425203 [details]
Patch
Comment on attachment 425203 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425203&action=review > Source/WebCore/style/ElementRuleCollector.cpp:602 > + m_result.userAgentDeclarations.shrinkToFit(); > + m_result.userDeclarations.shrinkToFit(); > + m_result.authorDeclarations.shrinkToFit(); Great to solve this: I don’t fully understand the choice of putting it here. Presumably the reason we shrink these is that we are keeping these around for a while. Also, why don’t we need this when matchUARules is called directly? It seems the place we want these calls are when these vectors go from being temporary things to being long-lived, and, to me, the end of this function is not obviously that place. That place is:
m_entries.add(hash, Entry { matchResult, RenderStyle::clonePtr(style), RenderStyle::clonePtr(parentStyle) });
So we could have Entry construct compacted vectors.
(In reply to Simon Fraser (smfr) from comment #4) > That place is: > m_entries.add(hash, Entry { matchResult, RenderStyle::clonePtr(style), > RenderStyle::clonePtr(parentStyle) }); > > So we could have Entry construct compacted vectors. Yes, or make a ElementRuleCollector function that does allthe shrinkToFit calls and call it there. It seems safe to do a shrinkToFit on a const object. Maybe just add MatchResult::shrinkToFit and call it before creating the cache entry? In most cases MatchResults are temporaries so any work to shrink-to-fit is wasted. *** This bug has been marked as a duplicate of bug 224313 *** |