HLE: offload async saves, reuse audio buffers, pin APU heap, and decouple input rumble/dialogs #237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/237"
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 Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T01:42:29Z.
Summary
Eliminates save, audio, and input frame hitches across
victory-hle:xasync&xgamesave:xasync::pending_withruns on the shared thread pool withArc-owned state and a cancel guard (preventing UAF onXAsyncCanceland per-call OS thread creation).xgamesave*Asyncmethods (initialize_async,quota_async,delete_async,read_async,submit_async) snapshot caller handles/buffers synchronously and offload blocking disk I/O +sync_all()with a FIFOSaveTicketorder guard preserving crash-safe atomic saves.apu.rs:Connection::stateinto per-stream mutexes (zero 46 KiB per-packet allocation and no dequeue/count lock contention while keeping synchronous completion semantics).audio.rs:HEAPtoRwLock, replaces unbounded-lifetimeheap_byteswithHeap::slice/Heap::ptrheld under a single read guard perpump()pass (blocking concurrentApuFreeUAF and removing per-256-byte relocking), and reusesVoice::scratchacross XMA frame decodes/flushes.gameinput.rs&xgameui.rs:set_rumblefromHub::sourcevia lock-free per-padAtomicU64slots flushed onHub::poll.xgameui.rswith a RAIIDialogGuardchecked bygameinput::host::focused()to suppress key leakage during modal text entry.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passed (including crash-safe save test and all 5 new tests)cargo xtask policy— passed (151 files ok)Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T05:01:00Z.
Thanks @wbkepler for the combined async-save, audio-buffer, APU, and input work. I tested the open PR at head
203d9f38407edeb74f37ae03f7a44b323cf402fbwith:Result: 91 passed, 0 failed, 0 ignored. Representative coverage includes APU scratch reuse without holding the state lock, audio heap pinning and voice-buffer reuse, host rumble routing, cancellation of queued XAsync work, FIFO ordering for offloaded async saves, and typed dialog completion. The suite is HLE unit coverage; it does not launch a title or exercise a real host audio device/dialog.
Relevant tests: apu.rs, audio.rs, gameinput.rs, xasync.rs, xgamesave.rs, xgameui.rs.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:23:02Z.
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-hle/src/modules/xasync.rs,crates/victory-hle/src/modules/xgamesave.rs,crates/victory-hle/src/modules/xgameui.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T00:42:57Z.
I checked the Opus allocation change on exact
203d9f38407edeb74f37ae03f7a44b323cf402fbagainst current main63bcca43. The same synthetic Windows test measured allocations on the calling thread after eight warm-up calls, then ran 128 commands alternating mono and stereo with a trimmed deinterleaved stereo output.63bcca43: 128 allocations, 4,423,680 bytes requested.203d9f38: 0 allocations and 0 bytes requested during the measured commands.The outputs reported the same frame and byte counts, with PCM checksum
c4ab76792457d6abon both revisions. This confirms the per-stream scratch change against an allocation count as well as the existing scratch-capacity test.git merge-treeagainst63bcca43also finds anapu.rsconflict. In that file, the activation hunk can keep main's upfront 1–2 channel guard and assign the decoder toslot.decoderon success. The test hunk can keep bothreuses_pcm_scratch_and_decouples_state_lockand main'sdecodes_into_unaligned_output_interleaved_and_deinterleaved.View 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.