Repository navigation
GPU: cut cold launch to the first screen from 49 s to 21 s - #2427
imjustprism wants to merge 4 commits into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:
- DirectStorage scheduling/buffer reuse, file I/O improvements, and placed buffer handling build cleanly and pass all targeted tests.
cargo test -p victory-hle dstorage::: 26/26 passed.cargo test -p victory-hle files::: passed.cargo test -p victory-gpu shadow::: 4/4 passed.cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 184 files ok.
AI-assisted (Gemini 4 Neon).
catminou4
left a comment
There was a problem hiding this comment.
Cold launch 49 s -> 21 s (+1366, docs+gpu+hle). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Big win if the numbers hold; too large for an approve without hardware repro, but the direction (parallel/lazy init) is sound. Needs hardware validation.
…ol small placed buffers
|
Automated triage for the maintainers. Needs work. The head is unchanged since the last triage. The PR still combines a pooled heap for small shared buffers ( On your reply: thank you for splitting the commits cleanly. Separate pull requests are still the better route. Each part touches a different subsystem with its own risks: GPU address reuse in the pool, title-visible file-open behaviour, and DirectStorage, which overlaps the open #1457 and #234. Separate PRs let each one be reviewed, merged or reverted on its own, and let the DirectStorage part be weighed against those two PRs. Please also add a timing for the Generated by Claude Code |
|
Read all three parts end to end. The wake/lock discipline is right ( Two narrow edges, neither blocking:
The measurement methodology in the body (per-change attribution, cache purging, driver-name variation) is a model for how perf PRs here should be written up. |
…A_FPS_LIMIT pacing Implements Wave 11A Ranks #1, #2, and #3 (GPL-3.0 attributed, zero RVAs, zero non-trivial thread_local): 1. Buffered overlapped DirectStorage + page-cached read-only pack opens (adapted from Marvisak/VIctory#2427, GPL-3.0): - runtime/shims/file_system.cpp: strip FILE_FLAG_NO_BUFFERING on read-only non-overlapped CreateFileW opens so Windows page cache and sequential read-ahead accelerate RPF pack reads while preserving the flag for CreateFileA, write opens, and overlapped opens. - runtime/shims/dstorage.cpp: open primary DirectStorage file handles with FILE_FLAG_OVERLAPPED using per-worker OVERLAPPED + event handles (with CancelIoEx safety on failed waits) so all worker threads issue true parallel cached I/O on the same pack file; flip LEONIDA_DSTORAGE_NO_BUFFERING default to 0 (opt-in =1 for low-RAM hosts). 2. Fast C++20/SSE2 zlib_inflate + lock-free DirectStorage stats & Status batching (inspired by Marvisak/VIctory#1355, GPL-3.0): - runtime/src/zlib_fast.h & runtime/src/shader_library.h: 11-bit canonical Huffman primary LUT, register-resident 64-bit bit buffer with single-refill fast inner loop, bulk memcpy/memset/doubling LZ77 copies, single-memcpy stored blocks, and chunked SSE2 Adler-32 (5.6x-6.5x speedup on 4 MiB dynamic+LZ77 benchmark: 230.9 MiB/s -> 1,302-1,501 MiB/s). - runtime/shims/dstorage.cpp: replace global stats().mutex locks on hot counters with lock-free relaxed std::atomic counters; batch independent file requests across non-fence Status entries while preserving exact queue-order Status completion, FirstFailure attribution, alias checks, and hard Signal/Event barriers. 3. Configurable uncapped / target frame pacing via LEONIDA_FPS_LIMIT (adapted from fxceless/victory-fork#773 & ubiquitarianism/leonida@77ded8a050, GPL-3.0): - runtime/src/frame_pacer.h & runtime/shims/xbox_present.cpp: support LEONIDA_FPS_LIMIT=0 (uncapped, even with LEONIDA_FRAME_PACING=1) and LEONIDA_FPS_LIMIT=1..1000 (overrides 30 Hz title interval and paces PresentX via sleep+1.5ms spin without catch-up bursts, using sync_interval=0). - runtime/src/main.cpp: skip forcing LEONIDA_FRAME_PACING=1 in --first-run-ui when LEONIDA_FPS_LIMIT is set. Verification: 7/7 CTests pass with Vulkan validation on RTX 3080 (0 validation errors), check_no_game_data.py 0 violations.
a shared buffer of up to 64 KiB takes a slot in a 16 MiB heap instead of a committed allocation of its own. a slot is free again when the host reports the buffer destroyed. on the frame meter's tick one heap no buffer is left in goes back, while a heap's worth of slots stays free without it.
a read no longer holds its file's position: requests of one file run at once on overlapped handles. each submitted read wakes one worker, a worker reuses its source and intermediate buffers up to 1 MiB, and a queue made with no worker running fails instead of never completing. a finish wakes every worker only when it frees staging that a start waited for.
d08323e to
9a8a397
Compare
|
@Marvisak triage asks to split this into three pull requests. the branch is
do you want three pull requests, or is reviewing it per commit here fine? timings i have per part are in the second table above: dstorage overlap |
…ORY_FILE_CACHE=0: unbuffered, as before) After Marvisak/VIctory#2427 by imjustprism (79fd6c2), its files.rs part only: CreateFileW and CreateFileA opens with access exactly GENERIC_READ and not overlapped lose FILE_FLAG_NO_BUFFERING, so the title's packs are read through the system file cache. The title's unbuffered opens are logged (first 8, every 256th) so a run with the switch off says whether it can change anything. RTX 2070 SUPER, 32 GB, SATA SSD: launch to the title-screen logo 34-37 s -> 21-23 s. Fixes Belobug#422. This change was made with AI assistance (Claude Code).
…ORY_FILE_CACHE=0: unbuffered, as before) After Marvisak/VIctory#2427 by imjustprism (79fd6c2), its files.rs part only: CreateFileW and CreateFileA opens with access exactly GENERIC_READ and not overlapped lose FILE_FLAG_NO_BUFFERING, so the title's packs are read through the system file cache. The title's unbuffered opens are logged (first 8, every 256th) so a run with the switch off says whether it can change anything. RTX 2070 SUPER, 32 GB, SATA SSD: launch to the title-screen logo 34-37 s -> 21-23 s. Fixes Belobug#422. This change was made with AI assistance (Claude Code). (cherry picked from commit d5ff00af030389bc19e6f53272675be278ede622) From avatarmanz/VIctory-7900XTX#423 (avatarmanz/VIctory-7900XTX@d5ff00af). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
the black screen before the first screen was almost all waiting, on the drive and on the host making thousands of tiny buffers. with the game folder on a hard drive a cold launch showed the first screen after 49 s; it is 21 s now.
what each change is worth, from builds of this branch with one of them turned off:
release builds of this branch's tree and of main at 940d32f, rx 9070 xt, game folder on a 7200 rpm drive that was idle before each run, each exe under a name the driver had not seen and warmed once first. cold means the file cache was purged for every file of the game folder before the run. the first screen is the first window capture with content, looked for every 250 ms, so times are good to a quarter second. three runs each; main's third cold run is left out because the capture missed the screen. main launched again varies and i do not know why.
packs go through the host file cache. the title opens its packs unbuffered, which is right on the console and costs here: every read went to the drive, windows kept nothing and read nothing ahead.
CreateFileWnow dropsFILE_FLAG_NO_BUFFERINGwhen the access is exactlyGENERIC_READand the open is not overlapped. an open that can write keeps the flag, and so does an overlapped one, because the host'sReadFileScatterneeds it. nothing the title can see changes: same handle kind, same results, same sizes. a later launch then reads the packs from memory, and a cold one gets the cache manager's read-ahead on the sequential stretches.dstorage reads are overlapped. a file was opened for synchronous reads, so the kernel ran one read of a file at a time however many workers were waiting on it. files are now opened with
FILE_FLAG_OVERLAPPEDand a worker reads at an offset with its own event, cancelling and draining the read if it has to give up, so reads of one file run at once and the drive's queue stays full. that is the 27 s to 21 s row. along with it: a submitted read wakes one worker instead of all of them, a worker keeps its source and intermediate buffers between requests (up to 1 MiB each) instead of allocating them per request, and a queue created when no worker could be started fails withE_OUTOFMEMORYinstead of being a queue that never completes. this is the dstorage half of #234 written against current main; the xmem half of #234 is not here, and neither is the scheduling change of #1457.small shared buffers share heaps.
Host::shared_buffermade a committed resource per buffer, a kernel allocation each, and a title makes thousands of buffers of a few hundred bytes while it loads. a buffer of up to 64 KiB now takes a slot in a 16 MiB heap (crates/victory-gpu/src/placed.rs). a slot is free again when the host reports its buffer destroyed (ID3DDestructionNotifier), and a heap no buffer is left in is released, one per tick of the frame meter, as long as a heap's worth of free slots stays without it. a placed buffer is zeroed over its width only, so the copy of a title buffer asks for whole slots: a root descriptor's read past the title buffer's end stays inside that copy, as it did before. that is the 7.0 s to 5.5 s row.what is left of the 21 s is drive time: the drive is busy for nearly all of it. warming the file cache from a list of an earlier launch's reads is the next idea and would be its own pull request.
what this does not show: only the way to the first screen was measured, no world scene. one machine, one amd card, a hard drive; on an ssd the unbuffered reads were never the problem, so expect less. in the measured launches the pool grew to 16 heaps holding about 4,000 buffers and no heap ran empty, so the release on the meter tick never ran there: tests cover what it does, nothing here says what it costs on the present thread.
the gate is green on each of the three commits, with the gpu tests on the rx 9070 xt. the new tests cover which opens lose the flag (wide, read-only, not overlapped) and which keep it, a read at an offset that leaves the handle's file pointer alone, a read whose wait fails having ended before the call returns, reads of one file queued together each getting their own bytes, which wakes a submit and a finish make, the buffers a worker keeps and frees, the scheduler without a worker, and the pool's slots, heaps and release rules.
refs #234
refs #280