Repository navigation
perf(shader): keep memoized results in a set-associative table - #6733
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Data point from a CPU-bound scene on Windows: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows,
Within the run-to-run spread ( AI-assisted: yes (Claude Code) |
|
Checked the hit/insert paths under |
What
materializePreparedMemoizedkeeps each source's materialized results by variant and snapshot hash, so a capture that reproduces a snapshot gets the shared result instead of a freshPopulate. The memo is astd::listin LRU order with anunordered_mapindex (256 entries). Every hit splices the list. Every insert allocates a list node and a hash node, and evicts the oldest, which frees two more.The memo is now a fixed table of 64 sets of 4 entries per source, allocated with its first insert:
The eviction policy changes from LRU over all 256 entries to LRU within a set of 4.
On the S2 page of Sonic Origins Plus's main menu, the queue worker spent, per frame (APS5 sampler, 15 s):
materializePreparedMemoizedminus thematerializeResultit calls on a miss): 1.87 to 1.92 in three runs without this change, 1.33 to 1.60 in four runs with it;materializeResult, the misses' work: 2.3 to 2.9 in all seven runs, so the sets do not miss noticeably more.That is about 1.2% of the worker's frame (31 to 33 samples), so the frame times below move within run-to-run noise.
The change is in the recompiler's sources, so the shader cache version changes with it.
Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.
agc_device_faultwas linked again and rerun after a locked file stopped its first link.)agc_driver_gpu_indirect_arguments_misaligned_writer_aheadis not run: main itself does not compile it with MinGW (alignas(65536)).agc_driver_multisample_fill_host_onlyfailed once ("the sentinel fill did not land"). That is main's own race, agc_driver_multisample_fill_host_only fails intermittently: the sentinel fill after an absorbed multisampled clear does not land #6512, which fix(agc): record a multisampled target's commands on its own device #6522 fixes; with fix(agc): record a multisampled target's commands on its own device #6522's line added it failed 0 of 200 runs (8 at a time).APS5_TRACE_SECONDS=200:15on the same machine in one session, caches warm. Traces attached.The FPS shown in the title went from 10.36 to 10.48 (median of six readings), and a sampled pair taken about 40 minutes earlier went from 10.50 to 10.82. Last night's windows of this page varied by about 5% at the median, so this pair's gap is mostly noise.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Traces and summary lines (baseline 40a9184, whose summary says 390f624; this change 11882cc, whose summary says 40a9184):
memo-traces.zip