Merge the audit: its map and ledger, the perf-trace markers and size lines, and the fixes of its Phase 4.

Verified by runs in the audit: the Market's periodic stall (a pool slot was listed once per refresh pass instead of once; the list fell from 160,385 entries to at most 3,192 and no frame over 20 ms remained while standing), orderly exits delete the pipeline prebuild's running marker (left behind, the next start wrote a skip file and every later start skipped the prebuild), the log and crash report name an area a save asks for that the game does not have, and the menu atlas hash no longer overflows a signed multiply. The other fixes compile and pass the regression route but their faults were never reproduced: see AUDIT.md section 13 for each.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-11 00:39:08 -05:00
36 changed files with 3108 additions and 44 deletions

View File

@@ -530,10 +530,12 @@ static volatile uint32_t cache_merges;
static VkResult pipe_create_in(int kind, void *ci, VkPipeline *pipe, VkPipelineCache cache) {
int shared = cache && !own_cache;
if (cache && own_cache) cache = own_cache;
uint64_t t0 = perf_mark_begin(); // NX2NAVI_TRACE=perf: the create on any thread, its wait for cache_rw included
if (shared) plat_mutex_lock_shared(&cache_rw);
VkResult r = kind == 2 ? vkCreateComputePipelines(P.device, cache, 1, ci, NULL, pipe)
: vkCreateGraphicsPipelines(P.device, cache, 1, ci, NULL, pipe);
if (shared) plat_mutex_unlock_shared(&cache_rw);
perf_mark_end(PERF_M_PIPE, t0, 0);
return r;
}
@@ -4231,7 +4233,8 @@ static void prewarm_run(void) {
// GPU and driver in <dir>/pipeline-prewarm-skip.txt, and starts on them build no recorded pipelines ahead of play:
// each one is built at its first draw instead, as with NX2NAVI_PIPE_PREBUILD=0. Another driver version, or deleting
// the file, brings the prebuild back. Only the boot's own share is covered: a crash during play, where the pool also
// builds what the boot left, says nothing about these builds.
// builds what the boot left, says nothing about these builds. An orderly end of the process during the boot (the
// window closed, the guest's ExitProcess, a --seconds run) deletes the marker as well: only a process that died leaves it.
static int cache_dir(char *dir, size_t n);
static void gpu_key(char *out, size_t n);
static char PM_run[PLAT_PATH_MAX * 2 + 48];
@@ -6668,3 +6671,28 @@ int vk_pipeline_selftest(void) {
printf("vk_pipeline selftest: %s\n", ok ? "passed" : "FAILED");
return ok ? 0 : 1;
}
// NX2NAVI_TRACE=perf "mem: sizes" (perf.c): the pipeline table's entries with their pipelines and fast links (never
// evicted), layouts, stage libraries, the job queues and the pipeline-keys.bin set. A walk of the hash chains under P.lock
// held shared: the workers' inserts and a draw's memo miss wait for it (well under a millisecond).
void vk_pipeline_sizes(PerfSizes *s) {
uint64_t ent = 0, built = 0, fast = 0, libn = 0, libb = 0, lq = 0;
plat_mutex_lock_shared(&P.lock);
for (int i = 0; i < PIPE_BUCKETS; i++)
for (const Pipe *p = pipes[i]; p; p = p->next) ent++, built += p->info.pipeline != VK_NULL_HANDLE, fast += p->fast != VK_NULL_HANDLE;
for (int i = 0; i < LIB_BUCKETS; i++)
for (const Lib *b = libs[i]; b; b = b->next) libn++, libb += b->pipe != VK_NULL_HANDLE;
for (const LibJob *j = U.head; j; j = j->next) lq++;
uint64_t lay = P.stats.layouts, fails = P.stats.failures, jobs = A.inflight, seen = K.seen_n, seen_b = (uint64_t)K.seen_cap * 8;
plat_mutex_unlock_shared(&P.lock);
perf_size(s, "pipeline entries", ent, 0, PERF_SIZE_NONE);
perf_size(s, "with a pipeline", built, 0, PERF_SIZE_NONE);
perf_size(s, "fast links", fast, 0, PERF_SIZE_NONE);
perf_size(s, "pipeline failures", fails, 0, PERF_SIZE_NONE);
perf_size(s, "pipeline layouts", lay, 0, PERF_SIZE_NONE);
perf_size(s, "stage library entries", libn, 0, PERF_SIZE_NONE);
perf_size(s, "built stage libraries", libb, 0, PERF_SIZE_NONE);
perf_size(s, "library jobs queued", lq, 0, PERF_SIZE_NONE);
perf_size(s, "pipeline jobs queued or running", jobs, 0, PERF_SIZE_NONE);
perf_size(s, "pipeline keys seen", seen, 0, seen_b);
}