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

Script paint worklets speculative evaluation #17810

Conversation

asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jul 20, 2017

This PR speculatively calls paint worklets during style, which increases the concurrency, since it increases the chance that the cache will have the right result in it when it comes to layout. The speculation is wasted effort if the size of the element has changed, but this is often not the case.



This change is Reviewable

@asajeffrey asajeffrey added A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/script Related to the script thread labels Jul 20, 2017
@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/traversal.rs, components/style/context.rs
  • @canaltinova: components/style/traversal.rs, components/style/context.rs
  • @KiChjang: components/script/dom/paintrenderingcontext2d.rs, components/script/dom/canvasrenderingcontext2d.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/dom/bindings/trace.rs and 4 more
  • @fitzgen: components/script/dom/paintrenderingcontext2d.rs, components/script/dom/canvasrenderingcontext2d.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/dom/bindings/trace.rs and 4 more
  • @emilio: components/layout/display_list_builder.rs, components/style/traversal.rs, components/style/context.rs, components/layout/context.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 20, 2017
@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@asajeffrey
Copy link
Member Author

This PR is dependent on #17634.

@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from 558002f to 5976728 Compare July 20, 2017 22:17
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17499) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jul 21, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from 5976728 to 372f159 Compare July 21, 2017 20:42
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17634) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jul 21, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from 372f159 to 5b61105 Compare July 24, 2017 19:53
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Jul 24, 2017
@asajeffrey
Copy link
Member Author

#17634 landed, so this PR is ready for review!

@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Jul 26, 2017
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17895) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jul 28, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from 31a00a3 to 016af1a Compare July 28, 2017 19:31
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Jul 28, 2017
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17892) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jul 28, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from 016af1a to ffd4c99 Compare July 28, 2017 20:39
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Jul 28, 2017
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 fine, just a question.

@@ -520,6 +522,8 @@ where
}
}

notify_paint_worklet(context, data);
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you want this outside of the if compute_self block? Do we really always need to paint it even if the style is the same?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Fixed.

@emilio
Copy link
Member

emilio commented Jul 28, 2017

Also, do you have any numbers on this?

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17910) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jul 29, 2017
@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from ffd4c99 to c512f6f Compare July 29, 2017 20:40
@asajeffrey
Copy link
Member Author

@emilio I'm afraid not, to get decent numbers we'd need a page with reasonably complex style/layout and a paint worklet. All the paint worklet demos are quite simple at the moment :/

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit c512f6f 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. S-needs-rebase There are merge conflict errors. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jul 29, 2017
@bors-servo
Copy link
Contributor

🔒 Merge conflict

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #17546) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added S-needs-rebase There are merge conflict errors. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jul 29, 2017
@bors-servo
Copy link
Contributor

🔒 Merge conflict

@asajeffrey asajeffrey force-pushed the script-paint-worklets-speculative-evaluation branch from c512f6f to 936dd3e Compare July 31, 2017 18:02
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 31, 2017
@asajeffrey asajeffrey removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jul 31, 2017
@asajeffrey
Copy link
Member Author

No actual numbers, but at least the cache is doing its job!

$ RUST_LOG=script::dom::paintworkletglobalscope ./mach run -d --pref=dom.worklet.enabled http://googlechrome.github.io/houdini-samples/
DEBUG:script::dom::paintworkletglobalscope: Creating paint worklet global scope for pipeline (0,2).
DEBUG:script::dom::paintworkletglobalscope: Registering paint image name ripple.
DEBUG:script::dom::paintworkletglobalscope: Registering definition ripple.
DEBUG:script::dom::paintworkletglobalscope: Creating paint worklet global scope for pipeline (0,2).
DEBUG:script::dom::paintworkletglobalscope: Registering paint image name ripple.
DEBUG:script::dom::paintworkletglobalscope: Registering definition ripple.
DEBUG:script::dom::paintworkletglobalscope: Creating paint worklet global scope for pipeline (0,2).
DEBUG:script::dom::paintworkletglobalscope: Registering paint image name ripple.
DEBUG:script::dom::paintworkletglobalscope: Registering definition ripple.
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(0,0) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache miss on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!
DEBUG:script::dom::paintworkletglobalscope: Invoking a paint callback ripple(300,300) at 1.
DEBUG:script::dom::paintworkletglobalscope: Invoking paint function ripple.
DEBUG:script::dom::paintworkletglobalscope: Cache hit on paint worklet ripple!

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit 936dd3e has been approved by emilio

@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 31, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 936dd3e with merge cf5602e...

bors-servo pushed a commit that referenced this pull request Jul 31, 2017
…valuation, r=emilio

Script paint worklets speculative evaluation

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

This PR speculatively calls paint worklets during style, which increases the concurrency, since it increases the chance that the cache will have the right result in it when it comes to layout. The speculation is wasted effort if the size of the element has changed, but this is often not the case.

---
<!-- 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 #17486 and #17369.
- [X] These changes do not require tests because it's a performance improvement

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/17810)
<!-- 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 cf5602e to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-content/script Related to the script thread
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paint worklets: speculatively draw a paint image
4 participants