GPU: cut cold launch to the first screen from 49 s to 21 s #2427
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2427
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2427"
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?
@imjustprism on GitHub · 2026-11-25 13:20 UTC · original
imjustprism:perf/startup-load→main· +1403 −107 · 9 files · 4 commits · openthe 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
@Marvisak on GitHub · 2026-11-25 15:33 UTC · original · edited 2026-11-26 00:20 UTC
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 (
crates/victory-gpu/src/small_buffers.rs,Host::shared_buffer, slot rounding inshadow::find), droppingFILE_FLAG_NO_BUFFERINGinfiles::CreateFileW, and two DirectStorage scheduling changes indstorage.rs, about 1,400 lines in all.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
CreateFileWbuffering change by itself (it has no row of its own yet). If the maintainer says per-commit review here is fine, that overrides this. CI: passing.Generated by Claude Code
@kotekompotek on GitHub · 2026-11-25 17:03 UTC · original
Read all three parts end to end. The wake/lock discipline is right (
submit_and_wakedrops the lanes lock before notifying;finishreports whether a starved start can retry;startlets zero-staging reads bypass the staging cap),read_atcorrectly keepsout/overlappedalive through a failed wait by spinning onInternalwithCancelIoEx, and the pool's slot lifecycle closes every race I could construct:take_or_addhandles two racing heap-creators,giveonly touches bits under the leaf lock,destroyedcan't fire whileslotsis held (nothing drops a resource inside the lock), andspare's 2×HEAP_SLOTS hysteresis stops heap churn. Thedropped_flagsgate is exactly as conservative as it should be (access == GENERIC_READ, non-overlapped, CreateFileW only).Two narrow edges, neither blocking:
create_placed'sRegisterDestructionCallbackfailure path drops the buffer andplacegives the slot back immediately. The runtime defers a placed resource's teardown, so a fast re-takeof that slot could tryCreatePlacedResourceover a resource the runtime is still destroying → create fails → pool closes → committed fallback. Self-healing, but a short delay or marking the slot free only after a tick would avoid the corner.starvedonly clears on a staging-holding finish. A run of zero-staging finishes leaves it set, so the next staging-freeing finish does a redundantnotify_all. Over-wake only, but atake(&mut self.starved)on a refused→non-refused transition would keep it tighter.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.
@imjustprism on GitHub · 2026-11-25 20:32 UTC · original
@Marvisak triage asks to split this into three pull requests. the branch is
already one commit per part, rebased on
13f91ca, gate green on each commit:dc08afasmall shared buffers in pooled heaps (victory-gpu only)79fd6c2packs through the host file cache (files.rs)5530eddand9a8a397dstorage: reads without staging, overlapped reads(dstorage.rs)
do you want three pull requests, or is reviewing it per commit here fine?
happy to split, i just don't want to open three more if one is easier for
you. the pool commit shares no file with #1457 or #234, the file cache commit
only victory-hle's Cargo.toml. the dstorage commits are the ones that overlap
them.
timings i have per part are in the second table above: dstorage overlap
27.3 s to 21 s cold, pool 7.0 s to 5.5 s launched again. the file cache part
has no row of its own.
cut cold launch to the first screen from 49 s to 21 sto GPU: cut cold launch to the first screen from 49 s to 21 s@DenRakEiw on GitHub · 2026-11-25 14:06 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090: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 on GitHub · 2026-11-25 14:11 UTC · original · reviewed
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.
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.