From f5227b731d2ec6cfdf909f53bdafe19fc039f891 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 17:59:31 -0500 Subject: [PATCH] H17: Sample soak client memory at the results of a match decided in the drop The R5 gate's soak failed its client leak check: match 0 was decided during the drop (23 eliminations as the clients landed) and never reached play, which is the only phase soak_clients sampled memory in, so each client process had one sample instead of two. Hashes, tick timing and server memory all passed. A match that never reaches play is now sampled at its results, and the memory line says which phase it was taken in. The rule is a static function, SoakClients.samples_memory_in, covered by a new test. A results sample can sit a little above a play sample, so a run that samples match 0 at its results is slightly lenient on growth from it. Closes #86 Co-Authored-By: Claude Opus 5.5 --- test/net/test_soak_memory_sample.gd | 17 +++++++++++++++++ test/net/test_soak_memory_sample.gd.uid | 1 + tools/soak_clients.gd | 15 ++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 test/net/test_soak_memory_sample.gd create mode 100644 test/net/test_soak_memory_sample.gd.uid diff --git a/test/net/test_soak_memory_sample.gd b/test/net/test_soak_memory_sample.gd new file mode 100644 index 0000000..728b9f6 --- /dev/null +++ b/test/net/test_soak_memory_sample.gd @@ -0,0 +1,17 @@ +extends TestCase + +## R5: the soak samples each client process's memory once a match. A match can be +## decided during the drop (test_match covers that) and never reach play, so such a +## match is sampled at its results; otherwise the soak's leak check had too few samples. + +const SoakClients: GDScript = preload("res://tools/soak_clients.gd") + + +func test_memory_is_sampled_in_play_and_at_results() -> void: + assert_true(SoakClients.samples_memory_in(Match.PLAY)) + assert_true(SoakClients.samples_memory_in(Match.RESULTS), "a match decided during the drop") + + +func test_memory_is_not_sampled_before_play() -> void: + for phase: int in [Match.LOBBY, Match.COUNTDOWN, Match.DROP]: + assert_false(SoakClients.samples_memory_in(phase), Match.PHASE_NAMES[phase]) diff --git a/test/net/test_soak_memory_sample.gd.uid b/test/net/test_soak_memory_sample.gd.uid new file mode 100644 index 0000000..cf3ec44 --- /dev/null +++ b/test/net/test_soak_memory_sample.gd.uid @@ -0,0 +1 @@ +uid://clerstsk6qkiw diff --git a/tools/soak_clients.gd b/tools/soak_clients.gd index 1cdb612..91ab633 100644 --- a/tools/soak_clients.gd +++ b/tools/soak_clients.gd @@ -17,7 +17,8 @@ ## same N as --hash-every here), when the client's world has caught up exactly. ## {"event":"client_match", "client", "match", ...}: a client's prediction statistics ## for a match it played, once the match is over for it. -## {"event":"memory", "match", "mem_bytes"}: this process's memory as each match began. +## {"event":"memory", "match", "at", "mem_bytes"}: this process's memory as each match +## began play, or at its results for a match decided during the drop. ## {"event":"soak_client", ...}: one per client at the end. ## {"event":"soak_process", ...}: frame times, totals and errors, last. ## It stops when every client's connection has closed, or after --seconds. @@ -170,9 +171,11 @@ func _follow(client: Dictionary) -> void: elif int(client["stats_match"]) >= 0: _report_match(client) # Once a match is in play every client here has let go of the last match's world. - if game.match_phase == Match.PLAY and not _memory_logged.has(game.match_index): + # A match can be decided during the drop and never reach play; then it is sampled + # at its results instead, so every match still gives one sample. + if samples_memory_in(game.match_phase) and not _memory_logged.has(game.match_index): _memory_logged[game.match_index] = Time.get_ticks_msec() - print(JSON.stringify({"event": "memory", "match": game.match_index, "mem_bytes": OS.get_static_memory_usage(), "objects": Performance.get_monitor(Performance.OBJECT_COUNT), "worlds": _live_worlds()})) + print(JSON.stringify({"event": "memory", "match": game.match_index, "at": Match.PHASE_NAMES[game.match_phase], "mem_bytes": OS.get_static_memory_usage(), "objects": Performance.get_monitor(Performance.OBJECT_COUNT), "worlds": _live_worlds()})) elif game.match_phase == Match.PLAY and _memory_logged.has(game.match_index) and _memory_logged.has(-1 - game.match_index) == false \ and Time.get_ticks_msec() - int(_memory_logged[game.match_index]) > LATE_MEMORY_MSEC: # A second look a minute later, for telling a leak from something let go late. @@ -180,6 +183,12 @@ func _follow(client: Dictionary) -> void: print(JSON.stringify({"event": "memory_late", "match": game.match_index, "mem_bytes": OS.get_static_memory_usage(), "objects": Performance.get_monitor(Performance.OBJECT_COUNT), "worlds": _live_worlds()})) +## Whether a client's memory is sampled for a match in `phase`: when it begins play, or +## at its results if it was decided during the drop and never reached play. +static func samples_memory_in(phase: int) -> bool: + return phase == Match.PLAY or phase == Match.RESULTS + + func _report_match(client: Dictionary) -> void: var stats: Array = client["last_stats"] var record: Dictionary = {