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

Close performance gap between bevy_tasks and rayon #10064

Open
alice-i-cecile opened this issue Oct 9, 2023 · 4 comments
Open

Close performance gap between bevy_tasks and rayon #10064

alice-i-cecile opened this issue Oct 9, 2023 · 4 comments
Labels
A-Tasks Tools for parallel and async work C-Performance A change motivated by improving speed, memory usage or compile times

Comments

@alice-i-cecile
Copy link
Member

  • One is that their executor spins a little more waiting for another task to be ready.
  • For par_for_each stuff, it wakes new threads faster as async executor limits to waking one thread at a time.
  • When it forks (splits current task in 2) it runs one on the current thread and only spawns a task for the other task.

There's probably some other microoptimizations too, but I think the above are the lowish hanging fruit.

From @hymm on Discord.

@alice-i-cecile alice-i-cecile added C-Performance A change motivated by improving speed, memory usage or compile times A-Tasks Tools for parallel and async work labels Oct 9, 2023
@alice-i-cecile alice-i-cecile changed the title Close performance gap between bevy_tasks and rayon Close performance gap between bevy_tasks and rayon Oct 9, 2023
@mockersf
Copy link
Member

mockersf commented Oct 9, 2023

is there a way to measure this performance gap before trying to optimise for it?

@Kanabenki
Copy link
Contributor

It seems rayon already has a suite of bench tests in rayon-demo, we could try to adapt some of the relevant ones to use bevy_tasks instead and compare the runs with something like Criterion.

@dmyyy
Copy link
Contributor

dmyyy commented Nov 13, 2023

There's also @Elabajaba's executor bench here which shows rayon to be 2x faster than bevy_tasks.

@james7132
Copy link
Member

As discussed on #6941, I'm more and more leaning towards reintroducing rayon as a base for all of our multi threaded processing. This may change with smol-rs/async-executor#93, but there is also a number of optimizations that rayon has made that is non-trivial to port to async-executor.

Since the introduction of ECS v2, Rayon has added support for wasm, and even has a version that supports web worker based multithreading. There remains the question of how we'd handle async tasks, which remains to be seen, but there are definitely a few options out there that merge tokio and rayon together, so it definitely seems doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Tasks Tools for parallel and async work C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

No branches or pull requests

5 participants