perf: give back a list's descriptor slots and kept views in one batch #608

Open
AlphaVIE wants to merge 1 commit from upstream-pr/608 into main
AlphaVIE commented 2026-12-01 18:12:04 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by AlphaVIE on 2026-12-01T18:12:04Z.


Change

When a submission's lists had run, the relay released each dynamic descriptor table on its own (HostHeap::release under the allocator lock) and retired every kept view with its own retire_resource call, each taking a RETIRED shard lock that the recording threads take as well. In the world that is about 70,000 retirements per frame. On a Ryzen 7 5700X (Series S profile) the relay spent 120-360 ms per frame there, while the submitting thread waited for it and the card stood idle.

  • descriptor: release_dynamic_many() / HostHeap::release_many() give a list's slots back under one hold of the allocator lock per heap.
  • host: retire_resources() retires many resources with one stamp, one lock and one ordered merge (merge_retired_batch). They wait for the same stamp as before, so nothing is dropped earlier.
  • draw: State::tables_done() and Drop use the batched release.

Measured on my copy (Xbox Series build 1.0.2.1, anyxboxx run --console series-s with the tuned settings, world, release build). Method: VIctory's own log lines, plus a local split of the landing's "read-backs and lists" step that is not part of this PR.

before after
tables released (relay), per frame 270-363 ms 3-7 ms
of which kept views retired 120-310 ms (~70,000 of them) 2-6 ms
GPU wait per frame (frame line) 120-200 ms 22-31 ms
world about 4-6 fps at ~3,600 draws about 12 fps at ~5,400 draws

Machine: Ryzen 7 5700X (8 cores, 16 threads), 32 GB RAM, RTX 5060 Ti 16 GB (PCIe 4.0 x8), Windows 11.

Linked issue: Fixes #607

Verification

python -m pytest                                                        → 1983 passed in 202.02s
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools   → All checks passed!
cargo build --release --workspace                                       → Finished
cmake -S runtime -B runtime/build -A x64; cmake --build runtime/build --config Release → built (anyxboxx_cpp, anyxboxx_gpu_run_cpp, xgameruntime oracle)
third_party/victory: cargo test --release -p victory-gpu --lib          → 646 passed, 0 failed, 51 ignored (5 of 6 runs; see below)
third_party/victory: cargo xtask policy                                 → asset policy: 380 files ok
third_party/victory: cargo build --release -p victory                   → Finished (one existing warning: vram_keep unused)

GPU: RTX 5060 Ti (not WARP).

One unrelated flaky test: watch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges failed in 1 of 6 runs on this branch and in 4 of 10 runs on unchanged main (66b92fb), same machine. This PR does not touch the write watch.

Oracle and test data

  • Failure case: descriptor::host release_many_gives_back_every_run_and_its_kept_resources_at_once and host retire_resources_queues_all_under_one_stamp do not build without this change (the functions are new). They check that every run is given back to the heap with the matching identity only, that kept resources are cleared, and that every retired resource waits under one stamp, none older than the stamp at the call.
  • Test data is built in the tests: upload buffers and a host heap made on the test's device.
  • The existing retirement and slot tests pass unchanged.

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 emulated function.)
  • README: the same change in the English and French READMEs. (Not applicable: no README change; the test count stays in the same hundred.)
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: counts and timings only, with how they were obtained; no address or RVA.
  • Code taken from another project: none.

This change was made with AI assistance (Claude Code); I ran and measured it on my own machine.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5591655842 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/608). Originally posted by [AlphaVIE](https://github.com/AlphaVIE) on 2026-12-01T18:12:04Z. --- ## Change When a submission's lists had run, the relay released each dynamic descriptor table on its own (`HostHeap::release` under the allocator lock) and retired every kept view with its own `retire_resource` call, each taking a `RETIRED` shard lock that the recording threads take as well. In the world that is about 70,000 retirements per frame. On a Ryzen 7 5700X (Series S profile) the relay spent 120-360 ms per frame there, while the submitting thread waited for it and the card stood idle. - `descriptor`: `release_dynamic_many()` / `HostHeap::release_many()` give a list's slots back under one hold of the allocator lock per heap. - `host`: `retire_resources()` retires many resources with one stamp, one lock and one ordered merge (`merge_retired_batch`). They wait for the same stamp as before, so nothing is dropped earlier. - `draw`: `State::tables_done()` and `Drop` use the batched release. Measured on my copy (Xbox Series build 1.0.2.1, `anyxboxx run --console series-s` with the tuned settings, world, release build). Method: VIctory's own log lines, plus a local split of the landing's "read-backs and lists" step that is not part of this PR. | | before | after | | --- | --- | --- | | tables released (relay), per frame | 270-363 ms | 3-7 ms | | of which kept views retired | 120-310 ms (~70,000 of them) | 2-6 ms | | GPU wait per frame (frame line) | 120-200 ms | 22-31 ms | | world | about 4-6 fps at ~3,600 draws | about 12 fps at ~5,400 draws | Machine: Ryzen 7 5700X (8 cores, 16 threads), 32 GB RAM, RTX 5060 Ti 16 GB (PCIe 4.0 x8), Windows 11. Linked issue: Fixes #607 ## Verification ``` python -m pytest → 1983 passed in 202.02s python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! cargo build --release --workspace → Finished cmake -S runtime -B runtime/build -A x64; cmake --build runtime/build --config Release → built (anyxboxx_cpp, anyxboxx_gpu_run_cpp, xgameruntime oracle) third_party/victory: cargo test --release -p victory-gpu --lib → 646 passed, 0 failed, 51 ignored (5 of 6 runs; see below) third_party/victory: cargo xtask policy → asset policy: 380 files ok third_party/victory: cargo build --release -p victory → Finished (one existing warning: vram_keep unused) ``` GPU: RTX 5060 Ti (not WARP). One unrelated flaky test: `watch::tests::a_raw_copy_in_watched_memory_keeps_the_other_asked_ranges` failed in 1 of 6 runs on this branch and in 4 of 10 runs on unchanged `main` (`66b92fb`), same machine. This PR does not touch the write watch. ## Oracle and test data - Failure case: `descriptor::host` `release_many_gives_back_every_run_and_its_kept_resources_at_once` and `host` `retire_resources_queues_all_under_one_stamp` do not build without this change (the functions are new). They check that every run is given back to the heap with the matching identity only, that kept resources are cleared, and that every retired resource waits under one stamp, none older than the stamp at the call. - Test data is built in the tests: upload buffers and a host heap made on the test's device. - The existing retirement and slot tests pass unchanged. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Not applicable: no emulated function.) - [x] README: the same change in the English and French READMEs. (Not applicable: no README change; the test count stays in the same hundred.) - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: counts and timings only, with how they were obtained; no address or RVA. - [x] Code taken from another project: none. This change was made with AI assistance (Claude Code); I ran and measured it on my own machine.
AlphaVIE commented 2026-12-01 18:12:17 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by AlphaVIE on 2026-12-01T18:12:17Z.


@LooperSalty this is ready for review. All checks listed in the description pass locally (pytest 1983 passed, ruff clean, cargo xtask policy ok). If it looks good to you, could you merge it? Happy to adjust anything you'd like changed.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7320567017 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/608#issuecomment-7320567017). Originally posted by [AlphaVIE](https://github.com/AlphaVIE) on 2026-12-01T18:12:17Z. --- @LooperSalty this is ready for review. All checks listed in the description pass locally (pytest 1983 passed, ruff clean, cargo xtask policy ok). If it looks good to you, could you merge it? Happy to adjust anything you'd like changed.
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/608:upstream-pr/608'
git switch 'upstream-pr/608'

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/608'
git switch 'upstream-pr/608'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/608'
git switch 'upstream-pr/608'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/608'
git switch 'main'
git merge --squash 'upstream-pr/608'
git switch 'main'
git merge --ff-only 'upstream-pr/608'
git switch 'main'
git merge 'upstream-pr/608'
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!608
No description provided.