Doraku / Ecs.CSharp.Benchmark

Benchmarks of some C# ECS frameworks.
MIT No Attribution
122 stars 19 forks source link

No entity padding in Arch benchmark #23

Open Sieluna opened 6 months ago

Sieluna commented 6 months ago

https://github.com/Doraku/Ecs.CSharp.Benchmark/blob/c91e1206a401450b05db7e806fd399ff38bcc46f/source/Ecs.CSharp.Benchmark/SystemWithOneComponent/Arch.cs#L22-L27

https://github.com/Doraku/Ecs.CSharp.Benchmark/blob/c91e1206a401450b05db7e806fd399ff38bcc46f/source/Ecs.CSharp.Benchmark/SystemWithTwoComponents/Arch.cs#L22-L27

https://github.com/Doraku/Ecs.CSharp.Benchmark/blob/c91e1206a401450b05db7e806fd399ff38bcc46f/source/Ecs.CSharp.Benchmark/SystemWithThreeComponents/Arch.cs#L22-L27

Doraku commented 6 months ago

It wasn't done before but it's probably possible to "simulate" padding with extra archetype signature like with other frameworks

thygrrr commented 4 months ago

It wasn't done before but it's probably possible to "simulate" padding with extra archetype signature like with other frameworks

I think Entity Padding is actually done in a way that literally benefits some ECS, and slightly to massively harms others.

Can I suggest a fragmentation pass (or separate test), too?

(instead of having "irrelevant" with the wrong 2 out of 3 relevant components, entities, instead I suggest sprinkling (adding) irrelevant EXTRA components onto the relevant entities).

Example could be "10% of entities have an irrelevant component" instead of "there's 10 random entities somewhere else in memory".

Fragmentation and even just multiple larger or smaller archetypes would cause Arch's InlineParallelQuery to fall pretty flat, for example. It only seems efficient because there's a single archetype, to which its work chunking and thread awaiting code has no weakness. (it would also affect fennecs up to version 0.3.x or something, I'm merely trying to make the benchmark more useful and expressive regarding real day2day scenarios)

Edit: Oops, I noticed while working on the new fennecs benchmarks that exactly this is done in CreateEntityWithTwoComponents, and it's exactly what happens to Arch in that benchmark.

Doraku commented 4 months ago

Thanks for your great contribution @thygrrr ! Yeah that was the goal of the padding, multiply the archetypes from a single query to see the impact, obviously it's not perfect and still not representative of a real world situation, but still better than the best case scenario with one archetype. SystemWithTwoComponentsMultipleComposition should probably be expanded into more real world case.