mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 12:55:57 +00:00
A switch to turn off the perf trace's dirty census, which slows a traced Steam Deck run by about 3% (#946)
TOTK_PERF_CENSUS=0 (perf_census in totk.ini) keeps TOTK_TRACE=perf and its frame lines but skips the write-watch queries the census makes at every submit, so a perf trace on Linux measures the frame without them. On an LCD Steam Deck at Lookout Landing (dev, three interleaved runs each) the census costs about 0.8 ms a frame: 38.0-38.3 fps with it, 39.1-39.4 fps without, 1% low 30.5-31.5 against 32.1-33.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0aa6f15dc
commit
14fa37a318
5 files changed
+16
-6
No files matched your search
@@ -32,6 +32,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `menu_cursor_log` | `1` logs what the menu cursor code reads at every screen change. | Only adds log lines. | Safe |
|
||||
| `plugin_tick_offset` (default `0`) | Added to every GetSystemTick in the plugin service run (`totk.exe --plugin-init DIR`), so `tools/exefs_plugins.py` can run a plugin's init twice with other ticks and compare the records. | Has no effect outside `--plugin-init`; a plugin's init at the start of the game gets the plain ticks. | Safe |
|
||||
| `plugin_trace` (default `0`) | `1` logs the first call of each entry of a mod plugin's hooks (its callbacks, replace and call targets) as `plugins: hook entry ... reached`. | Each such call goes through a counting step; nothing changes without a mod plugin. | Safe |
|
||||
| `perf_census` (default `1`) | With `TOTK_TRACE=perf`, `0` turns off the dirty census: the `mem: dirty` lines that count, at every submit, the pages the CPU wrote in the pools the replay binds as buffers. | The census queries the write watch at every submit, 3.5-5 ms of the replay thread a frame on a Steam Deck; with `0` a perf trace measures the frame without that cost, and `tools/perf_summary.py` prints no dirty lines. | Safe |
|
||||
| `perf_slow_ms` (default `50`) | Frames at least this many milliseconds long get a `perf: slow frame` log line with the time blocked per cause. | Changes how many frames are logged; a small value fills the log. | Safe |
|
||||
| `replay_check` | `1` reads every texture read-back a second time after a full drain of the replay queue and compares the two. | Stalls the replay queue at every read-back, so frames get much slower; mismatches are only counted and logged. | Caution |
|
||||
| `resolve_check` | `1` compares every cached pool lookup with the locked lookup and stops on a difference. | Slows every pool lookup; the game stops if the two ever differ. | Caution |
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ static const char *const known[] = {
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_NO_CODE", "MODS_ORDER", "MODS_REBUILD", "MODS_WITHOUT_CODE", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
"MV_SURVEY",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_CENSUS", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_BENCH", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "QUICKLOAD_KEY", "QUICKSAVE", "QUICKSAVE_KEY", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHUNKS", "REPLAY_CHUNK_DRAWS", "REPLAY_SKEW_US", "REPLAY_STATE_CHECK", "REPLAY_WORKERS",
|
||||
|
||||
+5
-2
@@ -244,9 +244,12 @@ void vk_mem_count_flush(int64_t (*acc)[VK_MUSE_N]);
|
||||
// TOTK_TRACE=perf dirty census (vk_memory.c): the replay notes each imported pool it binds as a vertex, index, uniform,
|
||||
// storage or indirect buffer; at the start of every submit the pages the CPU wrote in such pools since the previous
|
||||
// submit are counted from the shared page generations and logged as `mem: dirty` every 60 frames. Nothing when tracing
|
||||
// is off: VK_MEM_BOUND is one flag test at the call site.
|
||||
// is off: VK_MEM_BOUND is one flag test at the call site. vk_mem_census_on: tracing perf, no mirror, and
|
||||
// TOTK_PERF_CENSUS not 0 (set at device selection). The census queries the write watch at every submit, which costs
|
||||
// the replay thread 3.5-5 ms a frame on a Steam Deck (#946), so measurements of the frame turn it off.
|
||||
extern int vk_mem_census_on;
|
||||
void vk_mem_bound_note(void *pool);
|
||||
#define VK_MEM_BOUND(sp) do { if ((rt_trace & RT_TRACE_PERF) && (sp).pool) vk_mem_bound_note((sp).pool); } while (0)
|
||||
#define VK_MEM_BOUND(sp) do { if (vk_mem_census_on && (sp).pool) vk_mem_bound_note((sp).pool); } while (0)
|
||||
void vk_mem_dirty_submit(void); // vk_sync_submit, under its lock, before the replay
|
||||
// VRAM mirror of buffer-bound pools (vk_memory.c). vk_mirror_on: TOTK_MEMORY=mirror|verify, or the
|
||||
// device class is discrete and TOTK_MEMORY is unset or auto; set at device selection. The replay (submitting thread
|
||||
|
||||
@@ -2986,7 +2986,7 @@ static void bind_vertex_buffers(VkExec *ex) {
|
||||
ex->recorded++;
|
||||
for (int b = lo; b <= hi; b++) {
|
||||
if (D->B.vcls[b]) vk_mem_count(D->B.vcls[b], VK_MUSE_VB, D->B.vsz[b]);
|
||||
if ((rt_trace & RT_TRACE_PERF) && D->B.vpool[b]) vk_mem_bound_note(D->B.vpool[b]);
|
||||
if (vk_mem_census_on && D->B.vpool[b]) vk_mem_bound_note(D->B.vpool[b]);
|
||||
}
|
||||
D->B.vb_valid = 1;
|
||||
}
|
||||
|
||||
+8
-2
@@ -544,7 +544,7 @@ void vk_mem_census(uint64_t frame) {
|
||||
mirror_frame = frame;
|
||||
static uint64_t window_start;
|
||||
if ((rt_trace & RT_TRACE_PERF) && frame % 600 == 0) vram_log(frame);
|
||||
if ((rt_trace & RT_TRACE_PERF) && !vk_mirror_on) dirty_frame(frame);
|
||||
if (vk_mem_census_on) dirty_frame(frame);
|
||||
if ((rt_trace & RT_TRACE_PERF) ? frame % 60 == 0 : frame == 600 || frame == 1800)
|
||||
mirror_log(frame), shadow_log(frame); // mirror_log also logs the write-watch line
|
||||
if (frame == 1200) { // loading is over: the first window starts here
|
||||
@@ -1476,7 +1476,7 @@ static void shadow_log(uint64_t frame) {
|
||||
}
|
||||
|
||||
void vk_mem_dirty_submit(void) {
|
||||
if (!(rt_trace & RT_TRACE_PERF) || vk_mirror_on) return; // the mirror's own line replaces the census
|
||||
if (!vk_mem_census_on) return; // tracing off, TOTK_PERF_CENSUS=0, or a mirror (its own line replaces the census)
|
||||
uint64_t t0 = kern_now_ns();
|
||||
uint32_t prev = dirty_sub; // the submit whose replay noted the bindings
|
||||
dirty_sub = prev + 1 ? prev + 1 : 1;
|
||||
@@ -1627,6 +1627,7 @@ static void dirty_frame(uint64_t frame) {
|
||||
enum { MR_BUDGET, MR_UNTRACKED, MR_OVERLAP, MR_ALLOC, MR_N };
|
||||
|
||||
int vk_mirror_on;
|
||||
int vk_mem_census_on; // vk.h: the TOTK_TRACE=perf dirty census runs (mirror_mode)
|
||||
static int mirror_verify;
|
||||
static int mirror_gap = 2; // pre-snap: hot pools at most this many 2 MiB regions apart share one query
|
||||
static PoolRec **mlist; // pool_lock: mirrored pools by import_lo
|
||||
@@ -1671,6 +1672,11 @@ static void mirror_mode(int discrete) {
|
||||
}
|
||||
vk_mirror_on = mode > 0;
|
||||
mirror_verify = mode == 2;
|
||||
// The dirty census is a measurement of its own (what a mirror would upload), not part of the frame: with
|
||||
// TOTK_PERF_CENSUS=0 a perf trace measures the frame without its write-watch queries.
|
||||
vk_mem_census_on = (rt_trace & RT_TRACE_PERF) && !vk_mirror_on && rt_knob("PERF_CENSUS", "1");
|
||||
if ((rt_trace & RT_TRACE_PERF) && !vk_mirror_on && !vk_mem_census_on)
|
||||
rt_log("mem: dirty census off (TOTK_PERF_CENSUS=0): no `mem: dirty` lines, no write-watch queries for them");
|
||||
const char *g = cfg_get("TOTK_MIRROR_GAP");
|
||||
mirror_gap = g && *g ? atoi(g) : 2;
|
||||
if (mirror_gap < 0) mirror_gap = 0;
|
||||
|
||||
Reference in new issue
Block a user