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

Rewrite the parallel raytracing example with rayon #1380

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

alexcrichton
Copy link
Contributor

@alexcrichton alexcrichton commented Mar 21, 2019

One of the best parts about concurrency in Rust is using rayon and how
easy it makes parallelization of tasks, so it's the ideal example for
parallel Rust on the web! Previously we've been unable to use rayon
because there wasn't a way to customize how rayon threads themselves are
spawned, but that's now being developed for us!

This commit uses that PR to rewrite the raytrace-parallel example in
this repository. While not a perfect idiomatic representation of using
rayon I think this is far more idiomatic than the previous iteration
of raytrace-parallel! I'm hoping that we can continue to iterate on
this, but otherwise show it off as a good example of parallel Rust on
the web.

Closes #1349

@alexcrichton
Copy link
Contributor Author

I think we'll want to hold off on merging this until the upstream rayon PR is merged, but I wanted to post this for others interested!

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

🎉

@alexcrichton
Copy link
Contributor Author

And now updated with the merged API on rayon-rs/rayon#636!

r? @fitzgen

@alexcrichton
Copy link
Contributor Author

Or actually you've already approved so I'll merge when green

One of the best parts about concurrency in Rust is using `rayon` and how
easy it makes parallelization of tasks, so it's the ideal example for
parallel Rust on the web! Previously we've been unable to use `rayon`
because there wasn't a way to customize how rayon threads themselves are
spawned, but [that's now being developed for us][rayon]!

This commit uses that PR to rewrite the `raytrace-parallel` example in
this repository. While not a perfect idiomatic representation of using
`rayon` I think this is far more idiomatic than the previous iteration
of `raytrace-parallel`! I'm hoping that we can continue to iterate on
this, but otherwise show it off as a good example of parallel Rust on
the web.

[rayon]: rayon-rs/rayon#636
@alexcrichton
Copy link
Contributor Author

Thanks so much again for the help in rayon @cuviper!

@alexcrichton alexcrichton merged commit 3aa803c into rustwasm:master Jun 13, 2019
@alexcrichton alexcrichton deleted the rayon-example branch June 13, 2019 13:50
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.

Use rayon for the raytrace-parallel example
3 participants