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

Make the API transaction-based #1963

Merged
merged 3 commits into from Jan 10, 2018
Merged

Make the API transaction-based #1963

merged 3 commits into from Jan 10, 2018

Conversation

@nical
Copy link
Collaborator

nical commented Oct 30, 2017

The idea is to replace individual DocumentMsgs in the api messages by vectors of DocumentMsg to provide a way to express the constraint that several DocumentMsg must be handled atomically without any other message interleaving in between.
This also lets us avoid redundant work when we build transactions that contain several operations that would cause the frame and/or scene to be rebuilt.

At the API level, users create a Transaction object and accumulate commands like set_display_list, scroll or update_resources into it and only touch the RenderApi at the end when calling send_transaction.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented Oct 30, 2017

This is a work in progress, it's not too far from being ready but there are still a few unresolved TODOs in the code. For now I haven't removed the RenderApi methods that are in Transaction, so that we can hopefully first land this, update gecko and servo and then remove the deprecated APIs. Hopefully that should decouple the task of updating WebRender and moving to the new API.
Feedback very welcome.

cc @kvark @glennw

@glennw
Copy link
Member

glennw commented Oct 31, 2017

I haven't looked at this in super detail, but the general patch looks good - the bits I looked at so far make sense to me.

@nical nical force-pushed the nical:transaction branch 2 times, most recently from 242785c to 66b646e Oct 31, 2017
@kvark kvark self-requested a review Nov 6, 2017
@nical nical force-pushed the nical:transaction branch from 66b646e to 7356c81 Nov 6, 2017
@nical nical changed the title [WIP] Make the API transaction-based Make the API transaction-based Nov 6, 2017
@nical
Copy link
Collaborator Author

nical commented Nov 6, 2017

Gecko try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=9224869560da7e7c60097b52ba966c0c8c3a2195

The PR is in a good state to be reviewed now.

@kvark
kvark approved these changes Nov 6, 2017
/// The unique id for WR resource identification.
static NEXT_NAMESPACE_ID: AtomicUsize = ATOMIC_USIZE_INIT;

struct DocumentOp {

This comment has been minimized.

Copy link
@kvark

kvark Nov 6, 2017

Member

should be renamed to DocumentOps now

@@ -422,23 +444,22 @@ impl RenderBackend {
// rebuild of the frame!
if let Some(property_bindings) = property_bindings {
doc.scene.properties.set_properties(property_bindings);
doc.build_scene(&mut self.resource_cache);
op.build = true;

This comment has been minimized.

Copy link
@kvark

kvark Nov 6, 2017

Member

we should probably do the same for scroll & render events, instead of having and_render boolean

self.result_tx.send(msg).unwrap();
profile_counters.reset();

if !op.scroll {

This comment has been minimized.

Copy link
@kvark

kvark Nov 6, 2017

Member

hacky!

This comment has been minimized.

Copy link
@nical

nical Nov 6, 2017

Author Collaborator

Yeah, the whole RenderNotifier trait is kinda arbitrary and modelled around the previous control flow. It should really be a single method with parameters saying how much has changed (scroll, scene, frame, etc.).
I was trying to do this PR without making it a breaking change to make the wr update easier for once (and come back with a breaking cleanup once the APIs are not used anymore). But it'd be good to simplify the RenderNotifier API and avoid this kind of dance.

///
/// This mechanism ensures that:
/// - no other message can be interleaved between two commands that need to be applied together.
/// - no redundant work is performed if two commands in the same tranasction cause the scen or

This comment has been minimized.

Copy link
@kvark

kvark Nov 6, 2017

Member

"scen", "tranasction"

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2017

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

@glennw
Copy link
Member

glennw commented Nov 12, 2017

Needs a rebase.

@nical nical mentioned this pull request Nov 20, 2017
6 of 6 tasks complete
@glennw
Copy link
Member

glennw commented Nov 23, 2017

@nical Are you still working on this?

@nical
Copy link
Collaborator Author

nical commented Nov 23, 2017

I do plan to finish this but unless there we identify cases that we care about for Austin where this can help performance, it is not in the list of high priority items until the workweek.

@glennw
Copy link
Member

glennw commented Nov 28, 2017

Closing for now - let's re-open once we're ready to resume work on this.

@glennw glennw closed this Nov 28, 2017
@kvark
Copy link
Member

kvark commented Nov 28, 2017

@glennw I don't see much value in closing the issue if it's still to be worked on. Our goal for now is to have performance up, not close as many issues as we can.

@nical
Copy link
Collaborator Author

nical commented Jan 3, 2018

Resuming work on this (rebase in progress).

@nical nical reopened this Jan 3, 2018
@nical nical force-pushed the nical:transaction branch 2 times, most recently from f7e7ba6 to 1f1cfdf Jan 3, 2018
@kvark
Copy link
Member

kvark commented Jan 3, 2018

looking good so far 👍


Reviewed 7 of 7 files at r2.
Review status: 6 of 7 files reviewed at latest revision, 4 unresolved discussions.


webrender/src/render_backend.rs, line 488 at r2 (raw file):

                    op.render = true;
                } else {
                    // TODO(nical) - Eeeeeek! The previous code did the equivalent of this, but it doesn't

we need to clear up that semantics bit, it's inherited from long ago. perhaps, nop-scroll was used like a "wakeup" so now we can remove it since we have explicit wakeup


Comments from Reviewable

@nical
Copy link
Collaborator Author

nical commented Jan 3, 2018

I got the PR to build again but before merging I'd like to revive the gecko side as well and do some testing. I may move the resource updates in a separate array because they will likely need some special handling for the async scene building stuff.

@nical nical force-pushed the nical:transaction branch 2 times, most recently from 19b4c66 to 75cc81d Jan 5, 2018
@nical
Copy link
Collaborator Author

nical commented Jan 5, 2018

The PR is in a reviewable state now. There are some more cosmethic changes that would be nice to have (such as making SetDisplayList less of a uber-message, and make epochs truly up to the api user, but that can wait. There might be some reorg inside of the Transaction struct to help with the upcoming async scene building, but that should be doable without changing the API itself.

Next is deciding:

  • whether or not to keep the old API on the side. Personally I'd rather not but that's open for bikeshed.
  • whether to keep ResourceUpdateQueue. With a dedicated transaction object we can just merge the two, I don't feel strongly either way.

These can be decided later too.

@nical
Copy link
Collaborator Author

nical commented Jan 8, 2018

@kvark
Copy link
Member

kvark commented Jan 8, 2018

:lgtm:


Reviewed 4 of 4 files at r4.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


Comments from Reviewable

DocumentMsg::GenerateFrame(property_bindings) => {
profile_scope!("GenerateFrame");
DocumentMsg::UpdateDynamicProperties(property_bindings) => {
// Ideally, when there are property bindings present,

This comment has been minimized.

Copy link
@glennw

glennw Jan 8, 2018

Member

This comment and code is obsolete, as of #2043. We shouldn't need to rebuild the scene when the property bindings change.

@nical nical force-pushed the nical:transaction branch from 75cc81d to bc6e315 Jan 9, 2018
@glennw
glennw approved these changes Jan 9, 2018
@glennw
Copy link
Member

glennw commented Jan 9, 2018

Looks good to me! I'll delegate r+ and leave it to nical to determine if we need a gecko try run for this change, and merge when ready (unless @kvark has any remaining questions).

@bors-servo delegate+

@bors-servo
Copy link
Contributor

bors-servo commented Jan 9, 2018

✌️ @nical can now approve this pull request

@nical nical force-pushed the nical:transaction branch from bc6e315 to 1a53083 Jan 10, 2018
@nical
Copy link
Collaborator Author

nical commented Jan 10, 2018

I had some test timeouts which ended up me messing up the gecko side integration. Works now!

@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2018

📌 Commit 1a53083 has been approved by nical

@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2018

Testing commit 1a53083 with merge 722e8b1...

bors-servo added a commit that referenced this pull request Jan 10, 2018
Make the API transaction-based

The idea is to replace individual `DocumentMsg`s in the api messages by vectors of `DocumentMsg` to provide a way to express the constraint that several DocumentMsg must be handled atomically without any other message interleaving in between.
This also lets us avoid redundant work when we build transactions that contain several operations that would cause the frame and/or scene to be rebuilt.

At the API level, users create a `Transaction` object and accumulate commands like `set_display_list`, `scroll` or `update_resources` into it and only touch the `RenderApi` at the end when calling `send_transaction`.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1963)
<!-- Reviewable:end -->
@staktrace
Copy link
Contributor

staktrace commented Jan 10, 2018

@nical Please post the gecko integration patch to bug 1428766 so I can include it in my testing try pushes after this merges. Thanks!

@nical
Copy link
Collaborator Author

nical commented Jan 10, 2018

@staktrace I tried to make this PR non-breaking so that we can (hopefully) land the integration patches after the wr update (or that's the theory/intent anyway).
After we have integrated the new APIs with gecko I'll remove the old APIs here.

@staktrace
Copy link
Contributor

staktrace commented Jan 10, 2018

Ah cool, that works too :)

@bors-servo
Copy link
Contributor

bors-servo commented Jan 10, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nical
Pushing 722e8b1 to master...

@bors-servo bors-servo merged commit 1a53083 into servo:master Jan 10, 2018
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 2 files, 5 discussions left (glennw, kvark, nical)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@nical nical deleted the nical:transaction branch Jan 10, 2018
bors-servo added a commit that referenced this pull request Jan 16, 2018
Move code to the new transaction API.

Cleaning up after #1963.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2298)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Jan 18, 2018
Move code to the new transaction API.

Cleaning up after #1963.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2298)
<!-- 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

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