N8: Stop the soak player holding old islands, and count live islands

The soak's client memory growth (17 to 20 MB, about five islands, in some
processes) came from SoakPlayer keeping a strong reference to the last world it
played on. It let go only when its client next asked it for a command on the
new world, so finished islands stayed alive across a match change. It now keeps
only the island's seed.

LiveCount counts live Simulations and SimGrounds, which are made on worker
threads too, so it is thread-safe. The soak clients log the counts, and the
soak report fails if, a minute into a match, any island is alive that isn't a
client's world or one being made. That makes a leak name itself instead of
showing up as bytes.

Refs #39

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 09:01:49 -05:00
co-authored by Claude Opus 5.5
parent 4993601616
commit 880e001fbb
8 changed files with 101 additions and 6 deletions
+13 -3
View File
@@ -116,11 +116,14 @@ func _process(delta: float) -> bool:
return false
## How many distinct worlds this process's clients still reach: their own, and the
## ground their prediction runs on.
## How many distinct worlds this process's clients still reach (their own, the ground
## their prediction runs on, and islands made in the background but not yet taken
## up), and how many Simulations and grounds are alive in all. `extra_islands` counts
## live Simulations nothing here accounts for: a leak (#39).
func _live_worlds() -> Dictionary:
var worlds: Dictionary = {}
var grounds: Dictionary = {}
var built: int = 0
for client: Dictionary in _clients:
var game: ClientGame = client["game"]
if game.world != null:
@@ -128,7 +131,14 @@ func _live_worlds() -> Dictionary:
var ground: SimGround = game.prediction.get("_ground")
if ground != null:
grounds[ground.get_instance_id()] = true
return {"worlds": worlds.size(), "prediction_grounds": grounds.size()}
var made: Simulation = game.get("_built")
if made != null and made != game.world:
built += 1
if game.building_world():
built += 1
var live: int = LiveCount.of(&"Simulation")
return {"worlds": worlds.size(), "prediction_grounds": grounds.size(), "built": built,
"live_simulations": live, "live_grounds": LiveCount.of(&"SimGround"), "extra_islands": maxi(0, live - worlds.size() - built)}
## Keeps track of a client's phases, and reports each match it played once it's over.
+8
View File
@@ -165,6 +165,14 @@ func _client_growth(lines: Array[Dictionary]) -> int:
var worst: int = 0
for process: int in by_process:
worst = maxi(worst, _judge(by_process[process], "client process %d" % process))
# A minute into each match, every island alive must be a client's world or one being
# made. Anything more is an island nothing should still hold (#39).
for record: Dictionary in lines:
if String(record.get("event", "")) != "memory_late":
continue
var extra: int = int((record.get("worlds", {}) as Dictionary).get("extra_islands", 0))
if extra > 0:
_fail("client process %d still held %d islands beyond its clients' worlds in match %d" % [int(record.get("_process", 0)), extra, int(record.get("match", -1))])
return worst