Repository navigation
Conversation
…tead of scan + re-sort pooled() scanned the whole pool for the smallest fitting buffer and give_back() re-sorted it on every return. The pool is now kept sorted by capacity (largest first): take is one partition_point, give_back inserts at the partition point. Same best-fit and POOL_BYTES semantics. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).
- Maintaining the snapshot pool in sorted order and binary-searching on take/insert preserves best-fit allocation semantics without repeated scans and re-sorts.
cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11 passed, 0 failed (includingthe_pool_stays_sorted_and_best_fit_without_resorting).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks clean and preserves exact best-fit and POOL_BYTES retention semantics.
Verified all accesses to POOL in crates/victory-gpu/src/shadow.rs (pooled at line 105, give_back at line 123, and the new test at line 1315): keeping POOL descending by capacity ensures partition_point(|v| v.capacity() >= n).checked_sub(1) selects the smallest buffer that fits (remove(i) preserves the sorted order) and give_back inserts in sorted order before retain trims to POOL_BYTES.
Verification on origin/main (63bcca43):
cargo xtask policy: ok (191 files ok)cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): cleancargo test --locked -p victory-gpu --features diagnostics -- shadow::tests::withVICTORY_D3D12_DEBUG=1: 10/10 passed on RTX 5090 (200 take/return cycles at pool size 2,000 in 1.52 ms) and 10/10 passed on WARP (1.56 ms)- Additional edge-case check covering empty pool,
n = 0, duplicate capacities,n > max, andPOOL_BYTESoverflow eviction: passed.
|
Independent Release check on Windows 11 26H2 / i9-14900HX (Rust 1.98.1, AC, Balanced). I compared
The 8-buffer timing ranges overlap. At 128 and 2,000 buffers the head was faster in every pair for both request patterns. Both revisions passed the same best-fit, miss, equal-capacity and exact-512-MiB retention checks. An oversized return emptied the pool on both revisions. This measures the hot single-threaded pool cycle. It leaves title frame time and lock contention unmeasured. Synthetic fixture AI-assisted with Codex. |
|
Windows 11,
Synthetic only. AI-assisted. |
|
I resolved the The original #3384 test shared the process-wide pool. One controlled peer take between the two length checks made it see 1,998 entries when it expected 1,999. The replacement uses its own pool and keeps the best-fit, sorted order, return and successful miss checks. All 11 shadow tests, strict Clippy in both configurations and asset policy passed. Using a test-only allocator in a separate process, I rejected the first synthetic reservation. The combined code made two attempts, freed both idle buffers and returned the requested empty buffer. With a successful first reservation, there was one attempt and both idle buffers stayed. @borosf, the combined branch is ready if you coordinate the overlapping change with @desplmfao. If you reapply the resolution or its pool regression, please retain the Git author or add |
|
I measured the shared pool under contention on an Apple M1 (Rust 1.98.1, optimized), comparing base 63bcca4 with PR 2b0d14c. Four workers started together and each ran 1,024 take/return cycles through the production mutex, rotating requests across four prefilled size classes (1–4 KiB). Every take returned the expected capacity, and the final pool contained exactly the starting capacities on both revisions.
Each time is median wall time divided by the cycles completed across all four workers. I alternated revision order across 12 pairs. At 128 and 512 buffers the improvement also held in every pair with one and two workers. The small pool showed no consistent gain. AI-assisted with Codex. |
|
Three independent verifications, all pointing the same way — thank you.
That is the shape the change predicts: the win is On @andrewpozdnakov7-jpg's note about the combined branch and the overlapping change: I will not reapply that resolution without agreeing the shape with @desplmfao first, and if I do, the Git author stays or the Synthetic fixtures only, no game data. |
|
@borosf thanks for checking first. Yes, please take @andrewpozdnakov7-jpg's combined resolution ( |
…tion Takes andrewpozdnakov7-jpg's combined resolution (0dd0f3d): the sorted best-fit take and the binary-search insert stay, main's 512 MiB retention stays, and the retry from Marvisak#2153 goes in -- a snapshot whose fresh reservation fails frees the idle pool and reserves once more instead of aborting. The pool becomes a SnapshotPool with `take` and `give_back`, and its test uses a pool of its own rather than the shared one, which also fixes the race the shared pool left in the original test. Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> Co-authored-by: desplmfao <me@desp.lol> Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
|
Done —
Both Verification at I also rewrote the three hunks of the combined resolution that rustfmt would have reformatted ( Synthetic tests only, no game data used. |
|
@borosf a correction to my earlier comment: please keep the |
|
Good — the Current state: head |
What
0dd0f3d(andrewpozdnakov7-jpg's combined resolution) taken asabc64683: one PR now carries the wholesnapshot-pool change.
takeis onepartition_pointplus a
removeof the smallest buffer that fits;give_backinserts at the partition point. This replacesthe linear scan on every take and the re-sort on every return.
main's retention —give_backkeeps the largest buffers up toPOOL_BYTES(512 MiB), unchanged.try_reserve_exactfails,takelogssnapshot allocation failed; freeing the idle pool, clears the idle pool, and reserves once more insteadof aborting the snapshot.
the_snapshot_pool_preserves_best_fit_and_orderbuilds aSnapshotPoolof its owninstead of driving the shared
POOL, so it no longer races the othershadow::teststhat take snapshots.Credits:
Co-authored-by: andrewpozdnakov7-jpg(the combined resolution,0dd0f3d) andCo-authored-by: desplmfao(the allocation retry, #2153) are both on the commit.Claimed on #1633 (pool maintenance follows the sweep claims).
Measurement (Windows 11 x64, B580, synthetic Vec pool of 2,000 buffers, debug build, 3 rounds)
Per snapshot segment per frame this removes the O(pool) scan and the O(pool log pool) sort under the global
POOLmutex.Verification (head
abc64683, Windows 11 x64, B580)cargo test -p victory-gpu --lib shadow:: -- --test-threads=1— 11 passed, 0 failed, includingshadow::tests::the_snapshot_pool_preserves_best_fit_and_ordercargo test -p victory-gpu --lib --no-fail-fast -- --test-threads=1— 230 passed, 2 failed, 1 ignored;the two are the known B580 baseline (Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744/Test report: Intel UHD (Raptor Lake Xe-LP), 70564ae: victory-shader 201 passed, 8 failed (3 missing-feature skips, 5 different results) #1829):
descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views-D warnings, default features and--all-featuresshadow.rs39 hunks =origin/mainbaseline (39)cargo xtask policy— 191 files okSynthetic tests only; no game data used.