From b7c678540e2310196a1cce9d7e5dc8ccd6b563ce Mon Sep 17 00:00:00 2001 From: chrg6 Date: Fri, 13 Nov 2026 17:49:15 -0500 Subject: [PATCH] Give the frames presented at the start and end of a census walk on the "mem: process" line, not seconds since boot. The review of c05e6528 found that vk_memory.c census_main printed the walk's start and end as kern_now_ns / 1e9, which is plat_now_ns: seconds since Windows started. No other log line uses that clock (the stutter lines give seconds since the first frame, the slow-frame and present lines frame numbers), so the walk could not be set beside the frames it held up, which is what a play-test with mem_census = 0 needs to tell the walk from the presenting thread's report as the cause of the 600N+1 hitches. census_main now reads span_frame, the frame vk_mem_census sets at every present, beside each end of the walk and logs "the walk from frame F0 to frame F1, N ms": the numbers the "stutter: frame" and "perf: slow frame" lines carry. The walk's length stays. Diagnostics only: the line is logged with NX2NAVI_MEM_CENSUS = 1, which defaults to 0. Not reproduced (it needs a game run). No tool or test reads the line. vk_memory.c compiles with the dev flags and adds no -Wall -Wextra warnings. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_memory.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/vk_memory.c b/runtime/vk_memory.c index cc4e13e1..0826b69f 100644 --- a/runtime/vk_memory.c +++ b/runtime/vk_memory.c @@ -4559,17 +4559,18 @@ static void census_main(void *arg) { free(arg); const double M = 1048576.0; uint64_t priv = 0, wc = 0, wcn = 0, now; - // perf.c ft_frame charges the frames the walk overlapped to "census"; the line gives the walk's span on the run's - // clock (kern_now_ns) so that it can be set beside the frames it held up + // perf.c ft_frame charges the frames the walk overlapped to "census". The line gives the frames presented when the + // walk began and ended (span_frame, which vk_mem_census sets at every present) and its length: the frame numbers + // are the ones the "stutter: frame" and "perf: slow frame" lines carry, so it can be set beside the frames it held up perf_census_walk(1); - uint64_t w0 = kern_now_ns(); + uint64_t w0 = kern_now_ns(), f0 = __atomic_load_n(&span_frame, __ATOMIC_RELAXED); int have = plat_mem_census(&priv, &wc, &wcn); - uint64_t w1 = kern_now_ns(); + uint64_t w1 = kern_now_ns(), f1 = __atomic_load_n(&span_frame, __ATOMIC_RELAXED); perf_census_walk(0); if (have) { - rt_log("mem: process frame %llu: private %.0f MiB, write-combined %.0f MiB in %llu allocations; the walk %.3f s " - "to %.3f s, %.1f ms", (unsigned long long)j.frame, priv / M, wc / M, (unsigned long long)wcn, w0 / 1e9, - w1 / 1e9, (w1 - w0) / 1e6); + rt_log("mem: process frame %llu: private %.0f MiB, write-combined %.0f MiB in %llu allocations; the walk from " + "frame %llu to frame %llu, %.1f ms", (unsigned long long)j.frame, priv / M, wc / M, + (unsigned long long)wcn, (unsigned long long)f0, (unsigned long long)f1, (w1 - w0) / 1e6); uint64_t used = 0, budget = 0; int exact = 0; if (!vk_mem_vram(&used, &budget, &exact)) used = 0;