Skip to content

Use rayon's thread pool. - #1202

Merged
bors-servo merged 2 commits into
servo:masterfrom
nical:rayon
May 9, 2017
Merged

bors-servo merged 2 commits into
servo:masterfrom
nical:rayon

Conversation

@nical

@nical nical commented May 4, 2017 •

Copy link
Copy Markdown
Contributor

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

nical commented May 4, 2017

Copy link
Copy Markdown
Contributor Author

r? @kvark

@nical

nical commented May 4, 2017

Copy link
Copy Markdown
Contributor Author

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.

Comment thread webrender/src/renderer.rs Outdated
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
pub workers: Option<Arc<Mutex<rayon::ThreadPool>>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 commented May 4, 2017

Copy link
Copy Markdown
Contributor Author

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

@kvark kvark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great, there is a couple of notes.

Comment thread webrender/src/renderer.rs Outdated
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

Comment thread webrender/src/renderer.rs Outdated
pub render_target_debug: bool,
pub max_texture_size: Option<u32>,
pub workers: Option<Arc<Mutex<ThreadPool>>>,
pub workers: Option<Arc<rayon::ThreadPool>>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

glennw commented May 5, 2017

Copy link
Copy Markdown
Member

@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
Copy Markdown
Contributor

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

@stshine

stshine commented May 9, 2017

Copy link
Copy Markdown

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
@kvark

kvark commented May 9, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 48699aa has been approved by kvark

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 48699aa with merge 7f9051c...

bors-servo pushed 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
Copy Markdown
Contributor

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

@bors-servo
bors-servo merged commit 48699aa into servo:master May 9, 2017
@nical
nical deleted the rayon branch May 10, 2017 09:38
@nical nical mentioned this pull request May 10, 2017
@kvark kvark mentioned this pull request May 13, 2017
3 of 5 tasks
bors-servo pushed 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 pushed 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants