#ECS performance concerns

1 messages · Page 1 of 1 (latest)

solemn valve
#

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.

obsidian sparrow
#

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

solemn valve
#

btw so I can use managed component for these kind of cases (render component) without performance hit?

obsidian sparrow
#

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

solemn valve
solemn valve
solemn valve
mild nova
#

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