Files
NX2navi/runtime/vk_mem_heap.h
chrg6 7432f7375c Ask for the C runtime heap's summary before play only.
The memory report's system line asked for the heap's summary at every report until one was slow. The summary holds
the heap's lock, and every malloc of every thread with it, while it adds the heap up: 54 and 70 ms in two sessions
on an RTX 5090 PC, and the frame of the first report, 30 seconds into each session, took 55 to 82 ms, the longest
frame of play in both. One slow summary switched the question off, so every session paid for it once.

It is now asked for before play only (the boot and the title screen), and at every report with mem_census = 1,
which already accepts a late frame for the walk of the address space. In play the line gives what the runtime knows
it allocated, the same figure from one report to the next. The rule is in runtime/vk_mem_heap.h with
tests/mem_heap_check, which fails against the rule before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 08:53:26 -05:00

18 lines
1.4 KiB
C

// When the memory report asks for the C runtime heap's summary (vk_memory.c system_log, plat_heap_info). Header only,
// so that tests/mem_heap_check.c checks the rule without a device.
//
// The summary holds the heap's lock while it adds the heap up, and every malloc and free of every thread waits for
// it. With a heap of a few GiB that took 54 and 70 ms in two sessions (2026-11-14, RTX 5090 PC), and the frame of the
// first report, 30 seconds into each session, took 55 to 82 ms: the longest frame of play in both. One slow summary
// switched the question off for the rest of the run, so each session paid for it exactly once.
//
// The summary is therefore not asked for in play at all: only before play (the boot and the title screen, where a
// long frame is not seen and the heap is small), and no more once one was slow there. NX2NAVI_MEM_CENSUS=1, the
// switch that already accepts a late frame for the walk of the address space, asks for it at every report. In play
// the report gives what the runtime knows it allocated instead, the same figure from one report to the next, which is
// what the growth bookkeeping compares.
#pragma once
// census: NX2NAVI_MEM_CENSUS is on; in_play: a save's first frame was shown; slow: a summary took too long before.
static inline int mem_heap_summary_due(int census, int in_play, int slow) { return census || (!in_play && !slow); }