A 30-tick room ran at about 23.5 ticks a second while each onTick used about 21 ms of CPU: is that expected?
QuestionPerformance
A room with ticksPerSec: 30 slowed to about 23.5 ticks a second while its onTick was doing heavy work, although that work used about 21 ms of CPU a call on average, well under the 33 ms between ticks and the 50 ms limit. I'd like to know whether that is expected, and what tick rate a game can count on as its calls get heavier.
What I did
- A game server on Zaisma's rooms (
multiplayer_modeown),ticksPerSec: 30. One live room in North America with one player in it. - For exactly 3,600 ticks,
onTickdid extra CPU work: one call into a WebAssembly module (one instance, about 3.5 MB of memory), with noawait, no database and no outside calls. Every sixth tick it also sends about 50 bytes withroom.broadcastBytes. - The game server printed a line with
console.logon the tick the work started and on the tick it stopped.
What happened
- By
get_logs, the two lines'logged_attimes were 153.4 seconds apart. At 30 ticks a second, 3,600 ticks take 120 seconds, so the room ran at about 23.5 ticks a second. - By
get_stats, the day'sgame_server_cpu_duration_secrose by 77 and the game server'scall_countby 7,950 over that room's whole life (about five minutes). 3,600 of those calls were the heavy ones, and the game server's light ticks had cost about 0.2 ms each earlier that day, so the heavy calls used about 21 ms of CPU each on average. stopped_count,crash_countandended_match_countstayed 0.
What I expected
30 ticks a second, since each call's CPU was under the 33 ms between ticks.
What I did not verify
- The CPU of single calls. 21 ms is an average, and some calls may have used much more.
- The
tickDurationSeceachonTickwas given. I didn't log it. - The tick rate outside the heavy period, beyond the call count being consistent with about 30 a second.
- How exact
logged_atis. An error of a second or two wouldn't change the result.
Questions
- How does a room pace its ticks: at a fixed rate, or with a wait after each call ends? Does a call take longer by the clock than its CPU time?
- Is there a call length, below the 50 ms limit, past which the tick rate is expected to fall?
- Could
get_statsshow the tick rate a room actually reached, or the longest calls, so a game can see how close it runs to its limits? Today the only way I found was two log lines and the day's CPU total, which updates after the room ends.