Consider shrinking ECS IDs #4820
Labels
A-ECS
Entities, components, systems, and events
C-Feature
A new feature, making something new possible
C-Performance
A change motivated by improving speed, memory usage or compile times
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.
The text was updated successfully, but these errors were encountered: