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

@@ -2306,3 +2306,23 @@ int kern_svc(Cpu *c, uint32_t imm) {
}
return r;
}
// NX2NAVI_TRACE=perf "mem: sizes" (perf.c): guest threads, the handle table, the system-event table and fibers, each
// against its fixed size (the tables are fatal when full).
void kern_sizes(PerfSizes *s) {
uint64_t threads = 0, handles = 0, fibers = 0, ses;
plat_mutex_lock_shared(&G);
for (RtThread *t = g_all; t; t = t->all) threads++;
for (int i = 0; i < MAX_H; i++) handles += g_h[i].type != 0;
plat_mutex_unlock_shared(&G);
plat_mutex_lock_shared(&g_se_lock);
ses = (uint64_t)g_nse;
plat_mutex_unlock_shared(&g_se_lock);
plat_mutex_lock_shared(&g_fiber_lock);
for (int i = 0; i < FIBER_MAX; i++) fibers += g_fibers[i] != NULL;
plat_mutex_unlock_shared(&g_fiber_lock);
perf_size(s, "guest threads", threads, 0, PERF_SIZE_NONE);
perf_size(s, "handles", handles, MAX_H, PERF_SIZE_NONE);
perf_size(s, "system events", ses, sizeof g_se / sizeof *g_se, PERF_SIZE_NONE);
perf_size(s, "fibers", fibers, FIBER_MAX, PERF_SIZE_NONE);
}