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's thread pool. #1202

Merged
merged 2 commits into from May 9, 2017
Merged

Use rayon's thread pool. #1202

merged 2 commits into from May 9, 2017

Conversation

@nical
Copy link
Collaborator

nical commented May 4, 2017

cf. issue #1178.

Rayon's thread pool implementation is a lot better than the one provided by the threadpool crate, and comes with a lot of very useful additional features. The spawn_async functionality which we need is currently behind the unstable feature flag. Note that stylo is also using rayon with the unstable feature flag and is bumping to version 0.7 in servo/servo#16303.


This change is Reviewable

@nical
Copy link
Collaborator Author

nical commented May 4, 2017

r? @kvark

@nical
Copy link
Collaborator Author

nical commented May 4, 2017

I am being told that it would be best to wait for servo/servo#16303 to be merged before merging this one in order to avoid having 0.6 in servo and 0.7 in webrender.

@@ -2215,7 +2217,7 @@ pub struct RendererOptions {
pub enable_batcher: bool,
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
pub workers: Option<Arc<Mutex<rayon::ThreadPool>>>,

This comment has been minimized.

Copy link
@emilio

emilio May 4, 2017

Member

Do you need the mutex now? It seems the spawn_async function takes an immutable ThreadPool, so I don't see why off-hand.

@nical nical force-pushed the nical:rayon branch from 9d82cfa to 1ca07fe May 4, 2017
@nical
Copy link
Collaborator Author

nical commented May 4, 2017

Thanks @emilio, it's quite a lot nicer without that mutex around the thread pool!

@kvark
kvark approved these changes May 4, 2017
Copy link
Member

kvark left a comment

Looks great, there is a couple of notes.

@@ -1046,9 +1046,11 @@ impl Renderer {
let render_target_debug = options.render_target_debug;
let payload_tx_for_backend = payload_tx.clone();
let recorder = options.recorder;
// TODO(gw): Use a heuristic to select best # of worker threads.
let worker_config = rayon::Configuration::new().thread_name(|idx|{ format!("WebRender:Worker#{}", idx) })
.num_threads(4);

This comment has been minimized.

Copy link
@kvark

kvark May 4, 2017

Member

let's not even call num_threads?

If num_threads is 0, or you do not call this function, then the Rayon runtime will select the number of threads automatically. At present, this is based on the RAYON_RS_NUM_CPUS (if set), or the number of logical CPUs (otherwise).

@@ -2215,7 +2217,7 @@ pub struct RendererOptions {
pub enable_batcher: bool,
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
pub workers: Option<Arc<rayon::ThreadPool>>,

This comment has been minimized.

Copy link
@kvark

kvark May 4, 2017

Member

while I use this style in some of the personal project, I believe the convention in WR is to use all the types you need

@glennw glennw changed the title Use rayon's thread pool. [DO NOT MERGE] Use rayon's thread pool. May 5, 2017
@glennw
Copy link
Member

glennw commented May 5, 2017

@nical I marked this as [DO NOT MERGE] based on your comment #1202 (comment) - feel free to update the title when this is ready to go :)

@bors-servo
Copy link
Contributor

bors-servo commented May 5, 2017

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

@stshine
Copy link

stshine commented May 9, 2017

servo/servo#16303 has landed.

@nical nical changed the title [DO NOT MERGE] Use rayon's thread pool. Use rayon's thread pool. May 9, 2017
@nical nical force-pushed the nical:rayon branch from 1ca07fe to 48699aa May 9, 2017
@kvark
Copy link
Member

kvark commented May 9, 2017

@bors-servo
Copy link
Contributor

bors-servo commented May 9, 2017

📌 Commit 48699aa has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented May 9, 2017

Testing commit 48699aa with merge 7f9051c...

bors-servo added a commit that referenced this pull request May 9, 2017
Use rayon's thread pool.

cf. issue #1178.

Rayon's thread pool implementation is a lot better than the one provided by the threadpool crate, and comes with a lot of very useful additional features. The spawn_async functionality which we need is currently behind the unstable feature flag. Note that stylo is also using rayon with the unstable feature flag and is bumping to version 0.7 in servo/servo#16303.

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

bors-servo commented May 9, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing 7f9051c to master...

@bors-servo bors-servo merged commit 48699aa into servo:master May 9, 2017
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
@nical nical deleted the nical:rayon branch May 10, 2017
@nical nical mentioned this pull request May 10, 2017
@kvark kvark mentioned this pull request May 13, 2017
3 of 5 tasks complete
bors-servo added a commit to servo/servo that referenced this pull request May 14, 2017
WR update: preserve-3d support

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

This is WR update to servo/webrender@d335555 having new features:
  - limited "preserve-3d" support (servo/webrender#1169, servo/webrender#1208)
  - rayon thread pool (servo/webrender#1202)
  - further border rendering improvements

Edit: the references to bincode serialization and border styles are removed from here, since they are already integrated into Servo.
Edit2: this is alternative/similar to  #16801, based on @mrobinson code (see first commit).

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

Related to #9087
Note that I'm unlocking a few tests as well as changing some related to `preserve-3d`. The changes come from common sense and comparison to Chromium. I'm ready to discuss them on a individual basis.

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

There is still an investigation to do with regards to the differences of preserve3d logic between Blink and Gecko.

<!-- 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/16775)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 17, 2017
Let rayon automatically choose the number of threads in the ThreadPool.

This is a tiny followup from PR #1202 that I wanted to submit in isolation so that we can easily check its effect on performance (if any) and roll it back if needed.

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

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