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

Flattening refactor #1942

Merged
merged 2 commits into from Oct 26, 2017
Merged

Flattening refactor #1942

merged 2 commits into from Oct 26, 2017

Conversation

@kvark
Copy link
Member

kvark commented Oct 25, 2017

Warning: this would be difficult to review because of large amounts of moved code. Sorry!

Changes:
~~ - (nit) renamed FlattenContext -> Roller to give it a little more flavor, given the FrameContext defined in the same file.~~

  • detached flattening from resource cache by wrapping the font instance map in an Arc and passing it to the FlattenContext directly
  • (major) moved all the flattening logic from FrameContext into FlattenContext (oh, names...), which appears to have more sense to me architecturally, and allows to reduce the number of parameters we pass to flatten functions (see line count difference)

This is one more step towards moving the scene building in a separate thread. Biggest things left are:

  • clip-scroll tree
  • scene

cc @glennw @nical


This change is Reviewable

@kvark kvark force-pushed the kvark:flatten branch from 621c239 to 5ab7e20 Oct 25, 2017
@glennw
Copy link
Member

glennw commented Oct 25, 2017

Do we need a gecko try for this, or does it involve no functional changes?

@kvark
Copy link
Member Author

kvark commented Oct 25, 2017

No functional change is expected here. I believe local tests are sufficient.

@glennw
Copy link
Member

glennw commented Oct 25, 2017

Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@glennw
Copy link
Member

glennw commented Oct 25, 2017

@kvark This looks fine to me.

It will be interesting to see if reading the RWLock on each text run ever shows up in a profile (I don't think it will).

I'm not super keen on the Roller name - it doesn't seem very descriptive to me. But naming is hard - we can always change the name later on if we decide to, so that doesn't need to block this landing. Could we add a description in the source code of what it means though?

I'll leave it to you if you want to do a gecko try run, this seems fairly straightforward though, so r=me.

Thanks!

@glennw
Copy link
Member

glennw commented Oct 25, 2017

@kvark I guess having FontInstanceMap as a RWLock can introduce race conditions if someone updates the font instances while a DL is processing (e.g. some text runs may end up not finding the font instance, and other ones in the same DL will).

I don't think it's a big deal - since it can only happen if you're using the API incorrectly.

If we did ever run into perf issues reading the RW lock, or wanted to avoid races, we could probably instead clone the FontInstanceMap once at the start of each job.

@kvark
Copy link
Member Author

kvark commented Oct 25, 2017

@glennw thanks for feedback!

I'm not super keen on the Roller name

I'll rename it back.

It will be interesting to see if reading the RWLock on each text run ever shows up in a profile (I don't think it will).

Yes. Not sure how else we can provide this font instance data. RwLock was sort of a last resort for me.

I guess having FontInstanceMap as a RWLock can introduce race conditions if someone updates the font instances while a DL is processing (e.g. some text runs may end up not finding the font instance, and other ones in the same DL will).

My understanding was that it's going to be RenderBackend responsibility to ensure that font instance updates and removals (but not additions) are deferred until all pending scene builds (that rely on the older font instances) are done.

@kvark kvark force-pushed the kvark:flatten branch from 5ab7e20 to 7269276 Oct 25, 2017
@glennw
Copy link
Member

glennw commented Oct 25, 2017

@bors-servo r+ 🚀

@bors-servo
Copy link
Contributor

bors-servo commented Oct 25, 2017

📌 Commit 7269276 has been approved by glennw

@nical
Copy link
Collaborator

nical commented Oct 25, 2017

My understanding was that it's going to be RenderBackend responsibility to ensure that font instance updates and removals (but not additions) are deferred until all pending scene builds (that rely on the older font instances) are done.

Yeah we need to pipeline resource updates with scene building (any resource update coming after a scene must wait for that scene to be built) otherwise frame consistency would break. It should be fairly easy to do.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2017

Testing commit 7269276 with merge 844779d...

bors-servo added a commit that referenced this pull request Oct 26, 2017
Flattening refactor

Warning: this would be difficult to review because of large amounts of moved code. Sorry!

Changes:
~~  - (nit) renamed `FlattenContext` -> `Roller` to give it a little more flavor, given the `FrameContext` defined in the same file.~~
  - detached flattening from resource cache by wrapping the font instance map in an `Arc` and passing it to the `FlattenContext` directly
  - (major) moved all the flattening logic from `FrameContext` into `FlattenContext` (oh, names...), which appears to have more sense to me architecturally, and allows to reduce the number of parameters we pass to flatten functions (see line count difference)

This is one more step towards moving the scene building in a separate thread. Biggest things left are:
  - clip-scroll tree
  - scene

cc @glennw @nical

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

bors-servo commented Oct 26, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: glennw
Pushing 844779d to master...

@bors-servo bors-servo merged commit 7269276 into servo:master Oct 26, 2017
3 of 4 checks passed
3 of 4 checks passed
code-review/reviewable 1 file left (glennw)
Details
Taskcluster (pull_request) TaskGroup: success
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@staktrace
Copy link
Contributor

staktrace commented Oct 26, 2017

@kvark The latest WR update try push is showing a bunch of crashes, this PR is the most likely culprit in the regression range. I'm doing a try push to confirm but you might want a head start on seeing if there's any obvious problem. Details at bug 1410893 comment 9 onwards.

@kvark kvark deleted the kvark:flatten branch Oct 26, 2017
@kvark
Copy link
Member Author

kvark commented Oct 26, 2017

@staktrace thanks for the heads up! this is unexpected. Looking now...

bors-servo added a commit that referenced this pull request Oct 26, 2017
Followup fix to update_image_template

Follow-up to  #1942, addressing #1942 (comment)
r? @staktrace

<!-- 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/1948)
<!-- 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.