Repository navigation
perf(shader): select the sine fallback polynomial before evaluation - #13841
adriadam10 merged 1 commit into
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
At head bb9d7516fd0f7f3171fd5f94f4d6cd3508f29619, I found no blocking issue in the shader control-flow change, and the submitted performance artifacts are internally consistent.
What I ran
Reviewed the exact head bb9d7516fd0f7f3171fd5f94f4d6cd3508f29619. The benchmark baseline 45e39c7ad16c93871809eee8c81c3865596e883f is also the PR's merge base; the local merge preview against current main 809c7fa2dfb1b21e2b31b3114b7d51bc14ee88ab was clean. Local checks ran on Linux 6.1.0-54-amd64 with Python 3.11.2 and GCC 12.2.0 available; I did not invoke a C++ compiler or build.
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13841 --no-negative-controls --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13841
git diff --check 809c7fa2dfb1b21e2b31b3114b7d51bc14ee88ab...bb9d7516fd0f7f3171fd5f94f4d6cd3508f29619
python3 tools/check_conventions.py --base 809c7fa2dfb1b21e2b31b3114b7d51bc14ee88ab --head bb9d7516fd0f7f3171fd5f94f4d6cd3508f29619 --title 'perf(shader): select the sine fallback polynomial before evaluation' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13841/pr-body.md
python3 tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13841/head-bb9d7516fd0f-99e5773c --json core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
python3 tools/trace_digest.py <trace> --summary <combined-aps5-summary.jsonl>The precheck's isolated checkout did not contain the local-only pr_test_quality.py helper; I ran that check directly against the exact-head checkout. For the eight supplied captures, I downloaded and decoded the Gist artifacts, checked their gzip streams and SHA-256 provenance, reran trace_digest.py, and compared each result with its supplied digest. I recalculated each run's frame time from window.ms / presents, then recalculated the four paired reductions and the two-sided 95% Student-t interval.
Results
| Check | Result |
|---|---|
| Diff and repository conventions | Passed. |
| Current-base merge preview | Clean against 809c7fa2dfb1b21e2b31b3114b7d51bc14ee88ab. |
| Test-quality heuristic | Passed with no findings when run directly; the precheck wrapper could not locate this workspace-only helper in its isolated checkout. No tests are changed by this PR. |
| Performance evidence | All 8 trace digests matched their supplied reports; all 8 trace SHA-256 values matched the pinned provenance. Recalculated paired mean reduction 0.5332720943830501%; 95% df=3 interval [0.15262026696838982%, 0.9139239217977104%], consistent with the report. |
| Hosted CI at review time | Eligibility and intake passed. Conventions, labels, and relinker jobs were pending; Linux and Windows product jobs were skipped. |
| Local build or GPU tests | Not run. The author reports matched Radeon 760M/Khronos tests and 29,184 bit-identical outputs; I did not independently reproduce them. |
Unedited outputs from checks
All conventions checks passed.
{
"findings": [],
"negative_control_candidates": [],
"limits": [
"Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
"A test that passes against base is not by itself proof that the PR test is inadequate.",
"Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
]
}exact trace_digest matches: A1, A2, A3, A4, B1, B2, B3, B4 (8/8)
trace provenance SHA-256: all matched
window_ms/presents match A: True
window_ms/presents match B: True
paired reductions: [0.571797649159, 0.457949158977, 0.837890385567, 0.265451183829]
mean: 0.5332720943830501 95% df=3 CI: (0.15262026696838982, 0.9139239217977104)
comparison JSON consistent: True
git diff --check produced no output and exited 0. The precheck wrapper's test-quality step reported:
/usr/bin/python3: can't open file '/tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13841/head-bb9d7516fd0f-99e5773c/tools/pr_test_quality.py': [Errno 2] No such file or directory
The direct helper run above passed. Hosted status output immediately before posting:
conventions pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186703945/job/124494983459
relinker (macos-latest, clang++) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495409168
relinker (macos-latest, clang++, x86_64) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495409141
relinker (ubuntu-latest, g++) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495409095
relinker (windows-latest, g++) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495409173
relinker-asan pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495409130
labels pass 8s https://github.com/boykopovar/AnyPS5/actions/runs/41186703953/job/124494983151
linux skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495410914
register-context skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495410803
windows skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495410204
write-watch skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124495410637
eligibility pass 4s https://github.com/boykopovar/AnyPS5/actions/runs/41186704000/job/124494982856
intake pass 5s https://github.com/boykopovar/AnyPS5/actions/runs/41186703898/job/124494982975
Findings
Blocking
None found.
Non-blocking
The change emits a structured selection and phi around the two pure arithmetic series. This follows the existing emitter pattern; the author reports mixed-lane fixtures and matched GPU tests. I did not independently compile the shader or rerun those GPU tests. The measured benefit is limited to the reported title, scene, machine, and four paired runs, as the PR states.
Sources
- Changed sine emission at the reviewed head
- Existing structured branch/phi emitter pattern at the reviewed base
- Performance-report requirements at the reviewed base
- Performance captures, reports, and provenance at Gist revision
d20caac8100008b6156cf8223f242a0b233baf1a
Not verified
No local C++ build, CTest, GPU execution, other-vendor GPU, or console run. The hosted product Linux and Windows jobs were skipped; relinker and conventions jobs were pending at review time. Author-reported Radeon tests and measurements were read but not independently reproduced.
|
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.
|
|
Windows GPU run of head This PR changes no test files, so I picked the existing GPU execution tests that run the code it changes:
AI-assisted: yes (Claude Code). |
|
NVIDIA and Intel on Windows, for head Host: Windows 11 Pro 26200, i7-9750H, WinLibs GCC 15.2.0 (
Only these test targets were built, not the full suite, and no title was run. AI-assisted. |
✅ NVIDIA GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (4, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validation IDs already present on main (3 IDs in 387 tests)Skipped (48)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
Checked the diff (selection merge with single-block arms and a phi over the same pure scalar series, predicate and coefficients unchanged, |
What
Sine fallback emission evaluates both exact polynomials before selecting one. Emit a structured selection and phi around the same pure scalar arithmetic so the driver can allocate the selected paths separately.
This retains the accuracy series introduced by merged #3770 and the GCN near-zero interval from #13258. Both arms contain only scalar arithmetic, with no memory, derivative or subgroup operations; an ordered-false NaN predicate selects the same sine arm. Existing mixed-lane fixtures exercise both paths. This is independent of #13268's cosine sharing and #13826's cardinal checks.
Tested
Main
45e39c7ad16cversus candidatebb9d7516fd0f, God of War Sons of Sparta PPSA28997 v01.008.001, saved camp after Continue, 1920×1080 guest output, Wayland/mailbox. AMD Ryzen 5 7640HS / Radeon 760M integrated GPU with shared system memory, RADV Mesa 25.0.7-2+deb13u1, Debian 13.7 / Linux 7.2.12-x64v3-xanmod1.Mean frame time 45.671702 → 45.428081 ms. Four paired percentage reductions average 0.533272%, two-sided 95% Student-t CI [0.152620%, 0.913924%], df=3. Mean run FPS separately: 21.895417 → 22.012869.
Within-arm ranges: main 0.118891 ms, candidate 0.163681 ms; sample SDs 0.052055 and 0.080978 ms. Primary metric was fixed as window duration / presents per run. Order: warm A, warm B, A1, B1, B2, A2, B3, A3, A4, B4. All ten attempts valid, no exclusions, replacements or appended runs. Acceptance required positive paired mean and positive lower confidence bound; frames are not independent repetitions. Four pairs support only this tested scene/setup, with no combined or universal gain claim.
All eight traces, unchanged summaries, complete trace_digest reports, protocol, provenance hashes and measurement-hook source. Same save, scene/input route, resolution, focus/window geometry and separate warmed per-arm cache seeds; unchanged manifests in every window. Fifty native libraries and nine unique guest modules audited as full-path lists with duplicate detection and hashes through the process mount namespace, plus actual loaded RADV ICD. No drops or validation/profiling during timing; stdout stayed on a pseudo-terminal. Identical private readiness hooks operate outside timed windows and are excluded from production. VideoOut differs only in generated revision text. Trace
dirty:nullreflects dependency-symlink status failure; exact revisions, patch hashes and loaded-binary hashes are retained.Three matched main/candidate/final hook-free Radeon fixtures pass:
SinCosReduction,SinCosNearZero,Vop1FloatUnary, with verbose CTest, required Vulkan, no shader cache and Khronos instance/device validation. Zero skips, missing-layer warnings or VUIDs. Reused differential fixture with fresh libraries yields 29,184 bit-identical outputs across supported FP/fused settings, signed zeros, subnormals, NaNs/infinities, boundary neighbors and deterministic random inputs. Both existing unsupported denormal-mode errors remain. Existing committed mixed-lane fixtures cover the changed branch selection; no duplicate test framework added.Unfavorable historical native evidence: the focused fragment grows 6,593 → 6,950 instructions, 35,464 → 38,376 bytes, while allocated VGPRs fall 48 → 40, without spills. Final ISA predicates both arms with unchanged branch/FMA counts: this does not establish reduced executed FMA work or actual occupancy. The earlier two-pair cohort observed about 0.584% lower mean frame time, both pairs favorable with differing magnitudes; its complete table is included as historical evidence. Fresh elapsed timing above supports the total change, not a per-instruction bottleneck claim. No other GPU was tested locally. Historical full-game vertex/index binding VUIDs remain unrelated; no clean full-game validation claim.
Full overlap scan: 1,623 open PRs, ten shared-file branches. Stale #5021 and #12324 required manual review: lane-shuffle/NaN handling and wave-scan changes respectively, no duplicate sine mechanism. #13268 changes cosine evaluation and #13826 changes the later cardinal result; no required dependency. Conventions pass. Upstream advanced to
809c7fa2dfb1during final review with an unrelated Audio3d change; this PR retains the exact tested candidate/base, and the measured result is not transferred to that later runtime baseline. The overlap merge preview is clean.Main/candidate summary lines and trace_digest excerpts (all runs in the bundle)
{"commit":"45e39c7ad16c","dirty":null,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"30:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 30:12","first_present":676,"ms":12044.534},"presents":264,"frame_ms":{"p50":45.573,"p90":46.222,"p99":47.379,"max":47.904},"gpu_busy_ms_per_present":42.565,"worker_busy_pct":{"queue worker 0x0":78.302},"top_phases_ms_per_frame":{"Driver.Packet":35.589,"Driver.Packet.draw":33.102,"Driver.Draw":33.064,"Driver.Draw.draw_enqueued":29.697,"Recorder.Sync":28.516,"VideoOut.Flip":9.047,"Driver.Present":9.039,"VideoOut.Flip.present":9.012},"trace_dropped":false,"trace":"aps5-trace-45e39c7ad16c-214776.json.gz"} {"commit":"bb9d7516fd0f","dirty":null,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"30:12"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.2.12-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 30:12","first_present":668,"ms":12021.026},"presents":265,"frame_ms":{"p50":45.296,"p90":45.828,"p99":47.183,"max":47.698},"gpu_busy_ms_per_present":42.354,"worker_busy_pct":{"queue worker 0x0":78.213},"top_phases_ms_per_frame":{"Driver.Packet":35.341,"Driver.Packet.draw":32.864,"Driver.Draw":32.826,"Driver.Draw.draw_enqueued":29.222,"Recorder.Sync":28.12,"VideoOut.Flip":9.053,"Driver.Present":9.041,"VideoOut.Flip.present":9.014},"trace_dropped":false,"trace":"aps5-trace-bb9d7516fd0f-215581.json.gz"}seconds 30:12 from present 676: 264 presents, frame p50 45.6 / p90 46.2 / p99 47.4 / max 47.9 ms, GPU busy 42.6 ms per present
AMD Radeon 760M (RADV PHOENIX), radv Mesa 25.0.7-2+deb13u1, Linux 7.2.12-x64v3-xanmod1, 1920x1080, commit 45e39c7, dropped: no
seconds 30:12 from present 668: 265 presents, frame p50 45.3 / p90 45.8 / p99 47.2 / max 47.7 ms, GPU busy 42.4 ms per present
AMD Radeon 760M (RADV PHOENIX), radv Mesa 25.0.7-2+deb13u1, Linux 7.2.12-x64v3-xanmod1, 1920x1080, commit bb9d751, dropped: no
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)