Skip to content

Introduction ​

KenseiECS is a lightweight, sparse-set Entity Component System for Unity and .NET. Each component type is stored in its own sparse set: component access is O(1), iteration walks dense arrays, and adding or removing a component touches only that type's pool and the filters that care about it.

The core (World, pools, filters, systems) has no Unity dependency and runs on plain .NET. In Unity, the package adds a bootstrap component, inspector authoring, a listener bridge to MonoBehaviours and editor tools.

Features ​

  • Sparse Set storage — O(1) component access, dense arrays for cache-friendly iteration
  • Generational entities — 8-byte Entity (int Index + int Generation) with aliasing protection
  • Reactive filters — cached query results, updated automatically on component changes
  • Zero-allocation iteration — struct enumerator, reverse iteration safe for structural changes
  • Auto-destroy — entities without components are destroyed automatically
  • IAutoReset — custom cleanup on component remove
  • IAutoCopy — custom deep-copy logic for CopyEntity
  • SharedData — typed container for shared services, no reflection
  • OneFrame components — auto-removed event components, end-of-frame or positional (DelHere)
  • Nested system runners — separate groups for Update/FixedUpdate/LateUpdate
  • Named systems — enable/disable systems and phases at runtime
  • World events — IWorldEventListener for lifecycle notifications, type indices resolve to Type
  • Exception-safe lifecycle — a throwing listener or system releases entity slots and restores runner and buffer state; only a throw inside DestroyEntity or a snapshot Load can leave components behind, and Clear() recovers
  • Debug validation — dead/stale handle misuse throws under KENSEI_DEBUG, zero cost in release
  • Listener bridge — clean ECS <-> Unity MonoBehaviour communication, no delegates
  • Editor tools — World Inspector, Profiler, EcsEntityView with navigation (under KENSEI_DEBUG)
  • Scales to thousands of component types — multi-word bitmasks, per-type filter lists

Performance ​

10,000 entities, .NET 8 x64 RyuJIT, BenchmarkDotNet, zero allocations at runtime once pools, filters and buffers have grown to their peak capacity (one machine; the other frameworks measured in September 2026, KenseiECS 2.4.0 scaled from the same session by an October 2026 comparison with 2.0, see the benchmarks page):

OperationKenseiECSLeoEcsLiteArch
Iteration (2 comp), filter13.8 us14.0 us5.4 us
Iteration (2 comp), owning group5.5 us—5.4 us
Entity creation (2 comp)292 us344 us208 us
Structural changes (add+remove)87 us73 us590 us
Game loop (mixed frame)35 us40 us78 us

Bold = best in row. The owning-group row measures KenseiECS groups, which keep the dense arrays of several pools aligned. Unity's Mono and IL2CPP backends and ARM devices were not measured, and no scenario covers EventBuffer<T> or OneFrame<T>.

See the full benchmarks with analysis, including 1024 component types, fragmented worlds, filters observing the changed type and memory footprint. Run them yourself from the repository root:

sh
dotnet run -c Release --project Benchmark