• Advertisement
Sign in to follow this  

Statistic algorithms for ECS

This topic is 1354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have not found a good solution for ECS data structure in termes of cache coherency. Maybe it does not exist, so I am looking for some algorithms that reorder antities or components in memory using some data (may be also statistic data obtaind from the the game real time) to achieve contiguas memory traversing when the systems will travers on entities to accomplish their mission.

Share this post


Link to post
Share on other sites
Advertisement

You could use a pool allocator for each type of component in order to guarantee (mostly) contiguous memory for components of the same type.

Share this post


Link to post
Share on other sites

Adding to what ApochPiQ said, a lot of ECS systems tend to use the "outboard component" model, where each component is pooled separately, and the entity itself is just a semantic tag (usually an integer handle).

 

That's kind of the idea case for cache coherency - you can have a system, for example, that just iterates over a flat array of position data, and calculates world transforms for each one.

Share this post


Link to post
Share on other sites

What ApochPiQ and swiftcoder said is exactly how I implemented my ECS. I don't have any caching stats I can point to that prove its better doing it that way, but I can say that it was relatively straightforward to implement, and gives you quite a few interesting advantages.

 

The biggest downside is that it becomes a little more difficult to list all components for a single entity, since each component is stored far away from the others. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement