Files
aeternalis/server
dingoandClaude Sonnet 5 9454b51914 perf: take the admin-command DB poll off the world tick's global lock
Testing one specific, targeted hypothesis rather than another blind
patch: the portal merge added an unconditional per-second DB query
(controls(), checking for pending admin commands) directly inside the
world tick loop's s.mu-locked section -- the same lock every websocket
intent, every HTTP handler, and every snapshot broadcast to every
connected player depends on. That runs forever, for every world,
whether or not the admin feature is ever used.

Verified the actual game logic isn't broken (a live-instrumented run
of the unpatched single-shot gather/attack code landed its first hit
immediately and correctly), so the e2e flakiness has to be about
something making the server slower under load rather than a logic
defect. This is the one change in the merge positioned to tax *every*
player's snapshot/intent latency, every second, permanently -- not
just an occasional per-request cost like the other additions.

controls() now runs on its own ticker, independent of the simulation
tick, and only takes s.mu at all if there's an actual pending command
to apply (the DB read itself needs no lock -- world.ID is immutable
after creation). The idle case, which is the overwhelming majority of
ticks, no longer touches s.mu for this at all.

Verified: go build/vet/test clean, and the full local e2e suite (7/7,
both spec files, including the admin-command test that exercises
controls() directly) passes across two runs.

If this doesn't change CI's result, it should be reverted and ruled
out -- the next candidate would be the new /worlds/<id> routing
rewrite or the added per-request ActiveCharacter DB lookups.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 13:55:15 -04:00
..