Take the changed card copies from a queue, not from a walk of all of them #251

Closed
CristianCiubancan wants to merge 547 commits from upstream-pr/251 into main
CristianCiubancan commented 2026-11-27 12:20:06 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by CristianCiubancan on 2026-11-27T12:20:06Z.


One commit on main at 6141601. A draft because it touches the lines #238 and #199 move (see Overlap).

What

card_dirty took a reference to every copy in the card's memory at every submission to find the few whose CPU side had changed. #192 made the look at each copy lock-free (has_dirty), but the walk still upgrades and drops a Weak for each of them.

What puts a range into a copy's dirty (card_changed_runs) now also puts the copy on a list, once (a queued flag beside has_dirty), and card_dirty goes through that list.

  • The copies come out in the order they were listed in, as the walk gave them (each remembers its place).
  • has_dirty, sent and has_sent are set and cleared exactly where they were, in the same order; the take is the same closure for both ways.
  • VICTORY_CARD_DIRTY_QUEUE=0 walks as before. VICTORY_AB=<s>,VICTORY_CARD_DIRTY_QUEUE does each in turn in one run; the walk clears the queue and each copy's queued as it goes, so switching loses no change (tested).
  • The copies let go are taken out of CARDED when it has doubled since they last were, since no walk does it at every submission any more.

Measured

RTX 5070 Ti 16 GB, Ryzen 7 9850X3D, 32 GB, Windows 11. Diagnostics build of this branch, Series S, -Machine 4070 -Windowed, VICTORY_PIPELINE_WORKERS=8. The same self-driven route as in #247, one run each way, a VICTORY_PROFILE window of 60 s at 10 ms in the world. Share of the submitting thread's samples:

VICTORY_CARD_DIRTY_QUEUE=0 default (queue)
in shadow::card_dirty 3.45 % 0.93 %
of that, in the walk (Vec::retain's closure) 3.41 % 0 %

That thread works about 50 ms a frame there, so about 1.3 ms a frame. On the earlier base (3da964a, before #192) the same comparison gave 2.88 % against 0.84 % and 0.64 %.

Frame times do not show a change this small: an alternation in one hand-played session on the earlier base (20 s phases, 17 world phases, a fit against draws) leaned 1.6 ms to the queue's side with a scatter of 4.8 ms between phases, and the two runs here differ by more than that the other way (medians 18.9 and 17.8 fps, the second with a slow stretch of the kind #247 describes). The profile is the evidence; I do not claim a frame-rate gain from it.

Overlap

  • #238 and #199 both move the CARDED.lock()...push(Arc::downgrade(&shadow)) lines, which this replaces with list_carded(&shadow). It merges cleanly with neither as they are. I am glad to rebase on whichever lands first, or to wait for both.
  • It does not touch host.rs, so not #247.

Limits

  • One PC, one card, one profiled run each way on this base.
  • The picture: nothing recorded. On the earlier base I played two sessions with it and saw nothing wrong; on this base only the self-driven runs, with no errors and no device loss.

Checks

Three new tests (card_dirty_tests): the queue gives what the walk gives, in the same order; a copy changed again is taken again; the two ways in turn lose nothing. All three fail with the push to the queue taken out. cargo test -p victory-gpu --locked --all-features -- --test-threads=1 passes (537). Clippy with and without --all-features is clean, and cargo xtask policy passes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5526515028 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/251). Originally posted by [CristianCiubancan](https://github.com/CristianCiubancan) on 2026-11-27T12:20:06Z. --- One commit on `main` at `6141601`. A draft because it touches the lines #238 and #199 move (see Overlap). ## What `card_dirty` took a reference to every copy in the card's memory at every submission to find the few whose CPU side had changed. #192 made the look at each copy lock-free (`has_dirty`), but the walk still upgrades and drops a `Weak` for each of them. What puts a range into a copy's `dirty` (`card_changed_runs`) now also puts the copy on a list, once (a `queued` flag beside `has_dirty`), and `card_dirty` goes through that list. - The copies come out in the order they were listed in, as the walk gave them (each remembers its place). - `has_dirty`, `sent` and `has_sent` are set and cleared exactly where they were, in the same order; the take is the same closure for both ways. - `VICTORY_CARD_DIRTY_QUEUE=0` walks as before. `VICTORY_AB=<s>,VICTORY_CARD_DIRTY_QUEUE` does each in turn in one run; the walk clears the queue and each copy's `queued` as it goes, so switching loses no change (tested). - The copies let go are taken out of `CARDED` when it has doubled since they last were, since no walk does it at every submission any more. ## Measured RTX 5070 Ti 16 GB, Ryzen 7 9850X3D, 32 GB, Windows 11. Diagnostics build of this branch, Series S, `-Machine 4070 -Windowed`, `VICTORY_PIPELINE_WORKERS=8`. The same self-driven route as in #247, one run each way, a `VICTORY_PROFILE` window of 60 s at 10 ms in the world. Share of the submitting thread's samples: | | `VICTORY_CARD_DIRTY_QUEUE=0` | default (queue) | |---|---|---| | in `shadow::card_dirty` | 3.45 % | 0.93 % | | of that, in the walk (`Vec::retain`'s closure) | 3.41 % | 0 % | That thread works about 50 ms a frame there, so about 1.3 ms a frame. On the earlier base (`3da964a`, before #192) the same comparison gave 2.88 % against 0.84 % and 0.64 %. Frame times do not show a change this small: an alternation in one hand-played session on the earlier base (20 s phases, 17 world phases, a fit against draws) leaned 1.6 ms to the queue's side with a scatter of 4.8 ms between phases, and the two runs here differ by more than that the other way (medians 18.9 and 17.8 fps, the second with a slow stretch of the kind #247 describes). The profile is the evidence; I do not claim a frame-rate gain from it. ## Overlap - #238 and #199 both move the `CARDED.lock()...push(Arc::downgrade(&shadow))` lines, which this replaces with `list_carded(&shadow)`. It merges cleanly with neither as they are. I am glad to rebase on whichever lands first, or to wait for both. - It does not touch `host.rs`, so not #247. ## Limits - One PC, one card, one profiled run each way on this base. - The picture: nothing recorded. On the earlier base I played two sessions with it and saw nothing wrong; on this base only the self-driven runs, with no errors and no device loss. ## Checks Three new tests (`card_dirty_tests`): the queue gives what the walk gives, in the same order; a copy changed again is taken again; the two ways in turn lose nothing. All three fail with the push to the queue taken out. `cargo test -p victory-gpu --locked --all-features -- --test-threads=1` passes (537). Clippy with and without `--all-features` is clean, and `cargo xtask policy` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TaynanGT commented 2026-11-27 12:26:30 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T12:26:30Z.


@CristianCiubancan The profile moved card_dirty from 3.45% to 0.93% of the submitting thread, which isolates the benefit of replacing the walk. #238 is in main now. The next branch should preserve its publish-time bookkeeping when list_carded replaces the registration calls. The order and switch-over tests are the right checks for that rebase.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7218246285 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/251#issuecomment-7218246285). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T12:26:30Z. --- @CristianCiubancan The profile moved `card_dirty` from 3.45% to 0.93% of the submitting thread, which isolates the benefit of replacing the walk. #238 is in main now. The next branch should preserve its publish-time bookkeeping when `list_carded` replaces the registration calls. The order and switch-over tests are the right checks for that rebase.
TaynanGT commented 2026-11-30 17:14:55 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-30T17:14:55Z.


main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7285957776 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/251#issuecomment-7285957776). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-30T17:14:55Z. --- `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

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
TaynanGT/Vice-Tay!251
No description provided.