Skip to content

Options for disabling all parallelism for single-threaded performance  #6689

@james7132

Description

@james7132

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

In certain environments, like low cost VPS game hosting, it is often more efficient to host multiple single threaded game instances instead of hosting. For these use cases, the additional synchronization overhead of many Send/Sync types can be quite high, particularly with atomics.

What solution would you like?

A feature flag on bevy_ecs and bevy_tasks to:

  • disable the ParallelExecutor as a default runner
  • the multi-threaded TaskPool
  • internally replace Query::par_for_each calls with for_each.
  • switch to using !Send or !Sync options of common types (i.e. Mutex -> RefCell, Arc -> Rc) (questionable if this is possible, we already avoid the use of these).

In these target environments, rendering is typically not required. Ideally this shouldn't require too much code change on the user's end other than changing some crate features so that code can be easily shared between client and server.

What alternative(s) have you considered?

Leave it as is, eat the cost of atomics in these systems.

Additional context

Original discussion: https://www.reddit.com/r/rust/comments/ytiv2a/comment/iw4q6ed/?utm_source=share&utm_medium=web2x&context=3

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-TasksTools for parallel and async workC-FeatureA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile times

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions