Hello, I know the advantage of developing games using ECS in terms of memory, but what should I pay attention to when creating a game and its components for maximum performance? I can understand the importance of components fitting into the cache, but for example, RenderComponent contains the mesh and this will clearly not fit into the cache, but on the other hand, I guess this is unimportant since I do not process the CPU with the mesh. At this point, cache size should not matter for my components that only store data and do not perform any operations on them. For example, for a component that detects enemies around the character, the cache will be unimportant because I do not use this information for any operation. I think I'm a little confused, I would be very happy if someone could enlighten me.
#ECS performance concerns
1 messages · Page 1 of 1 (latest)
when you reference mesh, you actually store a pointer (or managed reference) to mesh data and it's irrelevant for cache anyway
when actual mesh data is processed - this is the case, where cache may be utilized
Scenarios where Cache is important are when I make processing?
btw so I can use managed component for these kind of cases (render component) without performance hit?
managed components = no burst, no jobs
I'd say it's more complicated than that and it's best if you learn more what cache is even about and how cpu works with it
I feel like you missunderstand how cpu cache is utilized
For clarification, the CPU cache is where the CPU stores data in groups for retrieval from RAM. The less I spend on time on RAM, the faster I can process.
At this point, if I keep the data only so that other components can access it, I am not getting benefit from ECS.
btw in cases like storing array on component is problematic for me. For instance I have a component for find targets around my character. So this component have to store array of id's of other entities
For performance it is better to focus on minizing sync points with jobs more than anything, but if you really want maximum performance then one thing you can do is optimize your high-quantity components to use smaller values like a byte or short to store health instead of a full int, this is to maximise the amount of entities in a chunk and to reduce cache misses.
There is a lot you can do but I recommend you work on a game first then optimise,
Ecs is just good like that, you can easily replace a system with a more optimised one due to modularity
You dont even have to use the unity components like their transform system
Just make your own one
That fits your needs
Also the rendermesh component isnt store on all entities, its a shared componeny meaning all entities simply store a pointer to a single instance