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

stylo: Improve restyling performance #12563

Merged
merged 10 commits into from Jul 27, 2016
Merged

stylo: Improve restyling performance #12563

merged 10 commits into from Jul 27, 2016

Conversation

@emilio
Copy link
Member

emilio commented Jul 23, 2016

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes do not require tests because no geckolib tests yet.

This change is Reviewable

@highfive
Copy link

highfive commented Jul 23, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/traversal.rs, components/style/sequential.rs, components/style/parallel.rs
@highfive
Copy link

highfive commented Jul 23, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style code, but no tests are modified. Please consider adding a test!
@emilio emilio force-pushed the emilio:stylo branch from 99198fa to 31131d6 Jul 23, 2016
@emilio
Copy link
Member Author

emilio commented Jul 23, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

Trying commit 31131d6 with merge c8e2fc8...

bors-servo added a commit that referenced this pull request Jul 23, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

💔 Test failed - mac-rel-css

@emilio
Copy link
Member Author

emilio commented Jul 23, 2016

I think these are servo incremental layout bugs uncovered by this patch (since right now we relayout way less than before), I'll verify this during the weekend.

@emilio
Copy link
Member Author

emilio commented Jul 23, 2016

What a better way to know?

@bors-servo: try

@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

Trying commit 99cb3ae with merge 6368273...

bors-servo added a commit that referenced this pull request Jul 23, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

💔 Test failed - mac-rel-css

@emilio emilio force-pushed the emilio:stylo branch from 99cb3ae to 1b9fcb0 Jul 23, 2016
@emilio emilio force-pushed the emilio:stylo branch from 1b9fcb0 to 01a8d96 Jul 23, 2016
@emilio
Copy link
Member Author

emilio commented Jul 23, 2016

@bors-servo: try

It seems servo relies on bubbling up the widths for layout, so it needs to traverse the whole DOM.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

Trying commit 01a8d96 with merge 37d2095...

bors-servo added a commit that referenced this pull request Jul 23, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@emilio emilio force-pushed the emilio:stylo branch 2 times, most recently from 20783ef to 956f09e Jul 23, 2016
@emilio
Copy link
Member Author

emilio commented Jul 23, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

Trying commit 956f09e with merge 0fcd30c...

bors-servo added a commit that referenced this pull request Jul 23, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 23, 2016

💔 Test failed - linux-dev

@bholley
Copy link
Contributor

bholley commented Jul 27, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

Testing commit f6043a2 with merge 8d1ddba...

bors-servo added a commit that referenced this pull request Jul 27, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

💔 Test failed - linux-rel

@bholley
Copy link
Contributor

bholley commented Jul 27, 2016

@bholley
Copy link
Contributor

bholley commented Jul 27, 2016

Tests with unexpected results:
Unexpected subtest result in /html/browsers/history/the-history-interface/001.html:
│ FAIL [expected PASS] pushState should not actually load the new URL
│ → assert_true: expected true got undefined

│ tests12/<@http://web-platform.test:8000/html/browsers/history/the-history-interface/001.html:283:13
│ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1402:20
│ test@http://web-platform.test:8000/resources/testharness.js:500:9
└ tests12@http://web-platform.test:8000/html/browsers/history/the-history-interface/001.html:282:9

#12580 #12625

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

Previous build results for android, arm32, arm64, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

💔 Test failed - linux-rel

@emilio
Copy link
Member Author

emilio commented Jul 27, 2016

@bors-servo: retry

@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

Testing commit f6043a2 with merge 944d371...

bors-servo added a commit that referenced this pull request Jul 27, 2016
stylo: Improve restyling performance

This commit adds hooks to the Servo style traversal to avoid traversing all the
DOM for every restyle. Additionally it changes the behavior of the dirty flag to
be propagated top down, to prevent extra overhead when an element is dirtied.

This commit doesn't aim to change the behavior on Servo just yet, since Servo does extra job when dirtying the node related with DOM revision counters that might be necessary.

CC @asajeffrey for the DOM revision counters stuff. When a node is dirty, do all its descendants really need to increment the revision counter, or is this an unintended effect? My intuition is that this is hurting performance quite a lot for servo.

r? @bholley

<!-- Please describe your changes on the following line: -->

---
<!-- 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

<!-- Either: -->
- [x] These changes do not require tests because no geckolib tests yet.

<!-- 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/12563)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 27, 2016

@bors-servo bors-servo merged commit f6043a2 into servo:master Jul 27, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@emilio emilio mentioned this pull request Jul 28, 2016
4 of 4 tasks complete
emilio added a commit to emilio/servo that referenced this pull request Aug 5, 2016
…nimation frames.

The script tick ends up only processing JS callbacks related to animation
frames, so CSS transitions/animations end up not working as expected.

This could have accidentally worked before servo#12563 because we over-restyled, but
now this is no longer the case.

Other possible way to do it is making a layout reflow with RAF handle CSS
animations/transitions too, but that may not work if the reflow ends up being
suppressed (that could very well be the case), and we'd need to handle a lot
more state in the document, so this solution (assuming it doesn't break try)
seems a bit less flacky.

Fixes servo#12749.
bors-servo added a commit that referenced this pull request Aug 5, 2016
compositor: Send animation ticks to layout even if there are script animation frames.

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #12749 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

The script tick ends up only processing JS callbacks related to animation
frames, so CSS transitions/animations end up not working as expected.

This could have accidentally worked before #12563 because we over-restyled, but
now this is no longer the case.

Other possible way to do it is making a layout reflow with RAF handle CSS
animations/transitions too, but that may not work if the reflow ends up being
suppressed (that could very well be the case), and we'd need to handle a lot
more state in the document, so this solution (assuming it doesn't break try)
seems a bit less flacky.

Missing a test, will add one soon. Fixes #12749.
bors-servo added a commit that referenced this pull request Aug 8, 2016
compositor: Send animation ticks to layout even if there are script animation frames.

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #12749 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

The script tick ends up only processing JS callbacks related to animation
frames, so CSS transitions/animations end up not working as expected.

This could have accidentally worked before #12563 because we over-restyled, but
now this is no longer the case.

Other possible way to do it is making a layout reflow with RAF handle CSS
animations/transitions too, but that may not work if the reflow ends up being
suppressed (that could very well be the case), and we'd need to handle a lot
more state in the document, so this solution (assuming it doesn't break try)
seems a bit less flacky.

Missing a test, will add one soon. Fixes #12749.

<!-- 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/12751)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.