perf(victory-gpu): optimize watch.rs and port.rs hot paths #17
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!17
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-17"
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:56 UTC · original
MahanYTT:perf/watch-port-journal→mega-upgrade-v3· +522 −149 · 2 files · 1 commits · merged 2026-12-04 20:18 UTCSummary
Optimizes
crates/victory-gpu/src/watch.rsandcrates/victory-gpu/src/port.rshot paths targeting the ~7.2 ms/frameGetWriteWatch/ watch-query overhead (4.1 mssubmitting thread +1.88 msheap_twin+1.23 msdescriptor) underVICTORY_PORT_JOURNAL=1.crates/victory-gpu/src/watch.rsnot_write_watchedinask_once& reuseahead_runs: Prevents mapped view/guarded/placeholder ranges from poisoning coalescedask_onceruns and triggering recursive binary-splitGetWriteWatchsyscall failures.ask_once/ask_ahead/ask_rest(note_ahead_batch): UnderVICTORY_PORT_JOURNAL=1, notes written pages under the sharedJOURNALread lock + per-shard write locks and acquiresJOURNAL.write()only for the O(1)ahead/keptswap, eliminating exclusive lock stalls for concurrent readers (heap_twin,descriptor, texture refreshes).writes_with: Locks onlyshards_of_pages(pages)instead ofshards_of(first, last) | shards_of_pages(pages), avoiding locking up to all 64 shards on wide clean/sparse queries.HeldShards(Empty/One/Many): Replaces heap-allocatedVec<RwLockWriteGuard>with stack-allocated shard guards and a single-shard fast path with no panics/unwraps on title threads.ScratchPages+kernel_written_into): AppendsGetWriteWatchresults directly into caller/TLS buffers instead of allocating a temporaryVec<(usize, u16)>per syscall.parts_written: Caches the active shardRwLockReadGuardacross consecutive pages in the same 64 MiB shard and adds fast paths for!parts_on()and emptyShard::parts.max_epochskipping inPageEpochs: Tracks per-leafmax_epochto skip clean 64 MiB leaves in one atomic load duringcollect_after,any_after, andall_within.Tracked::takewith denseSeenPages: ScansPageEpochs/Notesdirectly insidewrites_withagainst O(1) dense page-epoch storage (for ranges <= 4 GiB,BTreeMapfallback above) and reuses the already-heldJOURNALread lock forparts_written.crates/victory-gpu/src/port.rsRwLock<Vec<Region>>& unlocked D3D12 placement: ReplacesMutex<Vec<Region>>withRwLock, clones(start, heap, view)under a short read lock (or double-checked write lock on first open), and callscrate::inplace::place/GetGPUVirtualAddresscompletely unlocked.BOUNDSfast-path &Acquire/Releaseordering: Adds an empty-bounds early return tosection_gone, short-circuitswantedonlen == 0, and usesRelease/AcquireonBOUNDS.Verification
cargo clippy -p victory-gpu --target x86_64-pc-windows-gnu --tests -- -D warnings(Rust 1.98.1): 0 warnings, 0 errors.cargo clippy -p victory-gpu --target x86_64-pc-windows-gnu --features diagnostics --lib -- -D warnings(Rust 1.98.1): 0 warnings, 0 errors.watch.rsandport.rs; standalone host unit test verification passed (2 passed; 0 failed).