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
Rewrite the style sharing candidate cache #12668
Conversation
Heads up! This PR modifies the following files:
|
@bors-servo: try |
[wip] Rewrite the style sharing candidate cache <!-- Please describe your changes on the following line: --> See the first commit's description for a bit of background. I'm making the PR in this state just to verify against try I've handled all cases of possibly incorrect sharing and, if not, fix it. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12534 <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
💔 Test failed - linux-rel |
|
Hah! Funnily enough, that test fails because of (the lack of) emilio/rust-selectors@4c43337, bug that is in current rust selectors. @bors-servo: try |
[wip] Rewrite the style sharing candidate cache <!-- Please describe your changes on the following line: --> See the first commit's description for a bit of background. I'm making the PR in this state just to verify against try I've handled all cases of possibly incorrect sharing and, if not, fix it. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12534 <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12668) <!-- Reviewable:end -->
let shareable_element = match node.as_element() { | ||
Some(element) => { | ||
if opts::get().style_sharing_stats { |
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.
It may be faster to just do the add unconditionally than to take a lock to check the option.
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.
opts
is not the same as prefs
, and opts::get()
is just getting a lazy-static, not a RWLock
as with the preferences.
💥 Test timed out |
@bors-servo: retry |
[wip] Rewrite the style sharing candidate cache <!-- Please describe your changes on the following line: --> See the first commit's description for a bit of background. I'm making the PR in this state just to verify against try I've handled all cases of possibly incorrect sharing and, if not, fix it. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12534 <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12668) <!-- Reviewable:end -->
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
Yay! r? @pcwalton (still some cleanup needed, but should be good enough to get it reviewed). |
debug!("Stylist stats:"); | ||
debug!(" - Got {} sibling-affecting selectors", | ||
self.sibling_affecting_selectors.len()); | ||
debug!(" - Got {} non-commong-style-attribute-affecting selectors", |
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.
typo: "commong" -> "common"
This look good cc @emilio |
cool, can I r=you when I clean this up? (and the relevant selectors pr lands) |
I'd like to take one final look over it after you clean it up, but yeah, basically. |
Redesign the style sharing API. See servo/servo#12668 for context. r? @SimonSapin <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-selectors/93) <!-- Reviewable:end -->
@bors-servo: try |
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
fn have_same_class<E: TElement>(element: &E, candidate: &E) -> bool { | ||
// XXX Efficiency here, I'm only validating ideas. | ||
let mut first = vec![]; | ||
let mut second = vec![]; |
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.
These could be sets to be more accurate (fewer misses). If on the other hand we don’t mind being conservative (more misses) comparing the string values of class
attributes might be slightly faster than building these vecs.
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.
Sets or sorted vectors.
Looks good to me. @pcwalton Could you have that last look? This is upgrading to an already-released version of selector that has breaking changes, so it blocks using in Servo further breaking changes to selectors. (Version numbers don’t branch easily.) |
r=me when rebased. Awesome! |
The style candidate cache had regressed a few times (see servo#12534), and my intuition is that being able to disable all style sharing with a single rule in the page is really unfortunate. This commit redesigns the style sharing cache in order to be a optimistic cache, but then reject candidates if they match different sibling-affecting selectors in the page, for example. So far the numbers have improved, but not so much as I'd wanted (~10%/20% of non-incremental restyling time in general). The current implementation is really dumb though (we recompute and re-match a lot of stuff), so we should be able to optimise it quite a bit. I have different ideas for improving it (that may or may not work), apart of the low-hanging fruit like don't re-matching candidates all the time but I have to measure the real impact. Also, I need to verify it against try.
Haven't measured a lot, will do tomorrow, but I want a test run.
This was the underlying cause of the restyle_hints_state.html failure. It was uncovered only when fixing the HAS_EDGE_CHILD_SELECTOR flags because this was the series of events happening. * <script> starts executing. * All the restyle hint processing takes place. * <script> ends executing, gets appended to the body (I think this is also a bug). * <body> receives children_changed notification, with an Append mutation. * <body> had the HAS_EDGE_CHILD_SELECTOR flag, so due to its bogus value, it restyled the whole tree after <body>, fixing any mishandling of restyle hints.
…th children_changed.
@bors-servo: r=SimonSapin,pcwalton
|
📌 Commit a46f0c3 has been approved by |
Rewrite the style sharing candidate cache <!-- Please describe your changes on the following line: --> See the first commit's description for a bit of background. I'm making the PR in this state just to verify against try I've handled all cases of possibly incorrect sharing and, if not, fix it. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12534 <!-- Either: --> - [x] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/12668) <!-- Reviewable:end -->
💔 Test failed - linux-rel |
@bors-servo: retry That was my fault, I was investigating WebGL tests failures in the build On 08/17/2016 02:54 PM, bors-servo wrote:
|
⚡ Previous build results for arm32, arm64, linux-dev, mac-dev-unit, mac-rel-css, windows-dev are reusable. Rebuilding only linux-rel, mac-rel-wpt... |
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
See the first commit's description for a bit of background. I'm making the PR in this state just to verify against try I've handled all cases of possibly incorrect sharing and, if not, fix it.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is