Repository navigation
GPU: cut pipeline creation allocations and CPU overhead - #3396
Desamodeth wants to merge 2 commits into
Conversation
Stream GraphicsState::write_describe directly into BLAKE3 without intermediate Debug/Vec<String> heap allocations (preserving bit-exact pipeline keys), intern common/custom input-layout semantic names with a bounded cap, store compact 16-byte pipeline keys in Pending/CREATED/Used with lock-free wanted_early lookup, and avoid duplicating Vec<Arc<Shader>> on Pipeline on Windows. AI-assisted with Gemini 4 Neon
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).
- Interning common semantic names, avoiding intermediate formatting allocations in pipeline description/key generation, and trimming pipeline creation overhead pass cleanly with strong unit coverage.
cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1: 26 passed, 0 failed (includingsemantic_interning_reuses_common_and_caps_custom_names,write_describe_matches_debug_format, andkey_hex_roundtrip_and_rejection).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).
|
I tested early-cache compatibility in both directions between parent The old and new builds produced identical keys. Both produced Synthetic test fixture and runner AI-assisted with Codex. |
|
Windows 11,
The three added tests are |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed 92f218c5 merged onto main (63bcca43) — clean allocation and CPU overhead reduction on pipeline creation.
Verification
cargo xtask policy: 191 files ok;cargo check --locked --workspace --all-targets: ok;cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(both default and--features diagnostics): 0 warnings.pipeline::unit tests passed on both a discrete NVIDIA RTX 5090 and WARP with--features diagnosticsandVICTORY_D3D12_DEBUG=1.- Verified
GraphicsState::read(pipeline/host.rs:363-387),intern_semantic(pipeline/host.rs:183-202),write_describe/hash_describe(pipeline/host.rs:414-548),key_bytes(pipeline/make.rs:115-129), and lock-freeBEFORE: OnceLock<...>(pipeline/library.rs:501-536):- Tested all 12 edge-case
f32values (+0.0,-0.0,NaN,±Inf, subnormals,MIN/MAX) and extremei32/u32bounds: byte-for-byte identical toDebugformatting andblake3(describe). - Ran an 8-thread concurrency test hammering
GraphicsState::read(pastMAX_INTERNED_SEMANTICSinto the ownedself.namesfallback),key_bytes,note_created_key,wanted_early_key, andnote_used_key: 0 panics and deterministic keys across all threads. --releasemicrobenchmark on 10,000 iterations ofGraphicsState::read+key_bytesvsDebugformatting +blake3: 52.5 ms vs 70.1 ms (1.34×faster) with zero intermediateString/Vec<String>allocations.
- Tested all 12 edge-case
Minor non-blocking note
- Fuzzing all 255 non-NUL bytes (
1..=255) inSemanticNameshowed 254/255 matchDebugbyte-for-byte (hash_describematchesblake3(describe)for all 255/255), with the single exception of ASCII single quote'(0x27), whichCStr'sDebugescapes as'. Adding&& b != b'''to the fast-path guard inpush_cstr_quoted(crates/victory-gpu/src/pipeline/host.rs:245) would make parity 100% exact even for non-HLSL semantic strings.
LGTM.
Match CStr Debug escaping for ASCII single quote (0x27) as noted in review on Marvisak#3396. AI-assisted with Gemini 4 Neon
|
Thanks @fuzeofficlal for the thorough byte-level check! Added AI-assisted with Gemini 4 Neon |
Summary
During boot, a title can create ~60,000 pipeline states (create_stream) while drawing with only a small subset. Previously each graphics create_stream call allocated ~43 heap buffers (~10 KiB of transient churn and ~1.3 KiB retained):
(Orthogonal to #2211, #2974, #2986, #3005, and #3188.)
Verification (CPU-only, Windows 11 x64, Ryzen 7 9800X3D,
ustc 1.98.1 MSVC, base 63bcca4)
Benchmarks (--release, synthetic create_stream / create_compute, counting GlobalAlloc)
Deterministic allocations & heap memory (exact before/after)
Interleaved Release timings (10 runs each: 5× main → pr + 5× pr → main, medians)
| Workload | main ( /
) | This PR ( /
) | Delta |
|---|---:|---:|---:|
| W1 Typical 6k gfx (ns/PSO) | 11,735.5 (11,714.4 / 11,826.1) | 7,238.0 (7,208.8 / 7,267.2) | -38.3% (1.62×) |
| W2 Minimal 4k gfx, 0 inputs (ns/PSO) | 9,307.4 (9,235.5 / 9,329.8) | 6,493.7 (6,491.2 / 6,506.5) | -30.2% (1.43×) |
| W3 Adversarial 1k, 4k unique semantics (ns/PSO) | 11,513.8 (10,924.6 / 11,700.1) | 7,069.1 (7,070.0 / 7,068.2) | -38.6% (1.63×) |
| W4 Compute 2k (ns/PSO) | 785.7 (799.4 / 765.7) | 571.3 (570.7 / 571.9) | -27.3% (1.38×) |
| W5 Multi-thread 4×1k gfx (µs total) | 14,821.4 (14,552.5 / 15,321.8) | 8,689.3 (8,979.2 / 7,801.5) | -41.4% (1.71×) |
Trade-offs
Claim: #1633 (comment)
AI-assisted with Gemini 4 Neon