Skip to content

Efficient World merging #12545

@james7132

Description

@james7132

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

Minimize the time spent in the critical section in mutating the World when loading scenes.

What solution would you like?

A World::merge_with(&mut World) API that moves all of the entities, components, and resources from the provided world into the world it's being called on. The source world will be empty once complete.

This should support scene loads in a consumptive way. Assuming the scene doesn't need to exist after merging with the world (i.e. an environmental load, not a prefab-like spawn of multiple characters or bullets), this should minimize the need for reflection in the critical path.

This should be safe to do, though any systems in the system registry will likely fail to run once merged into the new world due to a WorldId mismatch. Likewise any metadata-as-entities (i.e. Components as entities) will likely need to be guarded against as well to invalidating the internal state of either world.

What alternative(s) have you considered?

Continue using our current reflection based approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-ScenesSerialized ECS data stored on the diskC-FeatureA new feature, making something new possibleC-PerformanceA change motivated by improving speed, memory usage or compile timesD-ComplexQuite challenging from either a design or technical perspective. Ask for help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions