Log the sizes of the caches, pools and tables under the perf trace, every 600 presents and with each memory snapshot.

Four "mem: sizes" lines give the entries and bytes of what no other line counted: the guest heap, physical maps, kernel region, lazily written ranges and the fixed kernel, setjmp, save-file, RomFS and zstd tables; pool records, mirrors, deferred destructions, upload and staging buffers, the device address table and the texture, sampler and slot caches; image views, descriptor spares, the completion queue, uniform snapshot arenas, recording copies and pins; and pipelines, layouts, stage libraries, job queues, the shader memory cache and the translator processes. Each subsystem reads its own counters under its lock; settings now count the replaced values they keep. Segment and scene lines say "-" for the world clock before it starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 19:51:36 -05:00
parent ecd34fb513
commit ded13958de
18 changed files with 359 additions and 9 deletions

View File

@@ -1315,3 +1315,24 @@ const char *nvn_op_name(uint32_t op) {
_Static_assert(sizeof names / sizeof *names == OP_COUNT_, "one name per op");
return op < OP_COUNT_ ? names[op] : "?";
}
// NX2NAVI_TRACE=perf "mem: sizes" (perf.c): live recording copies and the zombies waiting for their submissions, texture
// pins with their sweep queue, and the recording-buffer pool.
void nvn_cmd_sizes(PerfSizes *s) {
plat_mutex_lock_shared(&copy_lock);
uint64_t nc = ncopies, cb = copy_bytes, nz = nzombies, zb = 0;
for (uint32_t i = 0; i < nzombies; i++) zb += zombies[i]->bytes;
plat_mutex_unlock_shared(&copy_lock);
plat_mutex_lock(&pin_lock);
uint64_t pins = pins_live, pq = pin_qn - pin_qh;
plat_mutex_unlock(&pin_lock);
plat_mutex_lock(&pool_lock);
uint64_t np = npool, pb = 0;
for (uint32_t i = 0; i < npool; i++) pb += pool[i].size;
plat_mutex_unlock(&pool_lock);
perf_size(s, "recording copies", nc, 0, cb);
perf_size(s, "recording copy zombies", nz, 0, zb);
perf_size(s, "texture pins", pins, 0, PERF_SIZE_NONE);
perf_size(s, "pin sweep queue", pq, 0, PERF_SIZE_NONE);
perf_size(s, "recording-buffer pool", np, POOL_SLOTS, pb);
}