Skip to content
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

Merged
merged 3 commits into from Sep 14, 2017

Conversation

emilio
Copy link
Member

@emilio emilio commented Sep 14, 2017

This avoids doing wasted work, at least in the recascade case, and pretty likely
in the other as well.


This change is Reviewable

This avoids doing wasted work, at least in the recascade case, and pretty likely
in the other as well.
@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/sharing/mod.rs, components/style/traversal.rs
  • @canaltinova: components/style/sharing/mod.rs, components/style/traversal.rs

@highfive
Copy link

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 14, 2017
@emilio
Copy link
Member Author

emilio commented Sep 14, 2017

r? @heycam or @bholley

@highfive highfive assigned heycam and unassigned mbrubeck Sep 14, 2017
Copy link
Contributor

@heycam heycam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

context.thread_local
.sharing_cache
.insert_if_possible(
if !new_styles.primary.0.reused_via_rule_node {
Copy link
Contributor

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?

@emilio
Copy link
Member Author

emilio commented Sep 14, 2017

Nice, I like that.

@bors-servo r=heycam

@bors-servo
Copy link
Contributor

📌 Commit 158aa0f has been approved by heycam

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Sep 14, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 158aa0f with merge 988728e...

bors-servo pushed a commit that referenced this pull request Sep 14, 2017
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 -->
@bors-servo
Copy link
Contributor

☀️ 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
Approved by: heycam
Pushing 988728e to master...

@bors-servo bors-servo merged commit 158aa0f into servo:master Sep 14, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Sep 14, 2017
bholley added a commit to bholley/servo that referenced this pull request Sep 16, 2017
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
@bholley
Copy link
Contributor

bholley commented Sep 16, 2017

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.

bors-servo pushed a commit that referenced this pull request Sep 16, 2017
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 -->
@emilio emilio deleted the no-cache-if-cached branch September 16, 2017 13:06
avadacatavra pushed a commit to avadacatavra/servo that referenced this pull request Oct 17, 2017
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants