perf(gpu): dense watch::Tracked with lock-free clean skip, sync_heaps trims, and 4x unrolled safe_changed #3105

Open
qlfu wants to merge 3 commits from upstream-pr/3105 into main
qlfu commented 2026-11-29 20:02:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-29T20:02:14Z.


Summary

Trims CPU overhead in sync_heaps (watch::Tracked, watch::guard, descriptor::sync_heaps) and descriptor change scanning (safecopy::victory_safe_changed):

  • Dense watch::Tracked (Seen::Dense): replaces hash-map lookups on contiguous heap page ranges with direct dense indexing, plus lock-free WRITTEN_EPOCHS.all_seen clean-round skip and skipping parts_written when guards_asked already covers the range.
  • watch::guard trims: avoids dropping/re-locking when unsure is empty and defers soft_runs inside if !written.is_empty().
  • sync_heaps & draw.rs trims: skips empty guard rounds, caches OnceLock<SyncPart>, uses guarded_relaxed, batches make_waiting, and reuses batch.mirror in draw.rs.
  • 4x unrolled AVX2 victory_safe_changed (safecopy.rs): processes 4 descriptor records per iteration using only Windows x64 volatile registers (ymm0..ymm5), with an SEH fault-safe at4..after4 -> victory_safe_changed_tail 1x fallback.

Verification

  • cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked: 0 new warnings.
  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 (safecopy::, watch::, descriptor::): 173/173 passed.
  • Live 90s benchmarks (1440p DLSS Balanced, 0 WARNs / 0 ERRORs):
    • sync_heaps total: 15.39 -> 13.63 ms (Native), 13.09 -> 12.68 ms (FG).
    • sync_heaps read: 5.50 -> 4.84 ms (Native), 4.97 -> 4.54 ms (FG).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5554563032 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3105). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-29T20:02:14Z. --- ## Summary Trims CPU overhead in `sync_heaps` (`watch::Tracked`, `watch::guard`, `descriptor::sync_heaps`) and descriptor change scanning (`safecopy::victory_safe_changed`): - **Dense `watch::Tracked` (`Seen::Dense`)**: replaces hash-map lookups on contiguous heap page ranges with direct dense indexing, plus lock-free `WRITTEN_EPOCHS.all_seen` clean-round skip and skipping `parts_written` when `guards_asked` already covers the range. - **`watch::guard` trims**: avoids dropping/re-locking when `unsure` is empty and defers `soft_runs` inside `if !written.is_empty()`. - **`sync_heaps` & `draw.rs` trims**: skips empty guard rounds, caches `OnceLock<SyncPart>`, uses `guarded_relaxed`, batches `make_waiting`, and reuses `batch.mirror` in `draw.rs`. - **4x unrolled AVX2 `victory_safe_changed`** (`safecopy.rs`): processes 4 descriptor records per iteration using only Windows x64 volatile registers (`ymm0..ymm5`), with an SEH fault-safe `at4..after4 -> victory_safe_changed_tail` 1x fallback. ## Verification - `cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked`: 0 new warnings. - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1` (`safecopy::`, `watch::`, `descriptor::`): `173/173` passed. - Live 90s benchmarks (1440p DLSS Balanced, `0 WARNs / 0 ERRORs`): - `sync_heaps` total: `15.39 -> 13.63 ms` (Native), `13.09 -> 12.68 ms` (FG). - `sync_heaps` `read`: `5.50 -> 4.84 ms` (Native), `4.97 -> 4.54 ms` (FG).
qlfu commented 2026-11-30 00:12:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T00:12:49Z.


Rebased cleanly onto main (41adb551), preserving upstream #2795 (writes_since) and #2971 (part_runs) cleanly alongside dense watch::Tracked + PageEpochs::collect_newer. Verified watch::tests:: (42 passed), safecopy::tests:: (8 passed), and --features diagnostics.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7265066949 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3105#issuecomment-7265066949). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-30T00:12:49Z. --- Rebased cleanly onto `main` (`41adb551`), preserving upstream `#2795` (`writes_since`) and `#2971` (`part_runs`) cleanly alongside dense `watch::Tracked` + `PageEpochs::collect_newer`. Verified `watch::tests::` (42 passed), `safecopy::tests::` (8 passed), and `--features diagnostics`.
qlfu commented 2026-11-30 12:36:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-30T12:36:49Z.


Fixed writes_for_tracked on the published(from, to) fast path to return guards_asked = false instead of true, preserving 4 KiB parts_written granularity for landed_beside pages in Tracked::take. Verified with watch:: tests and clean merge-tree against 41adb551.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7278680596 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3105#issuecomment-7278680596). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-30T12:36:49Z. --- Fixed `writes_for_tracked` on the `published(from, to)` fast path to return `guards_asked = false` instead of `true`, preserving 4 KiB `parts_written` granularity for `landed_beside` pages in `Tracked::take`. Verified with `watch::` tests and clean `merge-tree` against `41adb551`.
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/3105:upstream-pr/3105'
git switch 'upstream-pr/3105'

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