Skip to content

Consider shrinking ECS IDs #4820

@james7132

Description

@james7132

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

Currently all of the ECS IDs (sans Entity) is backed with a usize, which might be bigger than it needs to be. It'll be difficult to find a use case that legitimately needs more than u32::MAX archetypes, tables, bundles or components, which means the upper 4 bytes on 64-bit machines effectively go unused.

For Components and Bundles, it may make sense to drop to u16, as most of these are determined at compile time, or are conservatively added via modding/scripting.

What solution would you like?

Shrink ArchetypeId, TableId, ArchetypeComponentId to u32.

Tentatively shrink ComponentId and BundleId to u16.

What alternative(s) have you considered?

Leaving them as is.

Additional context

As a good portion of the metadata storage for ECS is stored in SparseSets embedded in Archetypes and Tables, shrinking these IDs can shrink the size of these sets, keeping them hotter in caches, and thus reducing access overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions