Repository navigation
No pulling stand-ins for predicted keys with a made base - #2262
roandegraaf wants to merge 1 commit into
Conversation
…e is made: pso_predict_rest_ asks pso_base_made first, hands nothing to the background for such a key and leaves it out of later candidates (g_pp_easy), instead of making a stand-in (an archive lookup of the pulling base on the submit thread) for every key it proposed, outside its budget of 2. A Metal 4 base does not depend on the depth and stencil formats, so a draw's key without those attachments, which the prediction proposes for a pass that attaches them on demand, shares the drawn key's base; it is rarely drawn, so it never entered g_pso, a prewarm list or the archive's use, and every prediction of every run proposed it again. Ocarina of Time's Hyrule Castle Town (v131072, a host on 8db5dd4, Apple M4 Pro, headless, one run a side): the route's three predictions 30.8 / 104.4 / 54.5 ms on the submit thread, one of them 160 stand-ins with 100 found archive lookups and a frame of 149 ms, → 0.5 / 2.0 / 1.4 ms; pulling pipelines made 244 → 1. t_pso_depth_stencil's prediction_made_base pins it (its prediction case takes a second library, whose keys have no base made). Open: a proposed key with no base made still gets its stand-in lookup on the submit thread; no five-game regress run (one game built on this Mac), not repeated in the game on ced3612
…whose base is made: after a submission's first pipeline miss, pso_predict_rest_ proposes each remaining draw's key and that key without its depth / stencil attachment, and with hybrid pipelines it made the pulling stand-in of every proposed key to learn whether its draw would wait, an archive lookup of the pulling base on the submit thread each, outside its budget of 2 builds. A Metal 4 base does not depend on the depth and stencil formats (pbase_key, pso_desc4), and a draw asks for its own pipeline without compiling before any stand-in (pso_build_ex(..., 0)), so a key whose base is made is one specialization away and its stand-in was never used; the attachment-free keys are rarely drawn, never enter the pipeline cache or a prewarm list, and were proposed again in every run. The prediction now asks first whether the key's base is made (pso_base_made): such a key gets no stand-in and no background build and is left out of later predictions' candidates (g_pp_easy). Without Metal 4 bases nothing changes; with DM_PSO_HYBRID=0 such a key is specialized by its draw instead of in the background. The author's measurement, Ocarina of Time v131072 entering Hyrule Castle Town on an M4 Pro, one run a side on a host from 8db5dd4: the three predictions 30.8 / 104.4 / 54.5 ms -> 0.5 / 2.0 / 1.4 ms on the submit thread, pulling pipelines made 244 -> 1. On main: t_pso_depth_stencil (new case prediction_made_base; 293 / 296 / 293 / 296 checks), t_pso_pending, t_pso_archive, t_pull, t_pso_warm, t_pso_stall, t_pso_bundle, t_pull_inv and test_docs pass and the host builds; no game run and no regress run on main. Open: a proposed key with no base made still gets its stand-in lookup on the submit thread (PR #2262) Co-authored-by: Roan de Graaf <36153028+roandegraaf@users.noreply.github.com>
|
Landed unchanged on main as 6a6a018, with you as co-author. Thank you: the diagnosis holds on current main (a base carries no depth or stencil format, and a draw asks for its pipeline without compiling before any stand-in), and the pipeline tests, the docs test and the host build pass there. Still open, as your description says: a proposed key with no base made gets its stand-in lookup on the submit thread. No game was run on main with the change here, so the town-entry numbers remain yours from 8db5dd4; a run on current main would be welcome if you have the route at hand. |
|
Re-measured on ced3612 with its own shader libraries (chain bc8830d4ba5a), as asked above; this is the PR's commit 038492e on ced3612, not main at 6a6a018. The direction of the body's result holds, the sizes are smaller: from a warmed archive the baseline spent 0–71.5 ms a run in predictions on the submit thread and made 0–157 pulling pipelines for 0–60 draws that used one; the branch spent 0–4.3 ms and made 0–8 for 0–1. The branch does not get to "1 pulling pipeline for 1 draw" as the body has it: in the 2 of 6 runs where a prediction still cost time it made 5 and 8 for one draw, which is the open case of the description (a proposed key with no base made). Machine and settings: Apple M4 Pro (20-core GPU, 24 GB), macOS 27.2, profile
Notes on the table:
Pictures: one frame 44 s into each run ( Tests on the branch at ced3612, all 0 failed: Not checked: main at 6a6a018 itself (the host and the shader libraries here are ced3612's), a cold archive, a real window, iOS, other games. GPU time by process was sampled from outside the host over 19 s inside the measured window. |
|
On the open case in the description (a proposed key with no base made still gets its stand-in lookup on the submit thread): in my fork, the prediction makes no stand-ins at all. Instead of calling
Those keys get no stand-in and no speculative build in the prediction. If one is drawn, Numbers, all from my fork (M3 Max, Ocarina of Time v131072). It doesn't have main's
These are other routes than roandegraaf's, so they don't compare one to one with the table above. The cost: a pair whose pulling base is neither made nor archived no longer gets a head start from the prediction ( If it's wanted on main, I can open a PR for |
…whose base is made: after a submission's first pipeline miss, pso_predict_rest_ proposes each remaining draw's key and that key without its depth / stencil attachment, and with hybrid pipelines it made the pulling stand-in of every proposed key to learn whether its draw would wait, an archive lookup of the pulling base on the submit thread each, outside its budget of 2 builds. A Metal 4 base does not depend on the depth and stencil formats (pbase_key, pso_desc4), and a draw asks for its own pipeline without compiling before any stand-in (pso_build_ex(..., 0)), so a key whose base is made is one specialization away and its stand-in was never used; the attachment-free keys are rarely drawn, never enter the pipeline cache or a prewarm list, and were proposed again in every run. The prediction now asks first whether the key's base is made (pso_base_made): such a key gets no stand-in and no background build and is left out of later predictions' candidates (g_pp_easy). Without Metal 4 bases nothing changes; with DM_PSO_HYBRID=0 such a key is specialized by its draw instead of in the background. The author's measurement, Ocarina of Time v131072 entering Hyrule Castle Town on an M4 Pro, one run a side on a host from 8db5dd4: the three predictions 30.8 / 104.4 / 54.5 ms -> 0.5 / 2.0 / 1.4 ms on the submit thread, pulling pipelines made 244 -> 1. On main: t_pso_depth_stencil (new case prediction_made_base; 293 / 296 / 293 / 296 checks), t_pso_pending, t_pso_archive, t_pull, t_pso_warm, t_pso_stall, t_pso_bundle, t_pull_inv and test_docs pass and the host builds; no game run and no regress run on main. Open: a proposed key with no base made still gets its stand-in lookup on the submit thread (PR seedds#2262) Co-authored-by: Roan de Graaf <36153028+roandegraaf@users.noreply.github.com>
What and why
Entering Hyrule Castle Town in Ocarina of Time hitched for about 150 ms, on every visit and in every run, even with all of the area's pipelines prewarmed and archived.
Cause. On a pipeline miss the replay predicts the pipelines the rest of the submission will need (
pso_predict_rest_,dm/gfx/nvn/nvn_mtl.m). With hybrid pipelines it made a pulling stand-in for every key it proposed, to learn whether that key's draw would wait: an archive lookup of the pulling base on the submit thread each, outside its budget of 2 builds. In the town, all the proposed keys were "alternatives": each draw's key without its depth / stencil attachment, for a pass that attaches them on demand. Those keys are rarely drawn, so they never enter the pipeline cache, the user's prewarm list or the archive's use, and every prediction of every run proposed them again. A Metal 4 base does not depend on the depth and stencil formats, so each alternative shares the base of the key that is drawn; a draw of it would take that base for a specialization without compiling. The stand-in was never needed.Change. General, in the host: the prediction first asks whether a proposed key's base is already made (
pso_base_made). If it is, the key gets no stand-in and no background build, and is left out of later predictions' candidates (g_pp_easy), where it used to fill the 160 places for alternatives. Without Metal 4 bases nothing changes.dm/games/0400486024DEC000/README.md(Frame rate, Found on this game).t_pso_depth_stencilgets the caseprediction_made_base; its olderpredictioncase now uses a second library, because its keys must have no base made.Open:
Checked
ced36121plus the change),GAME=0400486024DEC000, all pass:make -C dm/gfx/tests check_t_pso_depth_stencil293 / 296 / 293 / 296 checks in its four configurations,check_t_pso_pending52,check_t_pso_archive338,check_t_pull422,check_t_pso_warm123 and 123,check_t_pso_stall73,check_t_pso_bundle71,check_t_pull_inv6. With thepso_base_madetest in the prediction turned off,prediction_made_basefails 3 checks in each Metal 4 configuration.make -C dm/hostbuilds;python3 -m pytest -q dm/tools/tests/test_docs.pypasses.0400486024DEC000, v131072, chaincb2e91c138e3, on a host built from8db5dd45with and without the change: a recorded walk into Hyrule Castle Town replayed from a fixed save, headless, 70 s,DM_FPS_HOLD=off, one run a side; thepipelines up to frameand long-frame log lines compared. Not repeated in the game onced36121: only the tests and the build were run there.scripts/regress.py check --games: not run. Ocarina of Time is the only game built on this Mac. The prediction runs for every NVN game that misses a pipeline, so the change reaches all of them; the tests above are the only check outside this game.pulling pipelines madenew pipelines 1 + shader libraries 0, 123.8 ms in all, which includes prediction time)The log's summary before:
pipelines up to frame 1500: on the submit thread pipelines 123.8 ms, predictions 1 / 122.6 ms; all threads: archive lookups found 100 / 119.0 ms.In a later run with this and other pending changes together, the worst 300-frame window had 15.3 ms of pipeline work on the submit thread (6 predictions, 13.5 ms).
Two windowed play sessions on the same route before the change: 219.7 and 272.5 ms of pipeline work on the submit thread in the entry's 300-frame window, with frames of 150–172 ms. A second visit in a new run was no better, because the keys behind it are never drawn and so never recorded.
Docs
docs/reference/<subsystem>.mdentry, andpython3 dm/tools/docs_symptoms.pywas run (the symptom index)dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change