Repository navigation
Conversation
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed head 1a09c6fe line-by-line (lock ordering, disjoint-slot parallelism, MRU buffer lookup, and resource retirement) and verified locally on Windows 11 (NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):
- RTX 5090:
sync_ranges_mirrors_and_clears_many_slots_in_parallel,find_existing_batch_matches_find_for_nested_and_adjacent_buffers, anddescriptor::(22/22, skipping only the known RTX 1M-view heap cap testdynamic_slots_are_held_until_released) all passed. - WARP (
VICTORY_D3D12_WARP=1):sync_ranges_mirrors_and_clears_many_slots_in_parallel,find_existing_batch_matches_find_for_nested_and_adjacent_buffers, anddescriptor::(23/23) all passed. - Clippy:
cargo clippy -p victory-gpu --locked --all-targets -- -D warnings(default and--features diagnostics) — 0 warnings.
Lock ordering matches existing paths (SHADER_HEAPS -> self.made -> VIEWS in Phase 1; self.made dropped for Phase 2 find_existing_batch / texture::in_parallel; self.made -> self.kept then host::retire_all after releasing self.kept, and self.made -> self.viewed.inner in Phase 3). Sorting/merging raw_clamped into disjoint intervals ensures worker threads write disjoint 0..self.count descriptor slots, and Phase 3 re-checks both the live title slot bytes and made[index] != key before writing.
Minor non-blocking notes:
- In
HostHeap::sync_ranges,if last > self.count { past_cap = Some(last - 1); }overwritespast_caprather than taking.max(last - 1). Current callers pass sorted ranges, but taking the max keepsHIGHESTconsistent regardless of input order. - Between Phase 2 and Phase 3, if another thread calls
resource::release->descriptor::forget(bumpingVIEWSgeneration without overwriting heap slot bytes), thenow == rawcheck still passes with the snapshotView(same window asHostHeap::mirroronmain); re-checkingVIEWSgeneration when buildingreadywould tighten that window. - Non-
#[ignore]coverage for thepages.len() >= 16parallel probe path, thetotal >= 32_768Phase 1 parallel diff path, and a Phase 2->3retrytrigger (viaWHILE_PREPARING) would be nice additions.
kotekompotek
left a comment
There was a problem hiding this comment.
Verified the concurrency design end-to-end: Phase 1 diffs under the same made→VIEWS lock order the serial path used; Phase 2 prepares outside locks (find_existing_batch is provably find-equivalent for buffer-resident queries — innermost containing = first .rev() match with end >= end, and the MRU's 'address < next_key_start' guarantees no deeper key; loose/ambiguous falls back to find); Phase 3 re-reads every record and retries changed slots through mirror — the TOCTOU that mattered. Ranges are sorted/merged so parallel slot writes are strictly disjoint; made is held across the whole apply; stride/mark/address/viewed/kept keep their own locking as in mirror. past_cap preserves the beyond-count path. sync_workers caps at half-parallelism ≤6 — leaves the title threads headroom. The 256-slot test discriminates make/clear/rewrite over split ranges.
|
Automated triage for the maintainers. Verdict: needs work.
CI: Generated by Claude Code |
f46a59e to
566a27a
Compare
|
Updated
Hardware runs and tests were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity. |
Problem
descriptor::sync_heaps()runs before every submission on the submitting thread:HostHeap::sync_slots), allocating three temporaryVecs per page (records,current,stale) and lockingVIEWSandself.madeonce per page while looking upVIEWSeven for empty unchanged slots.HostHeap::mirror, takingself.madetwice andVIEWS,self.kept,RETIRED, andself.viewedonce per slot, running D3D12Create*Viewserially, and callingshadow::for_view/shadow::findup to three times per buffer descriptor (prepare,make, andbindless::seen).Fix (Clean 4-Commit Stack)
24618c9(Part 1, GPU: batch dirty heap page ranges under one diff pass in sync_heaps #3139): Batches dirty page ranges and diffs directly against title memory,self.made, andVIEWSunder one lock of each (made->VIEWS), clamping withpast_cap.max(last - 1)and skippingVIEWSfor empty unchanged slots.5825419(Part 2): Addsshadow::find_existing_batch(placed cleanly afterfor_viewsofor_viewkeeps its doc comment),PreparedBuffer,prepare_resolved,make_with(removing duplicateGetDesc()inbuffer_uav),bindless::Viewed::set_with/seen_entry, and tests forfind_existing_batchandWHILE_PREPARINGretries (sync_ranges_retries_slot_rewritten_while_preparing).cae33f6(Part 3): Parallelizes dirty page probing (pages.len() >= 16), Phase 1 diff (total >= 32_768), Phase 2 texture preparation, and Phase 3 D3D12 descriptor creation (ready.len() >= 64) using the crate's existingcrate::texture::in_parallelhelper (max 4 workers, zerounsafein parallel result collection). Holdsself.madeonce across Phase 3, re-checks both live title slot bytes andVIEWSgeneration undermade->VIEWS(retrying concurrently rewritten or released slots viaHostHeap::mirrorafter droppingself.made), and appliesself.kept,host::retire_all, andbindless::Viewed::set_batchin one lock each.566a27a(by@passerbyyhx, viaMeMako/VIctory#1): Non-#[ignore]testa_sixteen_page_heap_sync_preserves_sparse_views_at_the_boundariescovering both the 16-page parallel probe and 32,768-slot Phase 1 parallel diff thresholds.Related PRs
bindlessFxMap+ O(1)forget): orthogonal;bindless.rs'sInnercontainers are untouched here.SHADER_HEAPS/BUFFERS/VIEWSRwLock): orthogonal; lock types are unchanged here, and holdingself.madeacross Phase 3 keepssync_rangessound even under concurrentSHADER_HEAPSreaders.Verification & Standalone Benchmarks
Host: Windows 11 (
10.0.26200), AMD Ryzen 9 7950X, AMD Radeon RX 9070 XT (RDNA 4, driver32.0.32029.2010), basemain63bcca4.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --locked -- --test-threads=1: all passed, 0 failed (victory-gpu: 236 passed,victory-shader: 305 passed,xtask: 6 passed).cargo run --locked -p xtask -- policy:asset policy: 191 files ok.Standalone benchmark (
--release,world_frame_sync_heaps, 700,416 slots across 342 dirty 64 KiB pages, 9-round medians,mainvs. Part 3 alone):main(63bcca4) median566a27a) median0changed / 700k scanned)6,000changed / 700k scanned)14,000changed / 700k scanned)(A standalone live
mainvs. Part 3 title run — without other PRs — will be added before marking this PR ready for review.)Hardware runs and tests were performed by me on my 7950X / RX 9070 XT; PR and code drafted with Antigravity.