gpu(native): run scanner rounds over the rayon pool #608

Open
AnastasisKon wants to merge 1 commit from upstream-pr/608 into main
AnastasisKon commented 2026-11-28 12:04:58 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:04:58Z.


Refs #179

What

The scanner thread hashed every watched texture one after another on its single thread — a round over hundreds of watched textures was one long serial read+hash chain every 5 ms, no matter how many cores sat idle.

scan_round now maps the watched entries over the rayon pool. Each scan_one snapshots the entry's compare-state under the Watched lock, then reads and hashes its own texture without holding the lock (each rayon thread keeps a thread-local scratch buffer, reused across rounds). Results are applied under the lock in a single pass, with the same re-check as before (skip when the entry was released or a submission began/applied meanwhile).

Semantics are unchanged: identical hashes, identical seen/partial/dirty updates, identical skip conditions — the existing scanner tests (scanner_forgets_removed_keys..., dirty_this_round users, probe-round tests) all pass unmodified.

Adds rayon as a workspace dependency of victory-gpu.

Testing

  • cargo test -p victory-hle -p victory -p victory-gpu -p xtask (host arm64) — all pass
  • cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures:: — 18 pass, 0 fail
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — clean
  • cargo xtask policy — 404 files ok

Checklist

  • One change, one PR
  • Branch vibe/scan-par-1705ac from upstream/main, pushed to my fork only
  • No game/GDK files, no dumps/logs in the repo
  • No AI attribution in the diff
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5539936835 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/608). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:04:58Z. --- Refs #179 ## What The scanner thread hashed every watched texture one after another on its single thread — a round over hundreds of watched textures was one long serial read+hash chain every 5 ms, no matter how many cores sat idle. `scan_round` now maps the watched entries over the rayon pool. Each `scan_one` snapshots the entry's compare-state under the `Watched` lock, then reads and hashes its own texture without holding the lock (each rayon thread keeps a thread-local scratch buffer, reused across rounds). Results are applied under the lock in a single pass, with the same re-check as before (skip when the entry was released or a submission began/applied meanwhile). Semantics are unchanged: identical hashes, identical `seen`/`partial`/`dirty` updates, identical skip conditions — the existing scanner tests (`scanner_forgets_removed_keys...`, `dirty_this_round` users, probe-round tests) all pass unmodified. Adds `rayon` as a workspace dependency of `victory-gpu`. ## Testing - [x] `cargo test -p victory-hle -p victory -p victory-gpu -p xtask` (host arm64) — all pass - [x] `cargo test --target x86_64-apple-darwin -p victory-gpu --lib textures::` — 18 pass, 0 fail - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — clean - [x] `cargo xtask policy` — 404 files ok ## Checklist - [x] One change, one PR - [x] Branch `vibe/scan-par-1705ac` from `upstream/main`, pushed to my fork only - [x] No game/GDK files, no dumps/logs in the repo - [x] No AI attribution in the diff
AnastasisKon commented 2026-11-28 12:21:18 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:21:18Z.


CI green (check + macos-scripts SUCCESS), marked ready for review.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239169313 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/608#issuecomment-7239169313). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:21:18Z. --- CI green (check + macos-scripts SUCCESS), marked ready for review.
AnastasisKon commented 2026-11-28 12:49:17 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:49:17Z.


Note for review: #603, #604, #605, #608, #610 and #609 were cherry-picked together onto a local integration branch off main; host 4-crate tests, x86_64-apple-darwin tests (victory-gpu/victory-loader/victory-hle), windows-target clippy --locked -D warnings and cargo xtask policy all pass on the composed result (the scan_round hunks of #603/#605/#608 resolve to: par_iter scan_one, big textures via read_into + hash_of). Happy to rebase any of these onto another once it merges.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239489662 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/608#issuecomment-7239489662). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:49:17Z. --- Note for review: #603, #604, #605, #608, #610 and #609 were cherry-picked together onto a local integration branch off main; host 4-crate tests, x86_64-apple-darwin tests (victory-gpu/victory-loader/victory-hle), windows-target clippy --locked -D warnings and cargo xtask policy all pass on the composed result (the scan_round hunks of #603/#605/#608 resolve to: par_iter scan_one, big textures via read_into + hash_of). Happy to rebase any of these onto another once it merges.
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
LakshanSivakumar/Native-Victory-macOS!608
No description provided.