Skip to content

ECS: Guarenteed Parallelization Tests #4204

Open

Description

@james7132

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

To ensure maximum performance, we should be able to test that at least two (if not N) different systems will not block each other during execution (ignoring any explicit labeling or ordering).

What solution would you like?

A testing utility that, given two or more systems, returns false if all of them cannot run in parallel. This would allow using assert tests to ensure that said tests are broken if the systems would serialize execution in any way.

What alternative(s) have you considered?

Blindly rely on the executor to properly handle parallelization.

Additional context

A lot of optimizations that rely on splitting large monolithic systems into smaller disjoint ones that can run in parallel cannot be easily enforced via unit tests right now.

Activity

  1. added
    A-ECSEntities, components, systems, and events
    C-UsabilityA targeted quality-of-life change that makes Bevy easier to use
    on Mar 14, 2022
  2. maniwani commented on Mar 14, 2022

    @maniwani
    Contributor

    Blindly rely on the executor to properly handle parallelization.

    I get what you're saying, but just wanted to say the executor does properly handle parallelization. If two systems see an intersection on their .archetype_component_access(), they definitely aren't disjoint.

    That relies on runtime information, though. Not sure if there's a way to statically prove that two systems can't run in parallel.

    This is what the current results mean.

    // these aren't known until you actually spawn entities and have archetypes
    let some_access = some_system.archetype_component_access();
    let other_access = other_system.archetype_component_access();
    
    if some_access.is_compatible(other_access) {
        // these systems definitely do not conflict
    } else {
    	// these systems definitely conflict
    }
    
    let some_access = some_system.component_access();
    let other_access = other_system.component_access();
    
    if some_access.is_compatible(other_access) {
        // these systems can never conflict
    } else {
    	// these systems may or may not conflict (depends on the archetypes)
    }
  3. moved this to PR needed in Schedulingon Apr 27, 2022
  4. moved this from PR needed to Tangentially Related in Schedulingon Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions