fix(gpu): never downgrade Shadow::watched from GUARDED in update_free and preserve SPARE sort order in send::memory #3947

Closed
github-bot wants to merge 1 commit from github-bot/gh-3947 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-30 12:36 UTC · original
qlfu:pr/fix-shadow-watched-cas-and-send-spare-order → main · +7 −3 · 2 files · 1 commits · closed without merging

Summary

Two small concurrency/invariant bugfixes:

  1. crates/victory-gpu/src/shadow.rs (Shadow::update_free): replace the unconditional self.watched.store(next, Relaxed) with a compare_exchange(0, 1) when next == 1, preventing a concurrent thread whose blocks are momentarily resting from downgrading GUARDED back to 1 (which would break Shadow::asked_ahead()).
  2. crates/victory-gpu/src/host/send.rs (send::memory): use spare.remove(i) instead of spare.swap_remove(i) so SPARE preserves its descending-by-size invariant assumed by trim() and give_back() (which evict index 0 / the largest block).

Verification

  • cargo check -p victory-gpu --all-targets --all-features --locked: exit 0.
  • cargo test -p victory-gpu --lib --locked -- shadow:: host::send:: --test-threads=1: passed (0 failed).
  • git merge-tree --write-tree 41adb551 HEAD: clean merge.
**@⁠qlfu** on GitHub · 2026-11-30 12:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3947) `qlfu:pr/fix-shadow-watched-cas-and-send-spare-order` → `main` · +7 −3 · 2 files · 1 commits · closed without merging ## Summary Two small concurrency/invariant bugfixes: 1. `crates/victory-gpu/src/shadow.rs` (`Shadow::update_free`): replace the unconditional `self.watched.store(next, Relaxed)` with a `compare_exchange(0, 1)` when `next == 1`, preventing a concurrent thread whose blocks are momentarily resting from downgrading `GUARDED` back to `1` (which would break `Shadow::asked_ahead()`). 2. `crates/victory-gpu/src/host/send.rs` (`send::memory`): use `spare.remove(i)` instead of `spare.swap_remove(i)` so `SPARE` preserves its descending-by-size invariant assumed by `trim()` and `give_back()` (which evict index `0` / the largest block). ## Verification - `cargo check -p victory-gpu --all-targets --all-features --locked`: exit 0. - `cargo test -p victory-gpu --lib --locked -- shadow:: host::send:: --test-threads=1`: passed (0 failed). - `git merge-tree --write-tree 41adb551 HEAD`: clean merge.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 12:40:26 +00:00
github-bot closed this pull request 2026-12-01 18:50:57 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:47 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3947#issuecomment-7321557092) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3947
No description provided.