perf_bench.py: a load ends when meshing goes quiet too

Sections wait for their neighbours' light before they are meshed, so the
chunk counts settled while edge sections were still undrawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-15 02:58:34 +02:00
parent 2a91612928
commit 7d36d09edd
2 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ One game is started per render distance (8, 16 and 32 chunks by default), each f
## Known caveats
- **Fabric Loader is present in the vanilla runs**, to load the driver mod. The only patch it applies is the driver's frame hook, so its cost after startup is negligible, but its mod discovery and class transformation add to vanilla's startup time (the modded runs use the same loader).
- **Readiness is detected differently.** Horizon knows exactly how many chunks are pending; for vanilla the driver waits until the loaded chunk count is unchanged for a second with nothing left to compile, and takes the time of the last change. Both stop the clock at the last chunk arriving, within a frame or two.
- **Readiness is detected differently.** For Horizon the driver waits until nothing is queued, the chunk counts are unchanged for a second and meshing has gone quiet (fewer than 100 section meshes a second: blocks that change keep being remeshed), and takes the time of the last of these; sections wait for their neighbours' light before they are meshed, so the chunk counts alone stop the clock before the last sections are drawn. For vanilla it waits until the loaded chunk count is unchanged for a second with nothing left to compile, and takes the time of the last change. Both stop the clock within a frame or two of the last section drawn.
- **Locked or headless screens.** A window nobody can see is not composited. On a Mac whose session is locked, Horizon draws only with `--offscreen` (it renders into a texture and does not wait for the window), and vanilla keeps rendering into its window without it being shown. Such runs measure rendering without presentation and are marked `offscreen`; numbers for players come from runs with the window on a real screen.
- **Different graphics APIs.** Horizon renders with wgpu (Vulkan on Linux and Windows, Metal on macOS); vanilla 26.3 uses OpenGL (or its Vulkan backend when chosen). The backend each game used is stored with the results. This is part of what is being compared.
- **World generation is the same algorithm but not the same threads.** Both generate the same terrain (the parity harnesses check it), with their own threading; the work per chunk differs, which is also part of what is being compared.
+23 -10
View File
@@ -264,28 +264,41 @@ def poll(control, check, limit, interval=0.05):
raise TimeoutError(f"not ready after {limit} s")
# Fewer section meshes than this in a second is the game remeshing blocks that change (random
# ticks), not loading.
QUIET_MESHES_PER_S = 100
def wait_loaded(control, near, limit):
"""Waits until the player is spawned (near(position)), nothing is queued and
the resident and generated chunk counts have not changed for a second, as
the vanilla driver does; returns the time of the last change.
(pending_chunks alone misses work the threads have already taken; sections
are remeshed all the time as blocks change, so meshes are not counted.)"""
"""Waits until the player is spawned (near(position)), nothing is queued, the
resident and generated chunk counts have not changed for a second, as the
vanilla driver does, and meshing has gone quiet (fewer than
QUIET_MESHES_PER_S section meshes in a second: the last sections drawn);
returns when the last of these happened. (pending_chunks alone misses work
the threads have already taken, and sections waiting for their neighbours'
light; blocks keep being remeshed as they change, so meshes can't be
required to stop.)"""
deadline = time.time() + limit
last, changed = None, time.time()
last, changed, previous, meshing = None, time.time(), None, time.time()
while time.time() < deadline:
try:
s = control("status", timeout=10)
except (OSError, ValueError, RuntimeError):
s = {}
player = s.get("player")
now = time.time()
if not player or not near(player["position"]) or s.get("pending_chunks") != 0 or s.get("screen") == "title":
last, changed = None, time.time()
last, changed, previous, meshing = None, now, None, now
else:
counts = (s["chunks"], s["generated_chunks"])
if counts != last:
last, changed = counts, time.time()
elif time.time() - changed >= 1.0:
return changed
last, changed = counts, now
sample = (now, s["meshed_sections"])
if previous and sample[1] - previous[1] > QUIET_MESHES_PER_S * (now - previous[0]):
meshing = now
previous = sample
if now - max(changed, meshing) >= 1.0:
return max(changed, meshing)
time.sleep(0.05)
raise TimeoutError(f"not loaded after {limit} s")