WIP: perf(vk): new pipelines are in the game's own cache before their first draw, which asks it instead of being left out #40
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
needs measurements
question
testing wanted
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!40
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/first-draw-asks-caches"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status: not ready to merge. The first-draw ask and the warm's cost are measured in a game; the cap on the warm, the hit rate of what it keeps and the budget for long frames have not run in a game (see "Not tested yet").
What
Two parts:
RX_VK_WARM_PREDICTED_MB;0: none, the pass is not made) or after 60 s (RX_VK_WARM_PREDICTED_S). The pipelines of programs a list names in another variant go first. What it does not reach is asked for at first draw and built by the workers where no cache has it, as on main.RX_VK_WARM_PREDICTED=0: off. It is skipped where the same process prepared the shaders.It runs only where programs are loaded at create calls (GPUs with native mesh shaders, no
longshot_load_start.txt, no compressed program cache, orRX_VK_LOAD=create), in a play process's first start on a folder without the "built" marker. Where programs are loaded before the title (start mode) the start keeps every listed pipeline ready as before and this pass does not exist.RX_VK_FIRST_ASK=0: off.Why the game's own cache
What an ask for a predicted pipeline costs in a later session (RTX 3090, Linux; 32 sampled predicted pipelines asked at start-up, the ask alone timed; all 32 answered each time):
Only the game's own cache answers in well under a millisecond. On NVIDIA the cache file a
--prepare-shadersprocess writes does not answer the game's process, so the game has to build them itself once.What it costs, and why the cap
A folder prepared by
--prepare-shaders(the Builder's way), then the game; RTX 3090, Linux, loads at create calls, a short tour of three areas. These runs put all 50,547 predicted pipelines into the cache (the commit before the cap):RX_VK_WARM_PREDICTED=0Start mode: only the ask changes
RX 580 (RADV, no mesh shaders, so start mode by default), 16 GB, a cold
--prepare-shaders(2,040 s), then the game's first start twice from that same prepared state:RX_VK_WARM_PREDICTED_MB=0Game tests of the ask
A new game's opening on a freshly prepared folder, RTX 3090, Linux, prepared inside the game's own start:
6a18ec05)The two sessions are not the same route or length, so the counts are not a strict before/after.
Not tested yet
first draws:line splits the answers by own cache and driver.first draws:line counts the frames stopped that way.Tests
tests/test_first_ask.py: the budget rule compiled and run alone; source checks that the ask is without compiling, inside the budget and before the worker hand-off.tests/test_warm_bounded.py: the time bound and the cap as rules; source checks that the pass builds into the game's cache, is bounded both ways, and that the marker is still written after the cache is saved.test_program_load_wait,test_program_lifeand the predict tests pass. The renderer builds on Linux.On hold, and its numbers should not be read as they stand.
Two more game tests on a folder prepared the Builder's way (a separate
--prepare-shadersrun, then the game) show that this pull request's code had nothing to do: a new game's opening and play, 22,288 frames, had 0 first-draw asks, 0 draws left out and 0 pipelines compiled; another session of 22,444 frames had 1 ask. In both, 7,519 and 10,260 graphics pipelines were made ready when the game created their programs.The two sessions in the description's "Game tests" table (113 and 42 frames with draws left out) were on folders that the game prepared inside its own start. In such a start the programs the state list reads lose their records, the index of kept program keys has 32,719 keys instead of 47,866, and about 5,300 create calls for listed programs get nothing made ready ("8192 create calls with nothing kept for their stages" against 2,743). Their pipelines are then fetched at first draw and the draws are left out meanwhile. So that table measured a defect of the preparing start with listed pipelines, not pipelines no list names.
Next: confirm that with one controlled pair, fix the preparing start on its own branch, then see what is left for the first-draw ask. The capped warm did run here for the first time: 4.7 s, 16,404 of 50,954 predicted pipelines kept, 253 MB added; no session so far shows a benefit from it.
Closing. A controlled pair confirms what the comment above says: the same build, folder and tour, in create mode, prepared two ways.
--prepare-shadersSo the pop-in belongs to the start that prepares in its own process, with listed pipelines that no create call asked for, and a folder prepared the Builder's way has nothing for this pull request to act on. The fix for the preparing start is a separate, smaller change: let the programs the state list read go and give their records back before the create-time index is built (not written yet).
What was measured here and may be useful later: a pipeline asked at first draw costs about 0.3 to 0.4 ms from the game's own cache, 3.5 ms from NVIDIA's disk cache and 2.1 ms from the driver's memory; keeping all 50,547 predicted pipelines in the game's cache costs about 650 MB a session (about 14.6 KB each).
Pull request closed