Fix severe GPU resource retirement performance regression introduced by #563 #591

Open
XxXFixuXxX wants to merge 1 commit from upstream-pr/591 into main
XxXFixuXxX commented 2026-11-28 22:55:33 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by XxXFixuXxX on 2026-11-28T22:55:33Z.


<html>

Change

Refs #563

Fixes a severe performance regression in relay descriptor resource retirement by batching retirements per completed submission.

Profiling identified repeated ordered insertions into the retirement queue through insert_retired as the primary bottleneck. Approximately 91.7% of insertions were out of order, with insertion costs reaching approximately 1408 ms per frame.

This change reuses the existing merge_retired_batch mechanism instead of repeatedly inserting individual resources into the ordered queue.

The patch preserves retirement stamp ordering, including equal stamps, and is designed to preserve existing resource lifetime and synchronization semantics.

Only third_party/victory/crates/victory-gpu/src/host.rs is modified.

Performance results

Hardware:

  • AMD Ryzen 9 5900X

  • NVIDIA RTX 3090 24 GB

  • 64 GB DDR4 RAM

  • Windows, NVMe SSD

Build | Average base FPS -- | -- Before #563 (4bfb5bd) | 8.17 After #563 (4079f2b) | 0.42 With retirement batching (3301ba5) | 8.16

Approximately 19.4x higher base FPS compared with the regressed build in the tested workload.

The measured WHY_READ cost decreased from approximately 1629 ms to 62 ms per frame.

DLSS and frame generation were disabled.

These are local, workload-specific measurements on the earlier development base, not a general performance guarantee. Performance has not yet been rebenchmarked on the final rebased commit.

Verification

Final commit: 7329e82
Upstream base: 66b92fb

Release build:

cargo build --locked --release --workspace --exclude anyxboxx-launcher

Result:

Finished `release` profile [optimized + debuginfo] target(s) in 1m 45s

The build completed with warnings but no errors.

GPU library unit tests:

cargo test --release --locked -p victory-gpu --manifest-path third_party\victory\Cargo.toml --lib

Result:

test result: ok. 648 passed; 0 failed; 51 ignored; 0 measured; 0 filtered out; finished in 5.31s

Python tests:

.\.pr-venv\Scripts\python.exe -m pytest -q

Result:

3 failed, 1971 passed, 9 skipped in 214.37s (0:03:34)

All three failing tests were independently reproduced on an unmodified checkout of upstream commit 66b92fb:

  • test_unfused_multiply_add_nans_match_the_python_model

  • test_float_atomic_programs_match_the_python_model

  • test_interpolation_programs_match_the_python_model

Baseline verification:

cargo build --locked --release --bin anyxboxx-rdna2-ref --target-dir target
Finished `release` profile [optimized + debuginfo] target(s) in 8.13s

Using the same Python virtual environment:

python -m pytest -q tests/test_rdna2_ref_parity.py -k "unfused_multiply_add_nans or float_atomic_programs or interpolation_programs" --tb=short

Result:

3 failed, 43 deselected in 1.93s

No tests were disabled or modified to suppress these failures.

Ruff:

.\.pr-venv\Scripts\python.exe -m ruff check --select W605,F,E9 PrototypeScarlett tests tools

Result:

All checks passed!

Git diff validation:

git diff --check HEAD~1 HEAD

Result: no output.

GPU performance measurements were performed on an RTX 3090. The GPU library test suite also included WARP tests.

A fresh runtime benchmark on the final rebased commit and a full Rust workspace test run have not been performed. The ignored GPU tests were not run.

Oracle and test data

No decoder or HLSL translation changes.

The retirement regression tests use synthetic data constructed within the Rust tests. No external test data is introduced.

The following retirement batch tests passed:

  • relay_batch_appends_ordered_stamps

  • relay_batch_merges_out_of_order_stamps

  • relay_batch_retains_order_for_equal_stamps

  • a_late_batch_does_not_hide_eligible_retirements

The performance regression was reproduced before the change, and the earlier patched build restored performance in the measured workload.

A separate failing-before/passing-after unit test run has not been demonstrated.

Checklist

  • The PR covers a single reviewable behaviour.

  • A test fails without this change and passes with it.

  • The commands and results of each check are given above.

  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Not applicable: no unimplemented functions added.)

  • README: the same change in the English and French READMEs (test_readme_sync.py checks it). (Not applicable: no README changes.)

  • No game, console or SDK file, no key, no dump, no download link.

  • Findings drawn from a title: limited to what rule 2 of AGENTS.md allows. Only aggregate runtime performance measurements are reported.

  • Code taken from another project: compatible licence and credit in THIRD_PARTY.md. (Not applicable: the patch reuses existing repository code.)

AI assistance

OpenAI Codex and ChatGPT assisted with regression analysis, profiling, implementation, testing and preparation of this pull request. The contributor performed local builds and benchmarks.

Experimental descriptor allocator changes and additional diagnostic instrumentation are intentionally excluded from this PR.

</html>
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5545392618 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/591). Originally posted by [XxXFixuXxX](https://github.com/XxXFixuXxX) on 2026-11-28T22:55:33Z. --- <html> <body> <!--StartFragment--><h2><span>Change</span></h2><p><span>Refs #563</span></p><p><span>Fixes a severe performance regression in relay descriptor resource retirement by batching retirements per completed submission.</span></p><p><span>Profiling identified repeated ordered insertions into the retirement queue through </span><code><span>insert_retired</span></code><span> as the primary bottleneck. Approximately 91.7% of insertions were out of order, with insertion costs reaching approximately 1408 ms per frame.</span></p><p><span>This change reuses the existing </span><code><span>merge_retired_batch</span></code><span> mechanism instead of repeatedly inserting individual resources into the ordered queue.</span></p><p><span>The patch preserves retirement stamp ordering, including equal stamps, and is designed to preserve existing resource lifetime and synchronization semantics.</span></p><p><span>Only </span><code><span>third_party/victory/crates/victory-gpu/src/host.rs</span></code><span> is modified.</span></p><h3><span>Performance results</span></h3><p><span>Hardware:</span></p><ul><li><p><span>AMD Ryzen 9 5900X</span></p></li><li><p><span>NVIDIA RTX 3090 24 GB</span></p></li><li><p><span>64 GB DDR4 RAM</span></p></li><li><p><span>Windows, NVMe SSD</span></p></li></ul> Build | Average base FPS -- | -- Before #563 (4bfb5bd) | 8.17 After #563 (4079f2b) | 0.42 With retirement batching (3301ba5) | 8.16 <p><span>Approximately 19.4x higher base FPS compared with the regressed build in the tested workload.</span></p><p><span>The measured WHY_READ cost decreased from approximately 1629 ms to 62 ms per frame.</span></p><p><span>DLSS and frame generation were disabled.</span></p><p><span>These are local, workload-specific measurements on the earlier development base, not a general performance guarantee. Performance has not yet been rebenchmarked on the final rebased commit.</span></p><h2><span>Verification</span></h2><p><span>Final commit: </span><code><span>7329e82</span></code><br><span>Upstream base: </span><code><span>66b92fb</span></code></p><p><strong><span>Release build:</span></strong></p><pre><code><span>cargo build --locked --release --workspace --exclude anyxboxx-launcher</span></code></pre><p><span>Result:</span></p><pre><code><span>Finished `release` profile [optimized + debuginfo] target(s) in 1m 45s</span></code></pre><p><span>The build completed with warnings but no errors.</span></p><p><strong><span>GPU library unit tests:</span></strong></p><pre><code><span>cargo test --release --locked -p victory-gpu --manifest-path third_party\victory\Cargo.toml --lib</span></code></pre><p><span>Result:</span></p><pre><code><span>test result: ok. 648 passed; 0 failed; 51 ignored; 0 measured; 0 filtered out; finished in 5.31s</span></code></pre><p><strong><span>Python tests:</span></strong></p><pre><code><span>.\.pr-venv\Scripts\python.exe -m pytest -q</span></code></pre><p><span>Result:</span></p><pre><code><span>3 failed, 1971 passed, 9 skipped in 214.37s (0:03:34)</span></code></pre><p><span>All three failing tests were independently reproduced on an unmodified checkout of upstream commit </span><code><span>66b92fb</span></code><span>:</span></p><ul><li><p><code><span>test_unfused_multiply_add_nans_match_the_python_model</span></code></p></li><li><p><code><span>test_float_atomic_programs_match_the_python_model</span></code></p></li><li><p><code><span>test_interpolation_programs_match_the_python_model</span></code></p></li></ul><p><span>Baseline verification:</span></p><pre><code><span>cargo build --locked --release --bin anyxboxx-rdna2-ref --target-dir target</span></code></pre><pre><code><span>Finished `release` profile [optimized + debuginfo] target(s) in 8.13s</span></code></pre><p><span>Using the same Python virtual environment:</span></p><pre><code><span>python -m pytest -q tests/test_rdna2_ref_parity.py -k "unfused_multiply_add_nans or float_atomic_programs or interpolation_programs" --tb=short</span></code></pre><p><span>Result:</span></p><pre><code><span>3 failed, 43 deselected in 1.93s</span></code></pre><p><span>No tests were disabled or modified to suppress these failures.</span></p><p><strong><span>Ruff:</span></strong></p><pre><code><span>.\.pr-venv\Scripts\python.exe -m ruff check --select W605,F,E9 PrototypeScarlett tests tools</span></code></pre><p><span>Result:</span></p><pre><code><span>All checks passed!</span></code></pre><p><strong><span>Git diff validation:</span></strong></p><pre><code><span>git diff --check HEAD~1 HEAD</span></code></pre><p><span>Result: no output.</span></p><p><span>GPU performance measurements were performed on an RTX 3090. The GPU library test suite also included WARP tests.</span></p><p><span>A fresh runtime benchmark on the final rebased commit and a full Rust workspace test run have not been performed. The ignored GPU tests were not run.</span></p><h2><span>Oracle and test data</span></h2><p><span>No decoder or HLSL translation changes.</span></p><p><span>The retirement regression tests use synthetic data constructed within the Rust tests. No external test data is introduced.</span></p><p><span>The following retirement batch tests passed:</span></p><ul><li><p><code><span>relay_batch_appends_ordered_stamps</span></code></p></li><li><p><code><span>relay_batch_merges_out_of_order_stamps</span></code></p></li><li><p><code><span>relay_batch_retains_order_for_equal_stamps</span></code></p></li><li><p><code><span>a_late_batch_does_not_hide_eligible_retirements</span></code></p></li></ul><p><span>The performance regression was reproduced before the change, and the earlier patched build restored performance in the measured workload.</span></p><p><span>A separate failing-before/passing-after unit test run has not been demonstrated.</span></p><h2><span>Checklist</span></h2><ul><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>The PR covers a single reviewable behaviour.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>A test fails without this change and passes with it.</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>The commands and results of each check are given above.</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>An unimplemented function returns an error (</span><code><span>E_NOTIMPL</span></code><span>), never a fake success. (Not applicable: no unimplemented functions added.)</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>README: the same change in the English and French READMEs (</span><code><span>test_readme_sync.py</span></code><span> checks it). (Not applicable: no README changes.)</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>No game, console or SDK file, no key, no dump, no download link.</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>Findings drawn from a title: limited to what rule 2 of </span><code><span>AGENTS.md</span></code><span> allows. Only aggregate runtime performance measurements are reported.</span></p></div></li><li><span><input type="checkbox" disabled="" checked=""></span><div><p><span>Code taken from another project: compatible licence and credit in </span><code><span>THIRD_PARTY.md</span></code><span>. (Not applicable: the patch reuses existing repository code.)</span></p></div></li></ul><h2><span>AI assistance</span></h2><p><span>OpenAI Codex and ChatGPT assisted with regression analysis, profiling, implementation, testing and preparation of this pull request. The contributor performed local builds and benchmarks.</span></p><p><span>Experimental descriptor allocator changes and additional diagnostic instrumentation are intentionally excluded from this PR.</span></p><!--EndFragment--> </body> </html>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/591:upstream-pr/591'
git switch 'upstream-pr/591'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/591'
git switch 'upstream-pr/591'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/591'
git switch 'upstream-pr/591'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/591'
git switch 'main'
git merge --squash 'upstream-pr/591'
git switch 'main'
git merge --ff-only 'upstream-pr/591'
git switch 'main'
git merge 'upstream-pr/591'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LooperSalty/AnyXboxX!591
No description provided.