Skip to content

Conversation

@upsuper
Copy link
Contributor

@upsuper upsuper commented Jan 16, 2018

This is the "better way" I mentioned in #19774, which seems to actually improve the score of dromaeo_css on talos.


This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/selectors/matching.rs, components/style/invalidation/element/invalidator.rs
  • @canaltinova: components/style/invalidation/element/invalidator.rs
  • @emilio: components/style/invalidation/element/invalidator.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 16, 2018
@highfive
Copy link

warning Warning warning

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

@upsuper
Copy link
Contributor Author

upsuper commented Jan 16, 2018

r? @emilio @SimonSapin

@highfive highfive assigned emilio and unassigned KiChjang Jan 16, 2018
@upsuper
Copy link
Contributor Author

upsuper commented Jan 16, 2018

See comparison: https://treeherder.mozilla.org/perf.html#/compare?originalProject=mozilla-central&newProject=try&newRevision=8602ad9e9b61&framework=1&selectedTimeRange=172800

It shows 3% improvement for dromaeo_css on Linux and macOS. It doesn't show a certain result for Windows platform on its overall score, but it still shows significant improvement on subtest dojo.html and prototype.html.

Mysteriously, subtest ext.html, mootools.html, and yui.html shows significant regression on win64, but those tests don't use qS or qSA at all... PGO is mysterious...

In addition, this change also improves performance on bug 1422522. On my machine, the time is pulled from ~2.6s down to ~2.2s, probably mostly benefits from the inlining of the common cases.

@upsuper
Copy link
Contributor Author

upsuper commented Jan 16, 2018

From that try run, it seems that we would almost close the gap for the regression of bug 1414789 with this patch.

@upsuper
Copy link
Contributor Author

upsuper commented Jan 16, 2018

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Looks good, as unfortunate as it is. r=me when you want.

F: FnMut(&E, ElementSelectorFlags),
{
let matches_hover_and_active_quirk =
matches_hover_and_active_quirk(&selector_iter, context, rightmost);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this could be moved below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because it wants the original selector_iter. Alternatively we can clone the iter at the beginning and pass it into the function later, but I don't think it's worth.

let matches_hover_and_active_quirk =
matches_hover_and_active_quirk(&selector_iter, context, rightmost);

// Handle some common cases first.
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit unfortunate that we need to do this indeed.

Mind leaving a comment like:

// TODO(emilio): It'd be nice to just get rid of this, if we make Talos happy / the generic case fast enough.

I've seen similar wins today just from enabling stylo-chrome and such (https://treeherder.mozilla.org/perf.html#/compare?originalProject=try&originalRevision=aea8893308877a9139af703db9d5abcc822dddd5&newProject=try&newRevision=e4667f74741b200ae5cc687ce7fb37697b7f394f&framework=1&showOnlyImportant=1). I'm not sure how you feel about landing this vs. waiting. Both look fine to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The big match needs dispatch anyway, and that may be less friendly to all the predicator and jump cache, so I think unrolling some common cases into a sequential if-chain is a reasonable optimization before rust compiler can do pto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And, it seems to me that commit is just from #19774 plus an #[inline(never)] on the helper function. I don't see how that's related to stylo-chrome.

@upsuper
Copy link
Contributor Author

upsuper commented Jan 16, 2018

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit d0fd922 has been approved by emilio

@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 Jan 16, 2018
@bors-servo
Copy link
Contributor

⌛ Testing commit d0fd922 with merge 525758e...

bors-servo pushed a commit that referenced this pull request Jan 16, 2018
Optimize selector matching for some common cases

This is the "better way" I mentioned in #19774, which seems to actually improve the score of dromaeo_css on talos.

<!-- 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/19781)
<!-- 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: emilio
Pushing 525758e to master...

@bors-servo bors-servo merged commit d0fd922 into servo:master Jan 16, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 16, 2018
@upsuper upsuper deleted the matching-opt branch January 16, 2018 23:47
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.

5 participants