Dense entity arrays: efficient, or a micro-optimization? #286
ExoticMatter
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Since entities have a lazily-generated ID, it is possible to store these IDs in a
TypedArray
. With a wrapper class this can be done without sacrificing ergonomic-ness.In theory, this should use less memory than
Entity[]
. The downside is that we need to look up the entity ID in order to return anEntity
, which means in theory indexing into it will be no faster than, and possibly slower than, indexing intoEntity[]
.Note: World.id() uses
Map<number, Entity>
for id -> Entity, which benchmarks suggest has the same performance asEntity[]
. However, we first have to index into the array of IDs, and then look up the entity in theMap
.Beta Was this translation helpful? Give feedback.
All reactions