Entities overhead

So yesterday I was toying around with ECS, made 1 million cubes move around with a single system at a steady 50fps, good stuff.

So it got me thinking, if I ever wanted to create a tilebased game where every tile is an entity, how many entities could I instantiate (without any system looping through them) without seeing any performance drops?

I removed the RenderMesh components, turned off the system and ran it again and got about…55-60fps, v-sync turned off, so it wasnt capped.

That’s unfortunate.

Unless I’m doing something wrong, this means that my high-end pc would be capped at a 1000x1000 size tilemap (without any systems running)?

I just noticed that it was the RenderMeshSystemV2 who ate up the resources. Apparently it processes entities with just LocalToWorld and Translation components.

That’s definately not expected.

Do you have a small repro sample project you can share?

What’s the purpose of having entities if they will no be processed by any system?
And i think this problem is coming from the hybred renderer systems,im had the same issue cause even if there are no entities to renderer the system still getting effected by entities count.
I think you can have Millions of entities by dividing your world into regions and cull them by regions instead of individually.
I’m doing it in my game and it’s working for me.
each entity within a region should have a region Shared Component Data and then move the entities that have out of interest regions to another World, this way you are making it easy for all systems to go through the right entities.
Moving the entities should by made by passing an entityquery to the moveFrom function instead of doing it by entity.

@Joachim_Ante_1

I’ll upload one once I get home. I did get the same results using just this code in a new project, latest beta, latest package releases:

public class ECSTest : MonoBehaviour
{
    void Start()
    {
        EntityManager ems = World.Active.EntityManager;
        for (int i = 0; i < 1000000; i++)
        {
            Entity ent = ems.CreateEntity( typeof(LocalToWorld), typeof(Translation));

        };
    }
}

Makes the hybrid renderer go haywire.

In practice? None. I just wanted to stress test ECS and evaluate it’s potential.

3 Likes

https://github.com/fmarqvardt/ECS-EntityOverhead
There you go, sorry about the delay.

Removing the hybrid renderer it seems that the TRSToLocalWorldSystem is taking up quite a bit of resources as well.

1 Like

Good find!
I can confirm TRSToLocalToWorld.Execute has 85% of the load.
I wonder why it’s not working on just changed values.

Further, it makes me think if it’s a good idea to rely on Translation when the endproduct LocalToWorld is important. Lots of overhead, especially with 1+ million entities and copies of nearly the same data. The introduction of LocalToWorld struck me as weird and I hope this gets addressed. Right now it feels like 2 systems are in place for what should be one. If it’s Translation/Rotation/Scale or LocalToWorld, I don’t care, they are handled pretty much the same anyway.

edit: Drilling down a String.memcpy comes up in math,float4x4. Must be debug related
4623976--433258--float4x4.PNG

1 Like