hle: track title working-set memory, bound xasync threads, and map XUser devices #687
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/687"
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-24T06:54:07Z.
Summary
xmem.rs(XMemGetWorkingSetStatistics):XMemAllocDefault/XMemFreeDefault, non-placeholder committedXMemVirtualAllocregions viaVirtualQueryEx, and physical pages with GPU-optimal breakdown) so host D3D12 mirrors and shader compiler RAM do not trigger premature title asset eviction/OOM.xasync.rs:BinaryHeap<Reverse<DelayedTask>>+Condvar) and bounds thePOOLworker count.xuser.rs(XUserFindUserByLocalId/find_for_device):APP_LOCAL_DEVICE_IDhandles to the offline local user, returningUSER_NOT_FOUNDfor all-zero IDs andE_INVALIDARGfor null pointers.Verification
cargo clippy --workspace --all-targets— passed (zero new warnings)cargo clippy -p victory --features diagnostics --all-targets— passedcargo test --workspace— passed (including 4 new unit tests inxmem/xasync/xuser)cargo xtask policy— passed (151 files ok)Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T06:56:51Z.
Review: COMMENTED
Static review only (victory-hle is Windows-only; I can't compile or run the new tests on macOS):
Scope is large but coherent — three related hardening changes:
XMemVirtualAllocregions separately, queries committed pages viaVirtualQueryExat report time, uses saturating arithmetic throughout, and cleans stale regions on overlap/reuse. TheAllocationBase == basecheck invirtual_usedcorrectly scopes commits to the reservation. Excluding host allocations (GPU mirrors, shader compiler) from title working-set stats is the right call.available_parallelismis the right shape for a console runtime (XAsync callbacks must not exhaust OS threads). The new tests cover deadline ordering and burst capping.find_for_device: small, with a test.Points a Windows run should confirm (I can't):
default_max_workerson the test machine (16 threads?) — the cap test asserts growth is bounded, but actual throughput under a real title burst is only observable on Windows.VIRTUAL_REGIONSgrows monotonically between cleanups — fine for a session, but a title that allocates/frees millions of tiny regions could makevirtual_usedO(regions × regions-in-range); the overlap sweep on insert bounds it in practice.No correctness objections from the static read.
Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:04:49Z.
Review: APPROVED
LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 90 unit tests in ictory-hle and
o_dll_planting passed cleanly. Tracking title memory separately from host/D3D12 mirrors in XMemGetWorkingSetStatistics prevents premature title asset eviction, and the bounded thread pool with single lazy timer thread reduces OS thread contention.
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T09:42:55Z.
Independent verification of
b7d3263d1merged withmain(8e79c80, clean merge) on Windows 11 Pro (26100), Rust1.98.1(x86_64-pc-windows-msvc): PASS (with two small edge-case notes below).Verification
cargo xtask policy→asset policy: 153 files okcargo clippy --workspace --all-targets --locked -- -D warnings→ pass (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings→ pass (0 warnings)cargo test -p victory-hle --locked→ 98 passed + 1 integration test (no_dll_planting), 0 failed (all 4 new tests inxmem,xasync, andxuserpass)cargo test --workspace --lockedpassed (frame::tests::waits_end_on_ticks_and_count_frameshit the known CPU-load timing flake once under concurrent compilation and passed in0.03son re-run).Code-review notes
xmem.rs(XMemVirtualAlloc,already_tracked): if a previously tracked reservation[rbase, rbase + rlen)is freed viaVirtualFreeand a subsequentXMemVirtualAlloclands at a sub-address inside[rbase, rbase + rlen)beforeXMemGetWorkingSetStatisticsruns to prune stale entries,already_trackedmatches the stale range without checkingmbi.AllocationBase == rbaseand skipsrecord_virtual_region. Whenvirtual_used()later runs and seesmbi.AllocationBase != rbase, the stale entry is pruned and the new allocation is never tracked. CheckingVirtualQueryEx'sAllocationBase(or only skipping whenbaseis non-null, i.e., a commit inside an existing reservation) avoids that gap.xasync.rs,Timer::run): whenitem.queue.terminatedis set beforedue,Timer::runskipsdeliverand dropsitem.taskoncedueexpires rather than running it withcanceled = true(and retainsArc<Queue>inTIMER.heapuntildue).AI-assisted; synthetic tests only, no game files.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:34:53Z.
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/xmem.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
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.