perf(gpu): sift refresh batches with the scoped worker pool #3705

Closed
victorportelada wants to merge 1 commit from upstream-pr/3705 into main
victorportelada commented 2026-11-30 04:22:58 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by victorportelada on 2026-11-30T04:22:58Z.


What it changes

The refresh sifting paths allocated fresh Arc<Vec<AtomicBool>> marks and an Arc<Vec<...>> of items for every large flush, then cloned them once per worker. On a 6-core host this was measurable overhead in the submitting thread's critical path.

This patch:

  • Adds one reusable Vec<AtomicBool> to Batch and a generic retain_scoped helper that checks items on the existing scoped worker pool, reuses the marks allocation, and retains entries in order.
  • Uses that helper for both the front spans (VICTORY_FRONT_SIFT) and the batch refreshes (VICTORY_FLUSH_SIFT), replacing the two duplicate Arc-based sift functions.
  • Removes two unused write-watch snapshot calls.
  • Adds a test that checks ordering, counts, and allocation reuse.

Measurement

On an RTX 5060 8 GB / Ryzen 5 5600 with a gated headless replay driver (same tape, settings and 3,000-draw gate): median frame 68.3 ms → 58.9 ms (14.6 → 17.0 fps), p95 80.3 → 78.6 ms. This was the only structural patch in a long A/B series that produced a clear fps gain. The 1-second report's refresh cost fell from ~21.8 ms to ~16.3 ms per frame.

Verification

  • Release build succeeds on current upstream main after resolving one conflict with the newer ahead_snapshot_into path (the snapshot was unused and removed).
  • cargo test -p victory-gpu --lib sampled: passes.
  • cargo xtask policy: the only reported violation (heap_sites/frame_users.rs, 2022 hex digits) is pre-existing on upstream main, not in this patch.
  • cargo clippy -D warnings currently fails on clean upstream main with pre-existing lints; this patch adds none.

Docs/analysis from the investigation are included in docs/cpu-submission-critical-path.md.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5558946327 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3705). Originally posted by [victorportelada](https://github.com/victorportelada) on 2026-11-30T04:22:58Z. --- ## What it changes The refresh sifting paths allocated fresh `Arc<Vec<AtomicBool>>` marks and an `Arc<Vec<...>>` of items for every large flush, then cloned them once per worker. On a 6-core host this was measurable overhead in the submitting thread's critical path. This patch: - Adds one reusable `Vec<AtomicBool>` to `Batch` and a generic `retain_scoped` helper that checks items on the existing scoped worker pool, reuses the marks allocation, and retains entries in order. - Uses that helper for both the front spans (`VICTORY_FRONT_SIFT`) and the batch refreshes (`VICTORY_FLUSH_SIFT`), replacing the two duplicate `Arc`-based sift functions. - Removes two unused write-watch snapshot calls. - Adds a test that checks ordering, counts, and allocation reuse. ## Measurement On an RTX 5060 8 GB / Ryzen 5 5600 with a gated headless replay driver (same tape, settings and 3,000-draw gate): median frame 68.3 ms → 58.9 ms (14.6 → 17.0 fps), p95 80.3 → 78.6 ms. This was the only structural patch in a long A/B series that produced a clear fps gain. The 1-second report's refresh cost fell from ~21.8 ms to ~16.3 ms per frame. ## Verification - Release build succeeds on current upstream `main` after resolving one conflict with the newer `ahead_snapshot_into` path (the snapshot was unused and removed). - `cargo test -p victory-gpu --lib sampled`: passes. - `cargo xtask policy`: the only reported violation (`heap_sites/frame_users.rs`, 2022 hex digits) is pre-existing on upstream `main`, not in this patch. - `cargo clippy -D warnings` currently fails on clean upstream `main` with pre-existing lints; this patch adds none. Docs/analysis from the investigation are included in `docs/cpu-submission-critical-path.md`.
trustno1-coder commented 2026-12-01 18:49:35 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:49:35Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321620993 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3705#issuecomment-7321620993). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:49:35Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3705
No description provided.