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

Use rayon to drive parallel layout and styling. #13641

Merged
merged 2 commits into from Nov 14, 2016
Merged

Conversation

@emilio
Copy link
Member

emilio commented Oct 7, 2016

The current work queue had a really annoying constraint: The size of the node had to be the size of the work unit data.

This makes it impractical for the new restyling model where we plan to pass down a bunch of data.

Rayon by default makes you wait for the result of the work unit, which makes it impractical for the current model (it's mostly sequential).

I added an API to rayon that allows us to push work to the queue without waiting (https://github.com/nikomatsakis/rayon/pull/103).

This still needs some work (for example, we're loosing the memory reporting functionality), but I wanted feedback on this.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Oct 7, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/Cargo.toml, components/style/lib.rs, components/style/parallel.rs, components/style/workqueue.rs, components/style/thread_state.rs
@highfive
Copy link

highfive commented Oct 7, 2016

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify style and layout code, but no tests are modified. Please consider adding a test!
@emilio
Copy link
Member Author

emilio commented Oct 7, 2016

@pcwalton, could you take a look at this and see if it makes sense to you?

Also, cc @bholley, @SimonSapin, and @Manishearth.

}
}

if i > SPINS_UNTIL_BACKOFF {

This comment has been minimized.

Copy link
@larsbergstrom

larsbergstrom Oct 7, 2016

Contributor

I'd like to see benchmarks of Rayon against our threadpool, as a lot of the backoff stuff was pretty highly tuned for the work item sizes of style and layout. These sorts of things are really easy to kill performance on small-sized work items if you move to locks/condvars/signals/etc.

This comment has been minimized.

Copy link
@emilio

emilio Oct 7, 2016

Author Member

Fair enough, I'll try to get some numbers.

This comment has been minimized.

Copy link
@emilio

emilio Oct 7, 2016

Author Member

After spending a few minutes studying Servo profiler dumps, I can't really draw a strong conclusion about this. Sometimes slower, sometimes faster, but always on the same order...


if self.should_record_thread_ids() {
flow::mut_base(flow).thread_id = proxy.worker_index();
// flow::mut_base(flow).thread_id = proxy.worker_index();

This comment has been minimized.

Copy link
@larsbergstrom

larsbergstrom Oct 7, 2016

Contributor

Do we no longer use this?

This comment has been minimized.

Copy link
@emilio

emilio Oct 7, 2016

Author Member

That was for the layout tinting debug mode, I'm not sure it still works now.

@aneeshusa
Copy link
Member

aneeshusa commented Oct 7, 2016

FYI, I think I only check for all-uppercase WIP/TODO in homu: servo/homu@1187df0. Might want to file an issue for having it work with lowercase as well.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 8, 2016

I've been wanting to do this for quite a while! This is great! It's always nice when we can move over to community solutions.

I second wanting to get solid numbers on this. If you can profile a few pages and make sure our parallel gains are the same as before (check ARM too), then I'm cool with it.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 13, 2016

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

@emilio emilio force-pushed the emilio:rayon-style branch 2 times, most recently from 6e393f2 to 83bc2f9 Oct 20, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Oct 20, 2016

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

@emilio emilio force-pushed the emilio:rayon-style branch 2 times, most recently from 317d116 to 4c4a387 Oct 22, 2016
@emilio
Copy link
Member Author

emilio commented Oct 24, 2016

The status of this is the following: I've benchmarked rayon and I think this is going to be good enough, and maybe better with low workloads given the rayon API executes the first call in the current thread and moves subsequent calls to worker threads.

Also, there's no unsafe code now there, only the Node::from_unsafe calls that I eventually plan to eliminate after this lands.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 24, 2016

@emilio What numbers are we talking about? Within 10% or...?

@emilio
Copy link
Member Author

emilio commented Oct 25, 2016

I'd say the difference is way lower, less than 5% in my previous
profiles (and on some of them rayon even appeared faster in the
profile), but I need to profile again with the new Rayon, and
potentially with https://github.com/nikomatsakis/rayon/pull/122.

@bholley
Copy link
Contributor

bholley commented Oct 25, 2016

Are these synthetic benchmarks? Would be good to know what the impact is on stylo (i.e. redoing the measurements in http://people.mozilla.org/~bholley/stylo-london-2016/wikipedia-annotated.png and http://people.mozilla.org/~bholley/stylo-london-2016/spec-annotated.png

@emilio
Copy link
Member Author

emilio commented Oct 25, 2016

Nope, they're done basically browsing with servo, trusting a bit the profiler and a bit more perf. I'll try to do more accurate benchmarking.

@pcwalton
Copy link
Contributor

pcwalton commented Oct 25, 2016

If it's under 5% that's more than good enough for me. We may well make up way more than that with parallel display list construction, which rayon could reenable.

@bholley
Copy link
Contributor

bholley commented Oct 25, 2016

I'm generally optimistic here, but would like to see the numbers on stylo.

@bors-servo
Copy link
Contributor

bors-servo commented Oct 26, 2016

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

@metajack
Copy link
Contributor

metajack commented Oct 27, 2016

It seems likely we can get back this performance by optimizing Rayon. I agree with Patrick that this change seems worthwhile even at a minor performance cost.

bors-servo added a commit to servo/webrender that referenced this pull request Nov 5, 2016
Update rayon.

I need this for servo/servo#13641

<!-- 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/532)
<!-- Reviewable:end -->
@emilio emilio force-pushed the emilio:rayon-style branch from 4c4a387 to ea06174 Nov 5, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2016

💔 Test failed - linux-dev

@emilio emilio force-pushed the emilio:rayon-style branch from 0e7af1c to b7971d6 Nov 13, 2016
@emilio
Copy link
Member Author

emilio commented Nov 13, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2016

Trying commit b7971d6 with merge 38e97d2...

bors-servo added a commit that referenced this pull request Nov 13, 2016
Use rayon to drive parallel layout and styling.

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

The current work queue had a really annoying constraint: The size of the node had to be the size of the work unit data.

This makes it impractical for the new restyling model where we plan to pass down a bunch of data.

Rayon by default makes you wait for the result of the work unit, which makes it impractical for the current model (it's mostly sequential).

I added an API to rayon that allows us to push work to the queue without waiting (https://github.com/nikomatsakis/rayon/pull/103).

This still needs some work (for example, we're loosing the memory reporting functionality), but I wanted feedback on this.

---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (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. -->

<!-- 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/13641)

<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2016

💔 Test failed - linux-rel-css

@bors-servo
Copy link
Contributor

bors-servo commented Nov 13, 2016

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

emilio added 2 commits Oct 7, 2016
After discussion with jdm.
@emilio emilio force-pushed the emilio:rayon-style branch from 8948a5c to 58bd039 Nov 14, 2016
@emilio
Copy link
Member Author

emilio commented Nov 14, 2016

@bors-servo r=pcwalton

There we go.

@bors-servo
Copy link
Contributor

bors-servo commented Nov 14, 2016

📌 Commit 58bd039 has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Nov 14, 2016

Testing commit 58bd039 with merge 9467fbe...

bors-servo added a commit that referenced this pull request Nov 14, 2016
Use rayon to drive parallel layout and styling.

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

The current work queue had a really annoying constraint: The size of the node had to be the size of the work unit data.

This makes it impractical for the new restyling model where we plan to pass down a bunch of data.

Rayon by default makes you wait for the result of the work unit, which makes it impractical for the current model (it's mostly sequential).

I added an API to rayon that allows us to push work to the queue without waiting (https://github.com/nikomatsakis/rayon/pull/103).

This still needs some work (for example, we're loosing the memory reporting functionality), but I wanted feedback on this.

---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (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. -->

<!-- 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/13641)

<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 14, 2016

@bors-servo bors-servo merged commit 58bd039 into servo:master Nov 14, 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 deleted the emilio:rayon-style branch Nov 15, 2016
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

You can’t perform that action at this time.