perf(queue): pipeline present drain, unbounded live batching, and lock-free wake #19
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/MahanYTT--VIctory-MA!19
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-19"
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?
@MahanYTT on GitHub · 2026-12-04 18:59 UTC · original
MahanYTT:perf/queue-async-submit→mega-upgrade-v3· +541 −133 · 2 files · 1 commits · merged 2026-12-04 20:18 UTCSummary
Optimizes
VICTORY_ASYNC_SUBMITqueueing, batching, and present pipelining incrates/victory-gpu/src/queue/behind.rsandcrates/victory-gpu/src/queue.rsto reduce the 27.1 ms/frame title-thread stall at presents and lock/dequeue overhead onvictory-submit.Root Causes & Fixes
queued_presentsvspresents):Lane::wait_presents(most)previously blocked title threads until the earlierJob::Present::go()(show_planes/host.present_placed) completely finished. Formost > 0(defaultVICTORY_SUBMIT_FRAMES=1),queued_presentsis now decremented andpresent_waitersnotified as soon as the earlier present is dequeued to run (after all prior submissions/signals have executed), overlapping title CPU recording with host presentation while keepingwait_presents(0)synchronous.Lane::serve():serve()previously snapshottedlimit = state.nextbeforelook(limit), causingtake_along(e.number < limit) to stop joining newly arrived ready submissions and chopVICTORY_JOIN_PARTSbatches prematurely.serve()now usesu64::MAXwhen nodrain()/wait_runs()waiter is active, and immediately bounds tostate.nextwhenneed_servedis set so drains never starve.wake()fast path & waiter-gated condvar notifications: Movedasked(AtomicU64),has_items(AtomicBool), andparked(AtomicBool) outside the mutex with SeqCst Dekker pairing sowake()takes zero locks/syscalls when empty or while the worker is already awake,push/push_one/push_behindonly notifyworkwhen the worker is parked, andmoved.notify_all()only fires when a relevant waiter count is non-zero.Lane::unfold_outsidedetaches/unfolds foldedJob::Listsentries without holdingLane::state, executes immediately ready parts directly without re-inserting intoVecDequeor restartingstep(), and feeds remaining parts intotake_alonglocally before touchingstate.items.step()when the oldest entry has no wait, reusableheadsbuffer, single-lockhas_presentandfloor/raisetracking,Work::can_take_along()+ pre-popshows()skip, limit check beforerunsVec allocation and in-placeJob::Joinedmutation inJob::take_along, zero-allocLane::push_one, and skipping redundanthost_transitioncalls inqueue.rs::present()whenthin::wanted()is active.Verification
cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu -- -D warnings(default,--tests,--features diagnostics,--features ab): 0 warnings, 0 errors.Laneunit tests inbehind.rs(7 existing + 3 new tests covering present pipelining, lock-free unfolding/batching order preservation, and liveserve()batching +drain()): 10 passed, 0 failed.