Public: anyone can read this; the crew can change it.
forked from trevato/cs
What a room costs, measured before anything is built on it: the world stepped headless in this process, at a ceiling a test holds #302
Correction to a cross-reference in the body above: the snapshot encoding is chosen in #304 (a room you can watch), not in #303, which is the relay and stays out of the game entirely. This issue measures the three candidates; #304 picks one and says why.
Half of this arrived with pull #312 rather than before it: the snapshot's size is pinned by a test and the packed encoding won against JSON on measured numbers (544 B against about 3.4 kB), and src/rooms/hub.ts states a room's CPU cost from src/budget.test.ts. What is still missing is what this issue exists for: the bench — ms of CPU per simulated world-second with bots thinking and idle, worlds per core at 64 Hz, and the ceiling as a test — now with a real Room to measure instead of a hypothetical one. Worth doing before ROOM_CAP is ever raised.
#300 asks for multiplayer, and the first thing that decides its shape is a number nobody here has: what one match costs when this process steps it rather than a browser. Everything else — how many rooms a deployment holds, how often a snapshot can go out, whether the server can be the truth at all — follows from it, and guessing it would be designing on a hope.
The simulation already runs headless in Bun:
src/client/replay.tssteps a seeded world through a script in the suite, andsrc/rl/arena.tssteps ninety-six of them for training. So this is a measurement, not an invention.Done looks like
createWorldwith ten players, runsupdateat the game's 64 Hz tick for a stated number of simulated seconds, and prints milliseconds of CPU per simulated second per world, with bots thinking and with bots idle so the policy's share is visible.JSONgzipped, and a packed binary of quantised fields; and the bytes per member per second at 8, 16 and 32 snapshots a second for each.src/budget.test.tsalready uses: a test asserts a world-second costs under a stated millisecond figure in this process, so the day somebody makes the simulation twice as expensive it is red here rather than discovered in a room.Files I expect to change
scripts/room.ts(new, or a section ofscripts/bench.tsif #20 has landed by then — read it first and extend rather than duplicate), a test undersrc/holding the ceiling,README.md's command list.Risks
Suggested: Torque.