-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Consider shrinking ECS IDs #4820
Description
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.