EasyEcs

EasyEcs vs DefaultEcs

EasyEcs and DefaultEcs side by side: archetype tables against component pools and entity sets, the same system in both, the tick, and when DefaultEcs fits.

DefaultEcs stores each component type in its own pool and keeps reactive entity sets up to date as components come and go; systems iterate a set's entities and read components through the pools. EasyEcs stores entities with the same components together in archetype tables and generates a struct job per [ForEach] method that walks their columns. Both have change tracking, removal tracking, value indexes, parallel systems and saves built in; they differ in storage, in how a system is written and in what a tick costs.

In the 20 head-to-head benchmarks both libraries take part in, EasyEcs is faster in 17, within the measurement error in 3 and slower in 0. On the same server tick of 100,000 entities, DefaultEcs takes 3.7× the time of EasyEcs and allocates 60.9 KB per tick, where EasyEcs allocates 0 B. DefaultEcs runs on netstandard1.1-2.1 and Unity; EasyEcs needs .NET 10.

Add a component to 100,000 entities by query, then remove it, vs DefaultEcs

103×faster
EasyEcs 78.7 μs, DefaultEcs 8.12 ms
  • EasyEcs78.7 μs
  • DefaultEcs8.12 ms

Benchmarks EasyEcs is faster in

17/ 20
of those both libraries take part in, beyond the measurement error

DefaultEcs's time for the server tick

3.7×
relative to EasyEcs, 100,000 entities

DefaultEcs allocates per tick

60.9KB
EasyEcs allocates 0 B

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

At a glance

EasyEcsDefaultEcs
Storagearchetype tables, presence bits per columna pool per component type, entity sets
A systeman EcsSystem with generated [ForEach] jobsAEntitySetSystem<T> / AComponentSystem<T, TComponent> with [With] / [Without] attributes
Changes during a passapplied at onceapplied at once to sets; useBuffer copies the set first, or an EntityCommandRecorder
Change trackingevery ref write, [Changed<T>]NotifyChanged<T>() at each write, WhenChanged<T>() sets
Removal tracking[Removed<T>]WhenRemoved<T>() sets, completed by hand
Allocation per server ticknoneallocates
Runtimesnet10.0netstandard1.1-2.1; Unity

Concepts side by side

ConceptDefaultEcsEasyEcs
Worldnew World(capacity)new World(new WorldOptions { InitialEntityCapacity = n })
Componentany structa struct implementing IComponent
Create with componentsvar e = world.CreateEntity(); e.Set(a); e.Set(b);world.CreateEntity(a, b) (placed in its final table at once)
Create manythe same per entityworld.CreateEntities(span, a, b), or world.EnsureCapacity<A, B>(n) before a loop
Read, writee.Get<T>() (ref), world.GetComponents<T>()[e]entity.Hp (a ref; ref readonly for a tracked component); a [ForEach] parameter
Tage.Set<Dead>()entity.SetDead()
Destroye.Dispose()entity.Destroy()
Singletonworld.Set<T>(value), world.Get<T>()ISingletonComponent, world.SetClock(…), world.Clock, a ref T parameter
System over a set[With(typeof(A)), Without(typeof(B))] class S : AEntitySetSystem<TState>class S : EcsSystem with [ForEach, Without<B>] static void M(ref A a)
System over one componentAComponentSystem<TState, A>a [ForEach] method taking ref A
Sequence of systemsnew SequentialSystem<T>(systems)world.AddSystem<S>() in order, or [UpdateBefore<T>] / [UpdateAfter<T>]
Parallel systemsnew ParallelSystem<T>(runner, systems)WorldOptions.ParallelSystems (conflicts from generated access)
Parallel set systemAEntitySetSystem with a DefaultParallelRunner[ForEach(Parallel = true)]
Entity setworld.GetEntities().With<A>().Without<B>().AsSet()a QueryFilter, world.Query<A>(filter), world.Count<A>(filter)
Changed since last look.WhenChanged<T>() + NotifyChanged<T>() + Complete()ITrackChanges + [Changed<T>]
Removed since last look.WhenRemoved<T>() + Complete()ITrackChanges + [Removed<T>]
Index by valueAsMultiMap<T>(), AsMap<T>()IIndexed<TKey>, world.Index<T, TKey>()
Deferred changesEntityCommandRecorder, Record(e).Set<T>(), Execute()not needed
Disablee.Disable(), e.Disable<T>()a tag and [Without<T>], or entity.DisableHp()
Copy to a worlde.CopyTo(world)entity.Clone(), world.MoveEntities(...), a Prefab
SaveBinarySerializer, TextSerializerworld.Save(writer) / world.Load(bytes)
Messagesworld.Subscribe<T>, world.Publish<T>data: a singleton or components later systems read

The same task in both

The status system of the headline tick: burning units lose health and the fire goes out after a few ticks. The DefaultEcs port removes the component while it iterates, so the system passes useBuffer: true and the set is copied before the update (DefaultEcsSimulation.cs).

StatusSystem.cs
public struct Hp : IComponent { public int Value, Max; }
public struct Fire : IComponent { public int Ticks, DamagePerTick; }

public class StatusSystem : EcsSystem
{
    [ForEach]
    static void Burn(Entity entity, ref Fire fire, ref Hp hp)
    {
        hp.Value -= fire.DamagePerTick;
        if (--fire.Ticks <= 0) entity.RemoveFire();      // a bit flip: the row stays
    }
}
world.AddSystem<StatusSystem>();
world.Update();

The numbers

Every comparison both libraries take part in, sorted by lead (each row links to its section of the comparison):

What is measuredEasyEcsDefaultEcsIts time vs EasyEcs
Add a component to 100,000 entities by query, then remove it78.7 μs8.12 ms103×
Add and remove a tag in the passes that find them (1,000 of 100,000)163 μs12.9 ms79× (within error)
Find the 10 of 100,000 entities written this tick507 ns37.1 μs73×
Find the 10 of 100,000 entities that lost a component830 ns39.6 μs48×
Save 10,000 entities and load them back146 μs4.33 ms, 4.37 MB allocated30×
Spawn 10,000 entities beside 100,000, then destroy them138 μs1.33 ms, 313 KB allocated9.7×
Add and remove a tag in the passes that find them (10 of 100,000)78.2 μs496 μs6.3×
Create 100,000 three-component entities in a fresh world in one call (the others' fastest way)2.71 ms, 4.96 MB allocated16.9 ms, 19.1 MB allocated6.3×
The full server tick: nine systems over 100,000 entities1.68 ms6.24 ms, 60.9 KB allocated3.7×
Put 100 of 100,000 entities to sleep, wake the last ones41.4 μs103 μs2.48×
Create 100,000 three-component entities one by one in a fresh world, nothing reserved7.13 ms, 8.97 MB allocated16.9 ms, 19.1 MB allocated2.38×
Find the 1,000 of 100,000 entities written this tick38.5 μs77.3 μs2.01×
Count 100 inventories through an index (1 item traded)425 ns838 ns1.97×
The full server tick: nine systems over 10,000 entities175 μs307 μs, 6.15 KB allocated1.76×
Find the 1,000 of 100,000 entities that lost a component66.7 μs107 μs1.61×
Put 10,000 of 100,000 entities to sleep, wake the last ones478 μs745 μs1.56×
Count 100 inventories through an index (100 items traded)5.11 μs7.87 μs1.54×
Four independent systems over 100,000 entities, one after another395 μs471 μs1.19×
Steer 100,000 agents on all cores (parallel query)766 μs854 μs1.11× (within error)
Four independent systems over 100,000 entities, in parallel370 μs405 μs1.09× (within error)
BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

The headline tick:

One server tick of 100,000 entities: EasyEcs vs Friflo, Arch and DefaultEcs

The same simulation ported to each library's fast path, with identical results checked in setup. Shorter is faster; the badge is the time relative to EasyEcs and the memory allocated per tick.

  • EasyEcs
  • Other libraries
EasyEcs 4.60 B per tick1.68 msFriflo.Engine.ECS 3.61.08× · 0 B per tick1.83 msArch 2.13.4× · 535 KB per tick5.76 msDefaultEcs 0.173.7× · 60.9 KB per tick6.24 ms0.00 ns1.00 ms2.00 ms3.00 ms4.00 ms5.00 ms6.00 msTime per tick

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryTimevs EasyEcsAllocated
EasyEcs 4.61.68 ms1.00×0 B
Friflo.Engine.ECS 3.61.83 ms1.08×0 B
Arch 2.15.76 ms3.4×535 KB
DefaultEcs 0.176.24 ms3.7×60.9 KB

DefaultEcs takes 3.7× the time of EasyEcs on this tick and allocates 60.9 KB per tick. Its reads go through a pool per component type, indexed by the entity, where EasyEcs walks the columns of a table front to back.

Replicate the entities written this tick: 10 or 1,000 of 100,000

  • EasyEcs
  • Other libraries
EasyEcs: Changed (Written=10)0 B allocated507 nsEasyEcs: Changed (Written=1000)0 B allocated38.5 μsDefaultEcs: WhenChanged (Written=10)73× · 0 B allocated37.1 μsDefaultEcs: WhenChanged (Written=1000)2.01× · 0 B allocated77.3 μs0.00 ns10.0 μs20.0 μs30.0 μs40.0 μs50.0 μs60.0 μs70.0 μs80.0 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseWrittenMeanvs EasyEcsAllocated
EasyEcsChanged10507 ns1.00×0 B
EasyEcsChanged100038.5 μs1.00×0 B
DefaultEcsWhenChanged1037.1 μs73×0 B
DefaultEcsWhenChanged100077.3 μs2.01×0 B

Four independent systems over 100,000 entities, sequential and parallel

  • EasyEcs
  • Other libraries
EasyEcs (Parallel=False)0 B allocated395 μsDefaultEcs (Parallel=False)1.19× · 0 B allocated471 μsEasyEcs (Parallel=True)0 B allocated370 μsDefaultEcs (Parallel=True)1.09× · 0 B allocated405 μs0.00 ns100 μs200 μs300 μs400 μs500 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryParallelMeanvs EasyEcsAllocated
EasyEcsFalse395 μs1.00×0 B
DefaultEcsFalse471 μs1.19×0 B
EasyEcsTrue370 μs1.00×0 B
DefaultEcsTrue405 μs1.09×0 B

Units fall asleep and wake up, then the awake are summed

  • EasyEcs
  • Other libraries
EasyEcs: Tag (Switched=100)0 B allocated42.4 μsEasyEcs: Tag (Switched=10000)0 B allocated478 μsDefaultEcs: Disable (Switched=100)2.42× · 0 B allocated103 μsDefaultEcs: Disable (Switched=10000)1.56× · 0 B allocated745 μs0.00 ns100 μs200 μs300 μs400 μs500 μs600 μs700 μs800 μsTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseSwitchedMeanvs EasyEcsAllocated
EasyEcsTag10042.4 μs1.00×0 B
EasyEcsTag10000478 μs1.00×0 B
DefaultEcsDisable100103 μs2.42×0 B
DefaultEcsDisable10000745 μs1.56×0 B

Mark the dead and revive them during two passes over 100,000 units

  • EasyEcs
  • Other libraries
EasyEcs: Direct (Killed=10)0 B allocated78.2 μsEasyEcs: Direct (Killed=1000)0 B allocated163 μsDefaultEcs: CommandRecorder (Killed=10)6.3× · 0 B allocated496 μsDefaultEcs: CommandRecorder (Killed=1000)79× · 0 B allocated12.9 ms0.00 ns2.00 ms4.00 ms6.00 ms8.00 ms10.0 ms12.0 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseKilledMeanvs EasyEcsAllocated
EasyEcsDirect1078.2 μs1.00×0 B
EasyEcsDirect1000163 μs1.00×0 B
DefaultEcsCommandRecorder10496 μs6.3×0 B
DefaultEcsCommandRecorder100012.9 ms79×0 B

Spawn 10,000 shots, then clear them

  • EasyEcs
  • Other libraries
EasyEcs: CreateAndDestroyAll0 B allocated138 μsDefaultEcs: PerEntity9.7× · 313 KB allocated1.33 ms0.00 ns200 μs400 μs600 μs800 μs1.00 ms1.20 ms1.40 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsCreateAndDestroyAll138 μs1.00×0 B
DefaultEcsPerEntity1.33 ms9.7×313 KB

Save and load 10,000 units

  • EasyEcs
  • Other libraries
EasyEcs: SaveLoad0 B allocated146 μsDefaultEcs: Binary30× · 4.37 MB allocated4.33 ms0.00 ns1.00 ms2.00 ms3.00 ms4.00 msTime (shorter is faster)

BenchmarkDotNet 0.15.2, .NET 10.0.13, Intel Xeon Processor 2.10GHz, 4 cores, Ubuntu 24.04.5 LTS.

Data table
LibraryCaseMeanvs EasyEcsAllocated
EasyEcsSaveLoad146 μs1.00×0 B
DefaultEcsBinary4.33 ms30×4.37 MB

The DefaultEcs row of the structural-change benchmark at 1,000 kills carries an error as large as its mean in this run, and the parallel rows carry a large error too.

What DefaultEcs does better

  • Reach. netstandard1.1 to 2.1 and Unity; EasyEcs needs .NET 10.
  • Shared components. SetSameAs lets entities share one component value; EasyEcs has no shared components (D14): keep the shared data in a singleton and an id into it.
  • Messages. A built-in publish / subscribe channel; EasyEcs models messages as data.
  • A text serializer next to the binary one.
  • Sparse storage suits worlds where entities change their component set constantly and are rarely iterated as a whole: adding a component never copies the others.

When to choose DefaultEcs

Choose DefaultEcs when you need old runtimes or Unity, reactive sets or messaging as the way systems talk, and the world is small enough that per-tick allocations and pool lookups do not matter. Choose EasyEcs for a .NET 10 server that iterates many entities every tick, wants change tracking without a NotifyChanged at every write, and must not allocate per tick. Porting a DefaultEcs codebase: Migrate from DefaultEcs.

Edit on GitHub

Last updated on

How is this guide?

On this page