mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 21:49:57 -04:00
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:
@@ -3931,3 +3931,33 @@ void vk_mem_shutdown(void) {
|
||||
for (uint64_t i = 0; i < GEN_CHUNKS; i++) free(gen_chunk[i]), gen_chunk[i] = NULL, free(cgen_chunk[i]), cgen_chunk[i] = NULL;
|
||||
plat_mutex_unlock(&gen_lock);
|
||||
}
|
||||
|
||||
// NX2NAVI_TRACE=perf "mem: sizes" (perf.c): pool records, VRAM mirrors, the deferred destruction list, upload batches,
|
||||
// the staging cache and arena, the write-back merge snapshot pool and the shadow storage's base copies. Counters only:
|
||||
// cmd_lock is taken by every upload and release, so nothing is walked under it.
|
||||
void vk_mem_sizes(PerfSizes *s) {
|
||||
plat_mutex_lock_shared(&pool_lock);
|
||||
uint64_t pools = (uint64_t)pool_index.n, phys = (uint64_t)nphys;
|
||||
plat_mutex_unlock_shared(&pool_lock);
|
||||
plat_rmutex_lock(&cmd_lock);
|
||||
uint64_t dead_n = (uint64_t)ndead, infl = (uint64_t)ninflight, spare_b = (uint64_t)nspare, stg_n = (uint64_t)stg_ncache,
|
||||
stg_b = (uint64_t)stg_cache_bytes, arena_n = (uint64_t)narena_free;
|
||||
plat_rmutex_unlock(&cmd_lock);
|
||||
plat_mutex_lock(&snap_pool_lock);
|
||||
uint64_t snap_n = (uint64_t)nsnap_pool, snap_b = snap_pool_bytes;
|
||||
plat_mutex_unlock(&snap_pool_lock);
|
||||
plat_mutex_lock(&shadow_lock);
|
||||
uint64_t sb = s_sb_pages;
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
perf_size(s, "pool records", pools, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "of them physical", phys, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "VRAM mirrors", (uint64_t)__atomic_load_n(&m_live_n, __ATOMIC_RELAXED), 0,
|
||||
(uint64_t)__atomic_load_n(&m_live_bytes, __ATOMIC_RELAXED));
|
||||
perf_size(s, "deferred destructions", dead_n, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "upload batches in flight", infl, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "spare upload batches", spare_b, 0, PERF_SIZE_NONE);
|
||||
perf_size(s, "staging cache", stg_n, STG_CACHE, stg_b);
|
||||
perf_size(s, "free staging arena chunks", arena_n, ARENA_KEEP, arena_n * ARENA_CHUNK);
|
||||
perf_size(s, "write-back snapshot pool", snap_n, SNAP_POOL_N, snap_b);
|
||||
perf_size(s, "shadow base copies", sb, 0, sb * SB_PAGE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user