GPU: atomic adaptive PSO wait budget and non-blocking pipeline library saves #275
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!275
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-275"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@wbkepler on GitHub · 2026-11-24 01:58 UTC · original
wbkepler:gpu/pso-hitch-and-library-save→main· +629 −86 · 2 files · 2 commits · openSummary
Eliminates mid-gameplay 500 ms PSO wait freezes and periodic 20-second pipeline-worker stalls while raising early-warmup capacity:
pipeline/make.rs:FRAME/WAITED_USaccounting with a lock-free packedAtomicU64FrameBudget(reserve + same-frame refund) so concurrent recording threads cannot collectively overshoot the frame wait budget or corrupt newer frames.Condvarto per-Pendingwait_lock/wait_donewakeups.< 60, 8 ms in steady state) with an explicitVICTORY_PSO_WAIT_MS(0..=5000ms) override.pipeline/library.rs:save(false)onto a dedicated low-priority background saver thread reusing its serialization buffer (pre-sized outsidelibrary.lock()).library.lock()strictly forID3D12PipelineLibrary1::Serialize, skips rewritinghost-pipelines.binwhen onlyearly-pipelines.txtchanged, and performs unique-temp atomic write+rename with cleanup on error outside all locks (restoring dirty counters on failure).save(true)synchronous via FIFOSaveAck, and raisesEARLY_MAXfrom8,192to65,536.victory-gpucovering concurrent 8-thread budget reservation/refund/frame isolation,VICTORY_PSO_WAIT_MSparsing/clamping and adaptive defaults, early-list recording/dedup up to 65,536, and atomic-write overwrite + temp-file cleanup on rename error.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passedcargo xtask policy— passed (151 files ok)@ifBars on GitHub · 2026-11-24 02:09 UTC · original
I compiled a deterministic CPU-only test against the
FrameBudgetimplementation fromf7730115. A recording thread can read frame 100, get descheduled, then enterreserve(100, ...)after another thread has already reserved frame 101. Becausereserveresets the state on every differing tag, the stale reservation moves the tag back to 100. The next frame-101 caller then gets a second full budget.This interleaving needs no timing-sensitive test:
The current implementation returns
(8000, 8000). The existing test exercises stale refunds. Could we also test stale reservations and havereservereturn zero when the supplied tag precedes the active tag, accounting for the sentinel and wraparound?@wbkepler on GitHub · 2026-11-24 02:16 UTC · original
@ifBars Good catch — thanks for the deterministic repro!
Fixed in
96b2822:FrameBudget::frame_tagnow usesframe % NO_FRAME_TAG(keeping tags strictly in0..NO_FRAME_TAGwithout colliding atNO_FRAME_TAG), andFrameBudget::reservechecksis_newer_tag(tag, cur_tag)via modular half-range distance (0 < diff < NO_FRAME_TAG / 2) before resetting the budget.cur_tag(including across theNO_FRAME_TAGwraparound boundary) now return0without mutating the active frame's packed state.stale_reservation_never_rewinds_active_frame_or_wraparoundcovering thereserve(101) -> reserve(100) / reserve(101)interleaving, partial-budget preservation, andNO_FRAME_TAGwraparound (cargo test -p victory-gpu --lib: 48 passed / 1 ignored,cargo clippy -p victory-gpu --all-targets,cargo xtask policyall passing).@Marvisak on GitHub · 2026-11-25 00:25 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-gpu/src/pipeline/library.rs,crates/victory-gpu/src/pipeline/make.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
@r4tedx on GitHub · 2026-11-25 07:29 UTC · original
A pointer and one observation, since this PR and #2111 change the same accounting in
pipeline/make.rs.What overlaps. On
main,waitreads the frame's waited time before it waits and adds its own only afterwards, so recording threads that wait at the same moment each take the whole budget. Both PRs fix that. #2111 does only that (the waits of a frame end together, and the frame line prints the time draws waited for pipelines); it is onmain940d32fand merges cleanly. Its synthetic test, four threads on pipelines that are never made: the frame stands still 882 ms onmainand 505 ms with the fix.What is only here. The adaptive budget (500 ms for the first 60 frames, 8 ms after),
VICTORY_PSO_WAIT_MS, a wake per pipeline instead of one for all, and the non-blocking library saves. This PR came first (24 Nov). It is ond2a4baeand conflicts withmain. For the library half, #2129 now maps the file and stages the save.One behavioural difference, from reading
96b2822.waitreserves all the budget that is left before it waits, and returns at once when it is granted nothing. So when two recording threads need a pipeline at the same moment, the first holds the whole budget and the second drops its draw immediately, even if its pipeline would be there a millisecond later; it can wait only after the first has refunded. In #2111 both wait until the frame's shared budget ends. I have not measured whether that matters in the title, and neither PR has a title run.Suggestion. After a rebase, the parts unique to this PR sit on top of either accounting, so the two need not compete: this could keep the adaptive budget, the switch and the per-pipeline wake, and take the accounting from whichever the maintainers prefer. If they prefer this PR's accounting, #2111 can close. Either way a test with two threads waiting at once would pin the case above.
Nothing was run for this comment; I read the diff.
AI-assisted (Claude Code).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.