
Kodama
Context
Kodama is an end-to-end simulation prototype, not a shipping product: a sandbox for testing patterns at scale. Crowded interactive worlds strain the server loop, the wire format and the client frame budget at once, so I wanted a stack where each constraint could be measured separately.
Decision
I chose SignalR with binary MessagePack snapshots over a custom WebSocket gateway, trading some payload size for one less bespoke component in the critical path. The server runs at 10 Hz on structure-of-arrays component storage (parallel arrays with sparse sets) and a position-hashed spatial index for constant-time cell lookups, with buffer pooling and no LINQ in simulation code. The client renders the crowd with GPU instancing and interpolates server state. Nearest-resource search is still a linear scan — profiled as a non-bottleneck at 10K agents, and kept visible as acknowledged debt.
Outcome
10K+ agents with sub-millisecond server ticks, an allocation-free behaviour pass in a profiling measurement, and payloads about 70% smaller than comparable JSON snapshots.