Skip to content

Specify thread pool by default for the parallel iteration of queries #3183

Closed
@alice-i-cecile

Description

@alice-i-cecile

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

The existing parallel iteration strategy requires specifying a thread pool, generally through Res<ComputeTaskPool>, and then passing in the parameters via a closure. See https://github.com/bevyengine/bevy/blob/main/examples/ecs/parallel_query.rs

What solution would you like?

  1. Implicitly fetch the ComputeTaskPool resource with each query. This is cloned during system initialization.
  2. Rename the existing method to par_for_each_manual and so on.
  3. Add an ergonomic method for par_for_each (and eventually par_iter and friends) which uses this task pool.

What alternative(s) have you considered?

We could instead create a global / static thread pool that is always used. This may be necessary for performance or ergonomics reasons, but should not be necessary.

Additional context

We cannot deprecate the existing techniques, as other thread pools may be desired in niche situations.

Related to #2088.

Discussed with @cart on Discord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions