fix(gpu): serialize pipeline compilation, add VEH fast copy, and reduce lock contention #240
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/240"
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?
Imported from DexNom/VIctory. Originally posted by amiltonjr on 2026-11-30T02:56:42Z.
Summary
This pull request resolves startup crashes, reduces host memory copy overhead, mitigates frame-time latency spikes, and improves process lifecycle reliability on Windows.
Problems Solved
AMD Driver Startup Crash (
0xc0000005inamdxc64.dll)Concurrent D3D12 pipeline state object (PSO) compilation across multiple worker threads caused race conditions inside host vendor drivers (specifically AMD's compiler DLL).
driver_compile_lockinlibrary.rsto serialize D3D12 compilation calls into the driver by default. Can be bypassed viaVICTORY_PARALLEL_COMPILE=1. Worker count is now configurable throughVICTORY_PIPELINE_WORKERS.Host Buffer Copy Overhead and Safety
Mapped host buffer copies previously relied on
ReadProcessMemorysyscalls on every buffer pass, which added kernel transition overhead. Direct user-space pointer copies crashed when hitting reserved but uncommitted sparse virtual pages.read_fastusing an x86_64 SSE2 user-space copy routine paired with a Vectored Exception Handler (VEH). Access violations (0xc0000005) within the copy routine's address bounds are caught and redirected cleanly to safe sparse reading without terminating the process.Lock Contention and Descriptor Table Latency Spikes
In
watch.rs, holding the globalJOURNALlock while callingguard()caused contention across render passes. Furthermore, descriptor tables rescanned every 16 passes indraw.rs, generating periodic frame-time stalls.JOURNALlock before guarding view memory, added aknown_viewcheck to bypass doomedGetWriteWatchsyscalls on protected blocks, and made the descriptor rescan interval configurable viaVICTORY_BUFFER_RESCAN_INTERVAL(defaulting to 64).Launcher Lock Sharing Violation (
os error 32) and Asset Policy ComplianceRestarting the launcher quickly could fail when opening
launcher.lockwith exclusive sharing mode before the terminating process released the file handle. In addition, storing state in the binary directory could trigger asset policy errors when running from a repository build.launcher.lock. Defaulted the runtime folder to%LOCALAPPDATA%\DexNom Runtimeto keep state and logs outside the source tree. Added percentage and timing metrics tovictory warm.Commits Included
fe72bb8: fix(gpu): serialize pipeline compilation and tune worker parallelism17fe85a: perf(gpu): implement fast user-space buffer copies with VEH recoveryafa194c: perf(gpu): reduce write-watch lock contention and configure descriptor rescans1004f4e: fix(play): handle launcher lock contention and sanitize runtime folder48c1071: fix(gpu): handle zero rescan interval, atomic watch publication, and VEH fallbackb2c7b3f: fix(play): preserve custom install path and runtime folder discoveryVerification & Testing
cargo clippy --workspace --all-targets --locked -- -D warnings: Passed with zero warnings or errors.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: Passed with zero warnings or errors.cargo test --workspace --locked: 689 tests passed (12 ignored across 26 suites), including regression tests for zero rescan intervals, concurrent watch publication, VEH registration fallback, and custom launcher install discovery.cargo run -p xtask -- policy: Passed (210 files ok, strictly adheres to Rule #1 asset policy).Test System & Live Metrics
Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T16:07:59Z.
Review of
1004f4e0parses and the first remainder operation panics. Add.filter(|&interval| interval != 0)before.unwrap_or(64). I reproduced the panic in a standalone Rust harness and verified the change on unset, zero, invalid, overflowing, and positive values. draw.rsguard()can mark a range clean before dirty pages reachJOURNAL. An overlappingwrites()call can then return old entries and skip changed bytes. Make the clean transition and publication atomic to readers, including in the failed-GetWriteWatchfallback. watch.rsAddVectoredExceptionHandlercan return null. The initializer still records the bounds and enables fast copy. Enable fast copy only after successful registration and fall back toread()otherwise. host.rsgame-path.txtunder-InstallDirand creates shortcuts that rely on discovery. Reading from the default installation can fail or select a different installation's game path. Resolve the configuration relative to the launcher executable. play_launcher.rsHost::card_compare_pipelinestill calls the driver directly and can overlap a background compile. Library loads can also overlap creation. Their relationship to the reported AMD crash remains unverified. library.rs · host.rsOn the locally patched Windows tree, the sparse fast-copy test and 14 watch tests passed. One watch performance test was ignored.
Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T18:04:36Z.
Tested launcher fix for custom installation paths. Follow-up to the launcher finding at
1004f4e. In the no-argument path, read the installation config withexe_folder.join("game-path.txt")and resolve a relative game path withexe_folder.join(value.trim()). The runtime profile still owns logs, state, and cache. Five launcher unit tests passed. I ran the built launcher against a stub runtime with different game paths in the custom install and the default profile. It selected the custom install's game and created logs and the lock under the profile.Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T19:05:58Z.
Tested fallback for failed VEH registration. Follow-up to the review on
1004f4e. Cache the registration result in aOnceLock<Option<(usize, usize)>>and publish bounds only whenAddVectoredExceptionHandlerreturns a non-null handle. The callback reads a successful registration withlet Some(&Some((start, fail))) = FAST_COPY_BOUNDS.get() else { return EXCEPTION_CONTINUE_SEARCH; };. Have the initializer return whether the cached bounds are present and guard the fast path with:The existing sparse-copy test passed with normal registration. It also passed in a separate test run that initialized the cell to
Nonebefore any copy, simulating failed registration and exercising theReadProcessMemoryand sparse-copy fallbacks. host.rsImported from DexNom/VIctory. Originally posted by amiltonjr on 2026-12-01T16:08:00Z.
Thank you for the thorough review, @Zippp69. I addressed these findings in
48c1071andb2c7b3f:draw.rs): Addedparse_rescan_intervalwith.filter(|&interval| interval != 0)before defaulting to64. Covered bydraw::tests::rescan_interval_rejects_zero_and_invalid_values.watch.rs): KeptJOURNALlocked acrossguard()in bothknown_viewand theGetWriteWatchfailure fallback so clean-block updates inGUARDSand write timestamps inJOURNALstay atomic to concurrentwrites()readers. Addedwatch::tests::concurrent_writes_on_view_never_misses_guarded_pages, which reproduced the stale write race before the fix and passes after.host.rs): ChangedFAST_COPY_BOUNDStoOnceLock<Option<(usize, usize)>>so fast copy activates only whenAddVectoredExceptionHandlerreturns a non-null handle, falling back toread()otherwise. Covered byfast_copy_tests::veh_registration_failure_disables_fast_copy_and_uses_read_fallbackacross committed memory and an uncommitted reservation.play_launcher.rs): Keptexe_folderas the runtime root whenevervictory_core::ensure_outside_repo(exe_folder)succeeds so-InstallDirdeployments remain isolated (game-path.txt,state,logs,cache, andfidelityfx). Redirected runtime data to%LOCALAPPDATA%\DexNom Runtimeonly when launched from inside a source checkout, while still checkingexe_folder/game-path.txt(and resolving relative paths against it) first. Covered bycustom_install_discovery_uses_exe_folder_when_outside_repo.host.rs,library.rs): Acquireddriver_compile_lockaroundCreateComputePipelineStateinHost::card_compare_pipeline.LoadPipelineremains outside the compile lock so warm cache loads stay parallel (synchronized per pipeline name bysame_name, or globally whenVICTORY_LIBRARY_LOCK=1is set).Verification run after the final edit:
cargo clippy --workspace --all-targets --locked -- -D warnings: 0 warnings, 0 errorscargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warnings, 0 errorscargo test --workspace --locked: 689 passed, 12 ignored (26 suites)cargo run -p xtask -- policy: asset policy: 210 files okcargo build --locked --release --target x86_64-pc-windows-msvc -p victory --bins: clean buildView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.