-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Rayon's Minimal Parallel Infrastructure With Bevy Task #11492
base: main
Are you sure you want to change the base?
Conversation
As most of the code is migrated from Rayon, I am uncertain about the possibility of encountering any copyright/license issues. |
I wonder, what are the advantages of this approach vs integrating |
this pr uses bevy's task pool rather than rayon's pool, and only pick up the design architecture of rayon. It aims to minimize redundant code, striking a balance between lightweight implementation and ergonomic design. |
I really like rayon, with #384 ,we replaced rayon with our own task pool system ,despite this, our current system lacks a robust abstraction design for data parallelism, resulting in numerous instances of |
I asked on Discord and this PR came up there too. Looks like Rayon did have some problems but they were supposedly solved (or at least partially) with some update, no? This is not a complete reason to switch back but I guess it may be worth testing how it compares now. It's also worth mentioning that the original implementation used only the global I would also argue that we don't really have a Bevy's implementation of a task pool, we're just offloading most work in the executor to I'm not saying that Some of the points in the first post also feel like a reason to use
I don't think adding a lot more code is gonna help with the maintenance. If anything this will increase the amount of work to do.
I don't think most of the ecosystem will adopt Bevy's parallel iterator traits. There are however already a lot of crates that do provide implementations of |
Sorry for the unclear wording. I initial thought to open this pull request because we don't really have a good parallel infrastructure for Bevy's internal (e.g. extract , render system ). Using Rayon directly could be more controversial and hard to move forwar , so I opted to cherry-pick the essential parts from Rayon and integrate them with the current Bevy task system.
Fair,bevy task system built on
yup,That's exactly what I meant. Bevy's task system has been stagnant for a while now. Whether we improve its ergonomics based on the current implementation or switch to Rayon, both options seem promising. We just need more test and to make a decision then move forward. |
Looks promising. I also really like Rayon and feel bevy_tasks could use some attention. Rayon seems to be dual licensed just like bevy, and as I understand it this use is acceptable under MIT, so no issue there. I'm going to spend some time evaluating this after 0.13 is out. |
Objective
vec.par_splat_map().map(**).collect()
can lead to unnecessary memory alloc and free.Solution
Rayon is a popular and powerful library for the Rust programming language designed for parallel and concurrent programming. it easy to use and extend, this pr introduces rayon's parallel architecture to intergrate with bevys task pool.
For more detailed information about Rayon's parallel infrastructure, you can find comprehensive documentation in the official Rayon documentation.
Future
Once this pr or a similar one gets accepted, I would like to implement it into Bevy-ecs query and some rendering systems to enhance ergonomic usage and squeeze out more performance.
Extend
Compare to directly use Rayon