Bug 298744
| Summary: | Poor performance of [class] attribute selector | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Victor Lin <victor.lin> |
| Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | ahmad.saleem792, koivisto, m_dubet |
| Priority: | P2 | ||
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Victor Lin
Safari has poor performance on a stylesheet with thousands of [class] selectors.
Demo: https://jsfiddle.net/8mturha4/2/ (click the button; color changes in chrome, browser freezes in safari)
Profiling showed that the slowdown was in style invalidation (https://github.com/WebKit/WebKit/blob/ed9dd0741be2f62a9c946cc4908a013ec3db2335/Source/WebCore/style/AttributeChangeInvalidation.cpp#L72)
and this makeJoining call as the hotspot: https://github.com/WebKit/WebKit/blob/ed9dd0741be2f62a9c946cc4908a013ec3db2335/Source/WebCore/style/StyleScopeRuleSets.cpp#L346
We were using `[class]` as a way of boosting style precedence without having to repeat classnames. Perhaps the attribute invalidation selector logic could be optimized when a rule is purely testing the presence of an attribute, rather than the value?
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Antti Koivisto
This was fixed in https://commits.webkit.org/299018@main
*** This bug has been marked as a duplicate of bug 297591 ***