As shown in Benchmarking tag component v2 , Huge entities are terrible for performance, adding a empty “tag” component to a large entity is also terrible for performance, adding any type or size of component is terrible, working on huge entities is also slow because there are less of them per chunk, imagine iterating over 100kb sized entities when you only want 8 bytes off them
Small entities are the way to go for performance.
Let me give an example to justify a sub entity feature:
You have a MainCharacter that contains: position, skills, inventory, collision, renderer, combat info, combat buffs, etc.
Now you want to make area of effect attacks, so to not have you checking every single entity every time for range check, you make so that each entity have a SharedComponentData(part of the map you are right now), something like MapTile(0, 0, 15, 15) if his position is (7, 0, 9) and would change to MapTile(15, 0, 30, 15) if his position is (16, 0, 9). Now each entity is on a ‘15x15 tile’ of the map, so you first check which tiles the AOE spell hits, and then only checks the entities in those ‘tiles’ the spell hits.
The issue is that adding or changing a SharedComponentData will move the entity to a chunk marked for that value, so the insanely huge MainCharacter entity will, in whole, have to me moved to a new chunk every time, and it is probably the only entity with that very specific archetype, so not only you need to move it to-from chunks, you also need to destroy/create chunks every single time.
Here enters a SubEntity. You split MainCharacter in MainCharacter +MainCharacterPosition, where MainCharacterPosition only have the character position, the current SharedComponentData for it’s tile, and a link to it’s parent Entity. When you need to check for spells, you only check these very small Position entities, so you can check for many of them in the same chunk, and since all of them are the very same, they all go to the same chunks and you only need to make a very new chunk if it is the only entity in the current map tile SharedComponentData.
Currently, this is already possible, the issue is a huge amount of boilerplate code needed to make it work, and it’s very error prone to manage these sub entities. I am aware that iterating values from the parent and sub entity at once have a cost of accessing two different chunks, but the reduced cost of moving huge entites all the time for every single little thing would probably outweigh it some times
[It is also possible that I misunderstand how entities are stored in chunks and all of this is wrong. Currently I understand that each entity archetype have it’s own chunk, so adding a component changes the entity’s archetype , and therefore it needs to be moved to a new chunk for the new archetype ]