tools: rank first shader refusals by the draws and dispatches they block #3198
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3198"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:28:43Z.
Part of #870
What this unblocks: picking the next translator gap by how many draws and dispatches it blocks in a real run, not by how many shader keys fail.
tools/startup/triage_run.pyalready counts.failreasons per key. A key that fails once and is never drawn counts the same as a key that blocks most of a frame. This addstools/startup/refusal_census.py, which reads a run's shader cache plus the stand-in stderr and weights each refused key's first refusal by the work the log says it blocked:<key>.fail; stage from the request files (.c67compute,.a/.bgraphics,.m57/.m86mesh,.rtv);x2w-render compute census keyline,no RTV translationandExecuteIndirectrefusal lines, and per-key use / not-drawn counts when a build prints them; a refused key that no line names weighs 0;triage_run.pyshader category when one matches, else the first refusal with registers, numbers and addresses normalized (R,N,H);--shareablekeeps only the fixed categories, liketriage_run.pyreports;--out-md), one TSV row per refused key (--out-tsv).How to run:
Tests:
startup_refusal_census(tests/startup_refusal_census_check.py): runs the tool on a synthetic cache and log; checks the TSV rows and weights (cumulative census lines take the last total, a refused key with no log line weighs 0, a translated key is not listed), the class ranking, that--shareabledrops unknown text, and that a missing log is a usage error.Verification:
python3 -B tests/startup_refusal_census_check.py-> 4 tests OKpython3 -B tests/startup_triage_run_check.py-> 0 failedcmake -S . -B /tmp/cfg -G Ninja -DDXC_EXECUTABLE=/bin/true-> configure OKA companion draft with the replay recorder and player follows; this tool is how we rank the first refusals that replays turn up.
Thanks to @Makto94 for the testing that found this.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:36:21Z.
Review: COMMENTED
Draft review on
fb4f718c: all fourpython -B tests/startup_refusal_census_check.pytests pass. An added synthetic row exposes a weighting error: a cached.failandx2w-render compute census key 1234567890abcdef: 12 dispatches, 10 translated, first refusal: examplereport blocked weight 12. The runtime's own by-reason census sumsdispatches - translatedind3d12_compute_dispatch.inl, so this key blocked 2. A cache refusal can be stale after successful translations. Please parse the translated count, prefer failure counters over total-use estimates for the same key, and cover partially recovered and fully translated counters. For a key with no matching log line, zero means the log recorded no evidence, since logs may be sampled or truncated.Imported from R0Y00/Xbox2Windows. Originally posted by xiaoqi72665 on 2026-11-27T22:54:19Z.
Independent follow-up to the review on
fb4f718c: I reproduced the 12 dispatches / 10 translated case (weight 12 instead of 2). There is also a separate runtime evidence gap.On main
e582a9a, the public source-built indirect translated/other refusal census fixtures on RX 7900 XT and WARP produced 14 per-reason detail lines across four successful fixture runs. For example:(The key and sequence above are synthetic.) Calling load_weights([log]) at this PR head returns an empty Counter for both that minimal log and the 14 actual lines. The existing per_reason_refusal_census.h reports cumulative counts with periodic and final repeats; this synthetic sequence means 5 runtime refusals, not 12. Runtime-only keys need not have .fail files, and the zero key is unattributed. I would keep these counters separate from first shader refusal attribution rather than blindly add them to shader weights; a missing log match is unknown evidence, not proof of zero failures.
Reproduction: build startup_indirect_draw_indexed on main; run ctest --preset release --no-tests=error -j1 -R "^startup_indirect_(translated|other)refusal_census(warp|hardware)$" -V; pass the per-reason detail lines to load_weights. Existing census unit tests passed 4/4. Happy to coordinate a focused test-only follow-up if useful; not opening a competing implementation. Buhe; AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T23:20:25Z.
Pushed
09e8189c7(merged with currentmain) for the weighting findings.dispatches - translated: 12 dispatches with 10 translated gives 2, and a fully translated key gives 0 even with a cached.fail. The old line form withouttranslatedstill works. Failure counters win over use estimates for the same key.Verification:
python3 -B tests/startup_refusal_census_check.py: 6 tests OK (new cases: 12/10 -> 2, 12/12 -> 0 with a.fail, legacy line, 2/5/5 -> 5).python3 -B tests/docs_links_check.py,git diff --check,cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true,public_guard.py.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T23:36:02Z.
Review: COMMENTED
I retested
09e8189cintegrated overmainfad97f47(clean trial treef6749198). The weighting issue in my earlier draft review is addressed: the 12-dispatch/10-translated case weighs 2, a fully translated key with a cached refusal weighs 0, and the older lines still parse. In the new indirect detail tests, repeat cumulative counters retain the final count, the zero key is excluded, and the per-reason rows do not inflate the shader totals.python -B tests/startup_refusal_census_check.pypassed 6/6,tests/startup_triage_run_check.pyreported zero failures, and the docs check passed. The source fixture results are recorded here while the PR stays in draft.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T23:48:14Z.
Review of
09e8189c(integrated over main):Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T22:01:55Z.
Merged current
maininto this branch (merge commit, no force push, no conflicts); head is nowac13b5d34. No change to the PR's own files since the weighting fix that @R0Y00 retested on09e8189c.Verification (Windows Server 2025, D3D12 WARP, head
ac13b5d34):x2w_pipe.py win2025 3198 --regex '^(startup_refusal_census|startup_triage_run)'-> 2/2 passed. The Python census tests also pass on Linux.All open asks (weighting with the translated count, failure counters over use estimates, partially recovered and fully translated cases) are done and were confirmed in the review above. Marking this Ready.
@MasterDomino ready for review and merge when you have time.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-28T22:02:08Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ac13b5dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-29T08:08:40Z.
Review: APPROVED
Independently reviewed
ac13b5d3integrated overmaineab7180c(clean trial merge, tree568379e3).git diff --cached --check origin/mainis clean. The change is Python tooling, a test, a ctest entry and a docs paragraph, so I did not request a title run.What I traced: each pattern in
tools/startup/refusal_census.pyagainst the line the runtime prints.compute census key ...: N dispatches, T translatedmatchesd3d12_compute_dispatch.inl:1104, andmax(0, N - T)agrees with the by-reason sum a few lines above it (dispatches - translated).no RTV translation for,translated ExecuteIndirect Draw refused, shaderandExecuteIndirect refused, keymatchd3d12_draw.inl:1268,d3d12_draw.inl:3564andd3d12_xs_device.cpp:3784.indirect-draw refusal N: key= reason= calls=form matches whattests/startup_indirect_draw_indexed.cppparses.<key>.failandreq_<key>.<ext>match whatgfx2hlsl.pyandcompile_dxil.cppwrite.The earlier asks on this PR are in at this head: 12 dispatches with 10 translated weighs 2, a fully translated key with a cached
.failweighs 0, the older line form still parses, a failure counter wins over a use estimate from another log, and the runtime indirect-draw counters are reported separately (2, 5, 5 gives 5; zero key left out).Ran, in the trial merge:
out\pe-env\Scripts\python.exe -B tests/startup_refusal_census_check.py: 6 tests OK.python -B tests/startup_triage_run_check.py: 0 failed.tests/docs_links_check.pyandtests/run_checks_parallel_check.py: pass.cmake --preset devandcmake --preset release, thenctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_refusal_census|startup_triage_run|runtime_startup_triage_run_cli_check)$': 3/3 passed in both, no skips.maineab7180cthe tool and its test do not exist, sostartup_refusal_censusis not registered there.Mutation test of
refusal_census.py(31 single-edit mutants, each run againsttests/startup_refusal_census_check.py, file restored andgit diff --quietchecked afterwards):.failline instead of first;--shareableleaking text; class ranking ascending; row order ascending; positive-weight count using>=; missing-log check off; normalized class cut short;no RTV translationpattern dead;.c67and.astage labels wrong.max(0, ...)clamp (the latermaxagainst the Counter default of 0 does the same); dropping thecontinueafter an indirect-draw line (no other pattern matches that line).translated ExecuteIndirect Draw refusedpattern, theExecuteIndirect refused, keypattern and thenot drawn keypattern can each be made dead with all 6 tests passing (the one ExecuteIndirect line in the fixture is hidden behind two RTV lines for the same key, because the weight is a maximum);--topignored;|not replaced in a class label; the--cachedirectory check off; the class tie-break by key count dropped; the.bstage label wrong (only visible for a key with.band no.a); thex2w-prefilter removed.Notes, none blocking:
mainare capped line counts, not draws.no RTV translation foris logged once when the variant entry is created. The twoExecuteIndirectrefusal lines are logged for the first call of each (key, reason) pair and then only for the first 32 and 16 refusals overall (first_calls). Nothing undersrc/printskey useornot drawn keyyet. So today a compute key is weighed by its real blocked dispatches while a graphics key that blocks many draws weighs about 1, and the ranking across stages leans to compute. The docs paragraph says logs can be sampled; I would add one sentence there saying that the graphics line counts are a lower bound until a build prints per-key draw counts.ExecuteIndirectrefusal (one for each form) and onenot drawn keyrow would pin the three surviving patterns..failwhose first line holds a byte that cp1252 cannot decode stops the report:printf 'bad byte \x81 here\n' > cache/00000000000000aa.fail, thenpython -B tools/startup/refusal_census.py --cache cache --log log.txt --out-md o.mdends inUnicodeEncodeError: 'charmap' codec can't encode character '�'. A UTF-8.failis read as cp1252 and comes out as mojibake. Passingencoding="utf-8"to theread_text,openandwrite_textcalls would fix both; unconfirmed.--shareableis not affected for unknown text.tests/startup_refusal_census_check.pyis registered in ctest but is not in theRun Python checkslist of thepython-linuxjob or intests/checks/, so it runs in the Windows job only.Environment: Windows 11 25H2 build 26200.9974; Python 3.12.10; CMake configure with MSVC 19.52.37029. No GPU tests apply.
CI:
Build and test on Windowspassed onac13b5d3.This reply was AI-assisted.