Archetype without entityId

Entity Id Consumes 8 bytes of data per record.
For small entities 1-2 bytes in size this is big waste of space.

Allow creation archetypes without EntityId in many cases we dont need to know EntityId from chunk iteration.

Under what circumstances would an this ever be an issue?

You could create 1,000,000 empty entities and it’d only save 8MB of memory. Even in the most low end of hardware these days that is unlikely to be your bottleneck.

1 Like

Potentially I can have world with 8M entities mostly static, 4 bytes each so it is 32MB of data

With entityId inside archetype it will be 96MB of data.

While it is not big deal for memory itself it will cost a performance to process because all 96MB will be loaded into caches :slight_smile:

May be I fear for nothing. This is just logical assumptions.

I think since the Chunks are layed out as struct of arrays and not as array of structs, the Entities should not be loaded into caches if you do not use them.

They will not be loaded into processor cache line it is true. but they will be loaded to all other caches: l3 l2 l1

Could you explain this? My understanding was that the cache line size for all caches was only 64 bytes. Why would the whole 16kb be loaded into l2 and l3?

In any event, I’m not sure you can actually leave out the Entity array in the chunk as the only way to retrieve it, when you do need it, is to search the entire Entity freelist which is inconceivable.
The only perf cost involved is cache misses due to many more chunks but that can be got around down the track by having custom chunk sizes.

You can’t do it, EntityId’s needed to remove entity from chunk.
To be specific, removing entity from a chunk is done by removing at swapping back, and thus we should update the moved entity’s chunk data, and that’s why EntityId is needed.

1 Like

I have Google a bit to be sure about prefetchers and the only meaningful piece of info was:

So not too much data will be accessed. Many cache misses on chunk boundaries may be the only real downside :slight_smile:

Thanks that’s very interesting. I always imagined the pre-fetch size would be such that it could feed L1 with no lag for streaming data.