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

Switch to using static async executors #11849

Open
james7132 opened this issue Feb 13, 2024 · 0 comments · May be fixed by #12990
Open

Switch to using static async executors #11849

james7132 opened this issue Feb 13, 2024 · 0 comments · May be fixed by #12990
Labels
A-Tasks Tools for parallel and async work C-Performance A change motivated by improving speed, memory usage or compile times S-Blocked This cannot move forward until something else changes S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help

Comments

@james7132
Copy link
Member

james7132 commented Feb 13, 2024

What problem does this solve or what need does it fill?

An investigation in smol-rs/async-executor#91 found that the lock on async_executor's state can have significant overhead when spawning new tasks in large batches, something that both MultithreadedExecutor and Query::par_iter heavily rely on.

What solution would you like?

Use the APIs implemented in smol-rs/async-executor#92 to batch spawn tasks in both the MultithreadedExecutor and Query::par_iter.

Alternatively, smol-rs/async-executor#112 eliminates the cost of the lock entirely, but switching to use a static executor will require additional user-facing API changes.

What alternative(s) have you considered?

Leaving it as is.

Additional context

This will likely require shuffling how we spawn tasks in the mulithreaded executor so that we do not end up holding the async_executor lock for longer than necessary. Query::par_iter doesn't have these issues and it should be fairly trivial to integrate.

In their current state, we may need have a type implement Extend<Task<T>> that just takes receives and detaches the spawned tasks to avoid roping the allocator into the loop.

@james7132 james7132 added A-ECS Entities, components, systems, and events C-Performance A change motivated by improving speed, memory usage or compile times S-Blocked This cannot move forward until something else changes S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help labels Feb 13, 2024
@james7132 james7132 changed the title Batch spawn MultithreadedExecutor and Query::par_iter tasks Switch to using static async executors Apr 13, 2024
@james7132 james7132 added A-Tasks Tools for parallel and async work and removed A-ECS Entities, components, systems, and events labels Apr 13, 2024
@james7132 james7132 linked a pull request Apr 16, 2024 that will close this issue
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 S-Blocked This cannot move forward until something else changes S-Needs-Benchmarking This set of changes needs performance benchmarking to double-check that they help
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant