New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style: Don't cache styles that got a cache hit on the second pass. #18497
Conversation
This avoids doing wasted work, at least in the recascade case, and pretty likely in the other as well.
Heads up! This PR modifies the following files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
components/style/traversal.rs
Outdated
context.thread_local | ||
.sharing_cache | ||
.insert_if_possible( | ||
if !new_styles.primary.0.reused_via_rule_node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should do this check inside insert_if_possible
instead?
Nice, I like that. @bors-servo r=heycam |
📌 Commit 158aa0f has been approved by |
style: Don't cache styles that got a cache hit on the second pass. This avoids doing wasted work, at least in the recascade case, and pretty likely in the other as well. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18497) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
It's easy to construct examples where not inserting in those cases causes performance to get worse (for example, any long list of siblings that match the same selectors while having some non-effectual differences in LocalName/Class/Id/etc). And the LRU nature of the cache already does the right thing of pruning non-useful entries. Fixing this causes several hundred more sharing hits on wikipedia. MozReview-Commit-ID: L7W8vcMnHaq
This is a great Improvement for the CascadeOnly case, but less obviously so for MatchAndCascade. I don't think the savings of fewer cache insertions is worth the potential decrease in sharing. Opened #18532 to fix this. |
Undo #18497 in the MatchAndCascade case It's easy to construct examples where not inserting in those cases causes performance to get worse (for example, any long list of siblings that match the same selectors while having some non-effectual differences in LocalName/Class/Id/etc). And the LRU nature of the cache already does the right thing of pruning non-useful entries. Fixing this causes several hundred more sharing hits on wikipedia. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18532) <!-- Reviewable:end -->
It's easy to construct examples where not inserting in those cases causes performance to get worse (for example, any long list of siblings that match the same selectors while having some non-effectual differences in LocalName/Class/Id/etc). And the LRU nature of the cache already does the right thing of pruning non-useful entries. Fixing this causes several hundred more sharing hits on wikipedia. MozReview-Commit-ID: L7W8vcMnHaq
This avoids doing wasted work, at least in the recascade case, and pretty likely
in the other as well.
This change is