Repository navigation
Conversation
…ain takes seconds, not minutes play.rs forced VICTORY_TEXTURE_CATCHUP=0 and a 16 ms slice per frame; with 100-300 ms frames the due-slot backlog (up to ~26k slots) drained over ~3 min (agent report 05). Catch-up is now on, with a 200 ms slice (VICTORY_TEXTURE_BACKLOG_MS) only while >=1024 slots are due. Unmeasured in-game: needs a run, compare time from pack open to queue < 500.
…y default (VICTORY_FILL_TITLE on) The title's 174 MB heap is declared written as a whole (root views have no size) so its 480-byte constants ring waited for every flight once a frame: 43-59 ms of 70-84 ms frames (report 06, measured). The existing guarded mechanism is now default; VICTORY_FILL_TITLE=0 disables it. Residual risk (documented in fill_is_titles): a constant a flight's shader really writes in a block the title also wrote. Not yet validated in-game.
… view creation Measurement only (report 03, E2/E4/E5), logged beside the existing descriptor lines: rounds run and empty rounds, asks of the write watch split by whether they found pages, ring pages (over 90% of changed records are draws' tables) with bytes read, and CreateShaderResourceView count/time for buffer views and raw twins (VICTORY_DESCRIPTOR_TIMING=0 counts without timing). No behaviour change.
…mented Records the new counters and why ring-page skipping, submission gating and coalesced write-watch asks were not done in this scope (need draw.rs, watch.rs or the picked bitmap).
…make times Record first-use order and per-pipeline make ms in pipeline-order.txt (early/slow files keep their formats), queue early pipelines by that order, raise worker priority and lift the slow cap while 32+ pipelines wait, and log count/p50/p90/p99/total of made, loaded and static-sampler pipelines in release builds.
# Conflicts: # docs/performance/EXPERIMENTS.md
The periodic sweep (every 1.5 s) forced a full settle of the flights first. What it lets go of goes through retire(), which holds it until every submission started so far has finished (submission numbers act as fence values), and what a list names has a count above one while the list is in a flight. So the drain is only kept for VICTORY_SWEEP_SETTLE=1 and the up-check. Unmeasured in game.
Distinct 64 KiB blocks per host copy that shaders wrote (landed bytes), that the title's CPU changed afterwards, and that the title wrote while pending (merge_under_writes). Logged every ~10 s with the frame lines; VICTORY_FOOTPRINT=0 disables. No behaviour change.
…ot asked again ask_rest walked the submission's ranges in refresh order and asked each one the standing asking did not already hold, so a small range followed by the big one containing it cost two kernel calls. Sorted by start, widest first, the contained one is answered by the first. The set of pages found and the journal are unchanged. Per-frame (rather than per-submission) asking is not done: a title write between two submissions would be seen a frame late.
The reads of title memory into the buffer between, and the writes out of it, are recorded as one CopyBufferRegion each. Runs that touch in both buffers (and, for reads, are separated by the same under-256-byte padding in source and between) now go in one command. VICTORY_JOIN_STEPS=0 gives one command each, as before. No gather kernel: see EXPERIMENTS.md. Unmeasured in game.
# Conflicts: # docs/performance/EXPERIMENTS.md
…nation only waits for steps behind it
# Conflicts: # docs/performance/EXPERIMENTS.md
…erify period Experimental code: constants instead of VICTORY_TIGHT_WRITES/VERIFY and VICTORY_TEXTURE_BACKLOG_MS.
… order, and hand them to the title's creation
…ted cache - texture/ledger.rs: each finished DirectStorage request is told to the book (dstorage.rs `landed`); if the texture at its destination is known (a view named it earlier this run, or the on-disk book linked this request to a named, kept texture), a background thread makes the host texture and sends the detile+upload to the copy queue (texture/ahead.rs), so the pass adopts the slot with no upload. Book saved in <cache>/textures/book.bin (request keys -> resource words; only named and kept, evicted dropped, aged out). - Loading gate from the request stream (+ .rpf opens, < 200 draws/frame): 4x pass bytes, >= 120 ms slice, more upload bytes in flight. - texture/converted.rs: write-through cache of decoded BCPack/zlib outputs keyed by request (file, offset, sizes, options) with a source digest; hits skip decode. 24 GiB LRU cap, in the cache dir only. - Budgets: 32 GB machines no longer limited for textures; in-flight uploads sized from free RAM (up to 6 GiB); ahead workers cores/4; VRAM line as code constants (88/90 % with frame generation), launcher switch removed. - Rechecks of uploaded textures counted in time as well as frames. Uncompiled, unmeasured. See docs/performance/EXPERIMENTS.md.
# Conflicts: # docs/performance/EXPERIMENTS.md
…ing for flights The fills behind a copy at its place read its destination on the CPU, where the copy is not while flights may write its bytes, so the submission waited for them (READ_PLACED, 18.6 ms/frame in a chase). Such constants are now copied at their place in the list out of the host copy into a buffer of ours, and the root view or descriptor slot points there.
…oted per 4 KiB part - watch: the submission's asked ranges are kept sorted and joined and looked up by halves in writes/asked/nothing_new/ask_rest (was a linear walk per question, thousands of ranges x 12,800 refresh spans a frame in the chase). - shadow: pages a refresh or a merge under shader writes holds in part note each 4 KiB part taken (parts_taken); stale_runs/stamp_taken decide and note per part, so pages beside declared ranges and at range ends are no longer taken again at every refresh once the title wrote any of them. nothing_new and stale_pages_in read the part notes too. - release line: what refreshes took (never taken / taken again / mid-page ends) and the asked-range questions. Not compiled or run (by instruction).
# Conflicts: # docs/performance/EXPERIMENTS.md
The chase scene's list calls cost 11.5 us each (70,418 in 813 ms of thread time a frame) against 3.5-5.3 us with fewer threads busy: contention. Per draw or look-up every translating thread wrote the same few lines: - draw counters DRAWS/DISPATCHES (list.rs) and DRAWN/DROPPED/DISPATCHED (draw.rs): one place per thread (sharded::Counter), summed when read; - the table of views' RwLock (descriptor.rs VIEWS), read per table entry of every draw: a reader takes its own thread's lock only, a writer all (sharded::ReadMostly); forget() of a resource without entries no longer takes the writer's lock; - HostList epochs (host.rs next_epoch): per-thread blocks of unique numbers (only compared for equality); - pipeline bound flag (pipeline.rs): load before the swap; - tight.rs footprint state: 16 locks by key and 16 by copy, never two held at once. Same counts, same exclusion, no switch. Not compiled, not measured.
# Conflicts: # docs/performance/EXPERIMENTS.md
Two homes per title buffer: title memory in place (port region) for constants no shader writes, the card copy for everything else; a per-page oracle (pages ever landed, pages bound to GPU writes at record time) decides per access.
|
A note on the write-watch asking this PR reworks ( In We found that two concurrent Stress test: title-writer threads, a submitting thread asking, and one more asker over a disjoint sub-range of the same reservation, repeated for about 1.5 s. Results:
Suggested fix: serialize the write-watch kernel calls per reservation, or with one global lock as we did. Across all threads the calls add up to only 3-8 ms per frame, so the lock costs little. A per-reservation lock would need the reservation bounds, which costs a system call per asking unless they are cached. |
… and pipeline changes
3013ab8 to
dfea61e
Compare
- Trace draw/dispatch translation, submissions, relay landing, Present, queue submits and fence publication, and label extra GPU passes (ambient, DLSS, indirect clamps, present copies) so captured frames can be joined across CPU and GPU rows. - Resolve more than one GPU timestamp query block per traced list and flag invalid timings in gpu_command rows. - Serialize Windows write-watch calls with a global lock, since concurrent calls on disjoint ranges of one reservation are unsafe. - Fix ask_ahead/ask_once to hold the asking lock before consuming dirty bits, so no answer is lost between reset and journal publication. - Log title_fence_request before the queue sync so ordering is correct.
- Move ask_once_end() inside the journal lock in ask_once so a reset dirty bit cannot be observed between ending the old answer and the journal noting it, which could lose a write. - Add a regression test checking that the single asker waits until an earlier reset has been journaled before it replaces the answer. - Extend the many-askers stress test with a disjoint-span asker and a start barrier so threads contend at the same moment.
Fixed |
… into perf/radical-refactor
Replace the ring-search allocator for dynamic descriptor slots with a range allocator whose ranges are owned by a recording and retired by the submission fence. - Add descriptor/host/dynamic.rs: free ranges indexed by start and by size, best-fit allocation, coalescing of neighbours on release. - Recordings keep their ranges per host heap. Dropping them returns the slots, and submitting hands them to the heap with the fence value. - Reclaim completed ranges on allocation, before readbacks and when merging, so reuse no longer depends on list reset or CPU readback. - When a heap is short, poll the host fence for up to 250 ms instead of settling all in-flight submissions and recycling every landed list. - Remove the host heap id and release path, and the FenceDrain reasons that only existed to free dynamic slots. - Log dynamic descriptor pressure per frame and add a render trace event. - Add a reserve_dynamic for permanent views so the memory table is not tied to a list's lifetime.
- Move the retired-fence queue out of the slot allocator's state mutex, so publishing a fence at submit no longer blocks on allocator operations. Reclaim takes the queue lock only while draining a batch. - Translate recordings that were already submitted before speculative ones, since the latter hold descriptor slots and delay reuse. - Release a dropped thin recording's list state so its descriptor tables are returned. - With a standing write-watch answer, check known-clean shadow spans on the worker jobs instead of walking them on the submitter first. - Add tests for lock-free fence publishing and submission-order priority.
- Plan front refresh spans and texture uploads in one pass. - Send large contiguous runs directly and reduce shared-lock work. - Reclaim completed slot ranges in batches while preserving availability. - Reuse nested title buffers safely and report direct versus staged bytes.
…mory pressure (stutters on a 32 GB PC) Every save serialises the whole host pipeline library (over a gigabyte once warm) and holds off every store while it does. Two cases made that a hitch: - In a burst of new pipelines (a new area, a cutscene) a worker saved it every 20 s, exactly while the title waited on those pipelines and the write competed with texture streaming for the disk. Saves in a burst now come at most every 180 s (VICTORY_LIBRARY_SAVE_BUSY_S; 20 as before). - Under host memory pressure the serialised library is written through the PC's memory and pushes the title's own pages out. On an RTX 4080 with 32 GB the layer ran pressured for a whole session (commit headroom 3.4 GB) and the title's threads stalled; the periodic save now waits 600 s while pressured. The save when the queue runs dry and the save at exit are unchanged, so nothing made is lost unless the process ends without one. Measured: release build, victory-gpu lib tests 414 passed; the two indirect::tests failures are the same on main (fixed by trustno1-coder#67). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a162ae7)
put_changed(), which writes what shaders wrote back into title memory, also computed its runs with the scalar dword_runs(.., 0) although word_runs() is that same call with the AVX2 implementation when it can. Same fallback, same runs, wider instruction. The copy-back path is the one measured at 34.8 -> 17.2 ms by WC_NO_BACK, so it is worth the wide compare too. Tests: 423 passed, 2 failed - the two pre-existing upstream ones. Build clean. (cherry picked from commit 260e446)
…flat 3 GiB The flat VICTORY_CARD_ROOM_FOR_TARGETS_MB (3,072 MiB) is given back only once the targets hold half of it, which the targets of a 720p world never do. On an 8 GB RTX 4060 Laptop the SeriesS profile's targets held 390 MB, so 2,675 MB stayed reserved for them the whole run: the texture queue weighed 6,182 MB against a line of 6,181 MB with the card 41 % used and refused new textures, and the skin textures of passers-by and the coffee shop's waitress were never uploaded (black faces, the phone's screen empty). Half as much again as the peak they have held (at least 256 MiB, never more than the switch's amount) is kept instead: 195 MB for the same run, and a 1440p world's peak of 2.9 GB still gets what it had. The switch keeps the old flat rule when it is set. (cherry picked from commit 05a269d)
…B MiB (off by default) XMemAllocatePhysicalPages makes one pagefile-backed section per request (6.1 GiB at once for the title), which it then maps a 64 KiB view at a time. Windows' large-page rebuild worker walks a section's views under the section's lock, so every map and unmap of the title's pages waits behind it while the camera turns. VICTORY_SECTION_MB=<n> backs a request with sections of at most n MiB (2 measured); unset, 0 or not a number keeps one section per request: same calls, same numbers. - xmem/section_mb.rs (new): the switch, and allocate_physical(n, per), which makes the sections, reports each to the GPU side and numbers the pages as one request. Each section keeps its own window and is closed (title_memory_section_gone) when its last page goes, as before. - xmem.rs: XMemAllocatePhysicalPages calls it; nothing else changes. A mapping or a write already ends a run at a section's end; DirectStorage destinations over a bound get no window and go through write_physical. - inplace.rs: sections and our whole views of them by handle in maps, not vectors scanned per lookup; census lines group alike sections (one of a kind reads as before, lines now in size order). Not combined with VICTORY_PORT_CONSTANTS=1: renderer port 1 needs the 32-bit heap in one section; with the switch set, arrange() logs that the pages are not of one section and leaves them, so the heap stays on the copy path. Tests: the switch's values; 33 pages whole vs 32+1 (numbering, window and write over the bound, one call mapping two views); 70 pages in 32/32/6 with every section closed after free; five pages in sections of two mapped, written, partly unmapped and page-mapping-copied over the bounds; the title call stays one section by default. Port of voidopcode/vilocity 0f44a1706; the finding and the cure are RyanCase94's and CuteBooty's (fxceless's fork, issue #1089, PR #1274). Tests after KainanP (Skyfrye/anyXboxx-diffbase ee8b92e14) and Xeltax (Xeltax/VIcky a8c223149). AI-assisted. (cherry picked from commit 6db4a58)
physical_remap_bench maps a 4 GiB request a page at a time, then remaps random single pages for 10 s while another thread makes, touches and frees 2 GiB, for one section against 2 MiB sections (3 rounds). Test code only: victory.exe is unchanged. Adapted from KainanP's bench (Skyfrye/anyXboxx-diffbase ee8b92e14). AI-assisted. (cherry picked from commit 401adb9)
The submitting thread, the frame's critical path, spent ~15 % of its samples in the process heap (ntdll under realloc/alloc: vectors growing in Host::submit, word_runs_avx2, merge_under_writes, watch::writes). That heap is shared with the title and the drivers. With the `mimalloc` feature the Rust side allocates through mimalloc instead (diagnostics builds keep counting every block in copystat's allocator, which then forwards to mimalloc). RTX 4090, Ryzen 9 7950X3D, Series S, half scale, play-nvidia.ps1 defaults, same unattended route (tools/rtx4090/bench.ps1), jail scene, last 2 minutes: process heap: 24.7 fps (min 23.8), preparing 30.1 ms a frame mimalloc: 26.9 fps (min 26.0), preparing 26.9 ms a frame No change in the picture. (cherry picked from commit c6efc44)
Classify UAV allocations by purpose so residency samples can identify their usage, and expose enqueue and paging-fence timing. Gate the new residency path behind `VICTORY_UAV_ENQUEUE_RESIDENT=1`, keeping existing allocation behavior when it is disabled or unsupported.
…coder#38, trustno1-coder#42) The cache may be deleted at any time; saves and settings kept inside it would go with it. `is_within` compares resolved whole components, so a sibling such as `cache-old` is still accepted, and a cache inside the data folder remains allowed. Ported from uiliannn/VItoriaBr 30d9ba1 (pull requests trustno1-coder#38 and trustno1-coder#42).
Loader: test the AMD-only instruction emulation on any CPU (including AMD!)
The cache may be deleted at any time; saves and settings kept inside it would go with it. `is_within` compares resolved whole components, so a sibling such as `cache-old` is still accepted, and a cache inside the data folder remains allowed. Ported from uiliannn/VItoriaBr 30d9ba1 (pull requests #38 and #42). (cherry picked from commit 0f52dbd)
|
Card test passed on RTX 5070 Ti (UMD 32.0.16.2124): pipelines with static samplers, stored in one process and loaded in later ones, read the right sampler in every slot. What we tested is our port of this PR's admit rule ( The layout is this tree's: one root signature per primed sampler, register 0, visibility ALL. Compute and draw pipelines with 4 static samplers.
Limits: 4 samplers told apart at 8 probe points; one card and driver; only the probe's own samplers. 🤖 Generated with Claude Code |
…coder#38, trustno1-coder#42) The cache may be deleted at any time; saves and settings kept inside it would go with it. `is_within` compares resolved whole components, so a sibling such as `cache-old` is still accepted, and a cache inside the data folder remains allowed. Ported from uiliannn/VItoriaBr 30d9ba1 (pull requests trustno1-coder#38 and trustno1-coder#42). (cherry picked from commit 0f52dbd) Upstream-Source: trustno1-coder/VIctory-NVIDIA@ee69dc0
|
Thanks for this. I'm closing it without merging: at 95 files and about 20,000 lines it's too big to review and test as one change, it conflicts with main, and it adds a new dependency (mimalloc). If you want these changes in, please split them into small pull requests against the current main, one change each, so each can be measured on its own. |
Summary
This branch brings together performance work aimed at reducing GPU command submission overhead, improving coherence between title memory and GPU copies, and shortening texture and pipeline loading times. The branch history was rewritten to remove all
Co-Authored-Bytrailers.Main changes
GPU/CPU submission and coherence
Resource loading
Measurement and documentation
docs/performance.Validation
git diff --checkpassed for the local changes before they were committed.Suggested review
docs/performance.