Repository navigation
Nvidia dev - #2572
Nvidia dev#2572bmjask wants to merge 421 commits into
Conversation
res_release called sparse::forget_buffer, which unpins a placed buffer's tiles, at the title's last Release, also when late_release kept the PC object alive until the queues are past the work in flight. The kept object still maps those tiles: sparse could hand them to another address or retire the pool heap under them while work queued through the buffer had yet to run. late_release's drain ends the object through the original Release, which never told sparse. forget_buffer now runs from res_release only for an object that is not held, and from late_release right before the real Release of a held one. Right before, not after: after it, another thread can make a buffer at the same address, whose tiles this would unpin (the queues are past the work by then, and forget_buffer takes no late_release lock and does not wait for the sparse state's). The same reuse made the address-keyed removals in res_release unsafe when its Release had already ended the object (late_release off, or two releases of the last two references at once): a resource made at the address in between lost its UMA_BUFFERS / BUFFER_DELTA / TITLE_ADDRESS entries and its pinned tiles. The last reference is now told by the count after an AddRef and Release of our own (1: ours alone) on every path, and the removals, the null views and, with late_release off, the unpinning run while the object is alive, before the Release that ends it. Of the two fixes the finding proposes this is the smaller: an identity guard would need a generation in sparse's buffer table. What is left is two threads releasing the last two references at the same instant: both see 2, and the one whose Release ends the object cleans up after it, as before. Cost: none on draws or binds; per resource Release, the AddRef and Release that late_release already made, now also with XCL_LATE_RELEASE=0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two things bound what a cheaper look could leave out or save. A look takes the blocks written lately only; a write to another block waits for the walk thread to find it. With XCL_LOOK_STATS=2 every look counts whether the walk had made a block hot since the look before began (a block no look had taken: written up to a walk pass ago), and the walk times its passes over all watched memory. XCL writes the title's memory itself: copies back landed and immediates stored. The write watch reports those pages like the title's, so a look takes them and the scan goes over them for nothing. With XCL_LOOK_STATS=2 those writes keep their pages (64 Ki at most, under the sparse state's lock they are made with) until the next look, which counts how many it found and how many of those the scan found unchanged. Lines every 256 looks: walk staleness (256 looks): K of N looks began with a block the walk found that no look had taken yet; a walk pass took A ms (B ms the longest, P passes) XCL's own writes (256 looks): W pages a look written by XCL since the look before (copies back landed, immediates stored), F of them in the look, S scanned, U % of those found unchanged They answer the study's questions of how stale the hot-block look is and how much of a look is XCL's own writes. With the switch off a look costs one atomic load more, a copy back landed or immediate stored one per page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pipeline objects XCL owns - the compute pass of a two-pass pipeline (Drop for TwoPassPso) and the background-built real pipeline behind a title's stand-in (pso_release) - were released the moment the title released its pipeline. A list recorded before that and still queued or running binds them (the two-pass draws bind both), and D3D12 asks that a pipeline outlives the work that runs it: the GPU would fetch shader code of a destroyed pipeline. late_release now takes them as well: a batch entry is a resource or a pipeline, and a pipeline is released (its COM Release) once every known queue has passed a fence value signalled after the hand-over, by the same thread and drains as resources. With XCL_LATE_RELEASE=0 they go at once, as before. Pipelines XCL releases that were never bound (a build nobody waits for any more, a duplicate depth-bias pipeline) still go at once; the depth-bias pipelines derived from a released base pipeline (device_x) are not changed here. Cost: a lock and a push per such release (a title's pipeline release); nothing on draws or binds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thout an allocator aged, ExecuteIndirect counts and vertex/index views kept inside their window, placed buffers unpinned when the PC object goes, XCL's own pipelines released after the queues) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s time by what its calls found, the scan's gather and pool, the submit's sparse lock split, the submitting thread's frame, stale looks and XCL's own writes) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The eight targets drawn into most are a frame's G-buffer. The passes that turn it into the picture (lighting, the HDR chain, the composite) draw once or twice each and rank last, so a flat picture over a drawn scene could not be followed past the scene's targets. A third number names how many of the ranked targets are written (default eight, 64 at most). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The memory line named the video memory in use, not what Windows lets the process have. A retail title's world held 29 to 30.5 GB of a 32 GB card with 1 GB already moved off it, and nothing in the log said it was past the budget. The budget is logged once, and every 2 s while the process is over it, by how much. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d when asked A retail title's world ended in a driver error whose cause the log did not hold: the process was killed from outside 3 s after the driver's first event, before the device was reported removed, and then hung half-terminated in the driver for five and a half minutes with 27 GB held. - a ring of the last 16 384 draws and dispatches (pipeline, kind, size, frame), written at each one and read only for a report; - a thread that looks for a removed device ten times a second (it was only looked for with XCL_DRED set) and times ExecuteCommandLists and Present in the driver: one that has not returned after XCL_GPU_STALL_MS (2 000) is reported with the ring, and the title's other submits wait until it returns; one that took 250 ms and returned is logged; - XCL_STOP_FILE=<path>: when the file appears the title ends itself through end_title. A file beginning with "fault" first gives the driver 12 s to report the device removed, with nothing more submitted. Not run on a GPU yet: the unit tests cover the ring, the report, the stall step and the stop file's reading. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…LSL path The direct translator turned s_barrier into a plain group barrier. That barrier waits for every hardware wave of the group, and a console wave that has left, or that ran one barrier fewer, never arrives: on the console the waves left go on, on NVIDIA they wait for ever and the GPU hangs. The HLSL path has had the barrier that counts the waves still there since 0c02b87 (xcl_s_barrier); with XCL_DIRECT_DXIL=1 compute programs and the compute pass of mesh pipelines did not get it. A retail title has it in 216 compute programs (19 of them branch a wave with no active lane around barriers the other waves run) and in all 36 of its mesh programs: the first wave of a group whose vertex or primitive count is 0, or past 128, runs a barrier the other waves branch around, then the one they all run. Its world, the first to draw meshes in two passes, ended in a driver time-out with no shader exception in two runs of three. A compute or mesh program with s_barrier in a group of more than one hardware wave is now an error of the direct translator, which sends it to the HLSL path (XCL_SAFE_BARRIER=0: as before, in both translators). Not run on a GPU: whether this was the cause of those time-outs is not shown, and the HLSL compute pass of that title's mesh pipelines has not run in its 16-window layout. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Translated shaders index the bound sampler heap with S# word 3 & 0x7FF (SamplerDescriptorHeap in the HLSL path, SAMPLER_HEAP_MASK in direct DXIL), so an index from 0 to 2047. A console sampler heap got as many PC samplers as the title asked for (128 in a retail title): an S# the title builds itself with a nonzero border color pointer in word 3 [11:0], or any index from 128 on, read past the end of the bound PC sampler heap, which D3D12 leaves undefined. A shader-visible console sampler heap now gets 2 048 PC samplers (the D3D12 maximum for a shader-visible sampler heap) whatever the title asked for, all of them made as the zero sampler XCL already wrote into the title's slots (point, wrap, mip 0). The console side does not change: the heap keeps the title's slot count, its 16-byte increment and its indexes, and copies, CreateSampler and the release only touch the title's slots. A CPU-only sampler heap keeps the title's count (shaders never bind it). The cost is up to 2 048 CreateSampler calls and 2 048 PC sampler descriptors a heap. The PC heap's own GetDesc (not hooked) now says 2 048 for such a heap; a console view heap's already says twice its slots. Tested on the software adapter only (WARP): the new test every_sampler_index_a_shader_forms_is_in_the_pc_heap checks the count for every index a shader forms and that D3D12 makes a shader-visible sampler heap of that size. Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t ranges view_want's per-thread memory of the ranges it asked for lately matched an exact (va, len) among the last 8. Mesh-stage root views of a retail title come at a new offset of tiles asked for already, draw after draw, so 12 000-74 000 of them every 2 s missed it and walked their tiles again in sparse::map_mirror (a shard lock and a hash insert a tile) for nothing. The memory now holds the span of 64 KiB tiles each range covers, 32 of them, and a range is skipped only when all its tiles lie in one span asked for while the GPU views were as they are now: it is still emptied when kernelx::gpu_view_map_gen() changes, and a range reaching one tile further still goes to map_mirror. What gets mapped does not change. map_mirror returns how many tiles it queued, and the "KB new" figure of the "GPU view (2 s)" line counts those tiles (64 KiB each) instead of the length of every range that missed the memory: before, 0.3-35 % of it ever became a filled tile. Tested: cargo test --release -p xcl --lib view_want (3 passed) and map_mirror (1 passed), on the software adapter. Not run on a GPU or a title: the miss rate on a title is not measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The compute path kept a driver blob on disk only when its build took 250 ms (driver_cache::KEEP), and XCL_PSO_DISK_CACHE_MIN_MS, which the graphics and two-pass paths read, did not reach it. A compute program whose build takes 100 to 250 ms was compiled again in every run, at its first bind, and a compute pipeline is waited for: often on one of the title's threads. In a retail title's run one of its threads spent 228 ms in the driver on a 4 KB program that no file was kept for. driver_cache::keep (its only caller is translated_compute_pso) now keeps a blob of a build of 20 ms or more, and XCL_PSO_DISK_CACHE_MIN_MS chooses for it as for the others. The graphics and two-pass default stays 250 ms. The cost is more small files in the driver folder, at most one a compute program. Programs under 16 KB of DXIL still keep no blob (COMPUTE_BLOB_MIN_DXIL), as before. Tested with the unit tests only (software adapter): the new test keeps a 100 ms compute build and fails on the old threshold. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ges by counters A wave64 program on 32-lane hardware runs as two hardware halves that exchange ballot words and lane values. Groups of more than one console wave do that through bounded group-shared counters; a group of exactly one (33 to 64 threads) met at a group barrier at every exchange. Those barriers hung NVIDIA GPUs when several such programs ran at once (xcl-dev#1727: device hung and driver event 153 in 11 of 25 parallel runs of the lib tests on an RTX 5070, none on the HLSL path, whose exchange spins by default). A retail title's world runs such programs on several queues at once and ended in a driver time-out with no shader exception. A compute or mesh group of one console wave now takes the counter exchange too (its slots and counters are made for it when the program has no LDS). Geometry programs, which set their partner by phase, and the tests' kernel form keep the barrier. The change is that of xcl-dev#1741 (hajduzsolt), which is open and written against an older main; applied here by hand. Not run on a GPU. The test checks the translated program: one group barrier (the start's) and the counters' atomics for 33, 64 and 128 threads. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… ones A retail title's world made about 33 committed buffers of 1-32 MiB a second for two-pass mesh draws, and let as many go, on a card that was nearly full (the "two-pass res buffer #n" lines: xcl-dev#2048 at 201 s, #8192 at 384 s). Most of them are 32 MiB, and they do not come from DispatchMesh: an ExecuteIndirect of two-pass commands always asked for 32 MiB of records (each with a 1 MiB argument scratch block), since a command's groups are known on the GPU only. A DispatchMesh asked for its need, at least 4 MiB. Each recording keeps its buffers until its PC allocator is reset; then they went to FREE_RES, which kept 16 buffers or 256 MiB at most: eight of the 32 MiB ones. 24-27 of them were made in the world's first two seconds, so each round of allocator resets let go of most of what the next recordings made again. The pick from FREE_RES also took the first buffer large enough, so a DispatchMesh of a few groups could take a 32 MiB one that the next ExecuteIndirect then made anew. - Record buffers are a power of two from 1 MiB (the scratch block's size) to 128 MiB. A draw gets at least the groups it got before (a test checks this over record sizes, splits and group counts). An ExecuteIndirect keeps 32 MiB of records unless a command's groups in X (65 535 / split) need less, which leaves its group cap as it was. - FREE_RES keeps every buffer handed back, up to 1 GiB, and lets go of one no recording took for 2 s; a recording takes the smallest one that fits, the last handed back of that size. What it keeps is bounded by what recordings took in the last 2 s and by 1 GiB. When a buffer goes back to FREE_RES does not change: when its allocator is reset (or alloc_pool sees the GPU past its submits), or 10 s after a recording with no known allocator. A buffer leaves FREE_RES only for a recording or to be let go, both after that point. The DispatchMesh floor goes from 4 MiB to 1 MiB: fewer bytes past the last record. Every store to a record is bounded by its vertex and primitive counts (HLSL and direct DXIL mesh and geometry paths), so a store does not reach past the records a draw dispatched. Tested on the software adapter only (unit tests of the sizing and of the pool). Not run on a GPU or with the title: how many buffers a frame now makes is not measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The coherent window is committed when unified memory is made, so it is sized from what the title asked of it in an earlier run (<data>/cache/uma_coherent.txt), and that value only grew. A retail title's 4582 MB of GPU heaps, stored by a run that put them in the window, made two coherent windows of 4095 + 998 MB in later runs with XCL_COHERENT_HEAPS=sparse:16. Those runs sent every such heap to the sparse windows and put at most 105 MB in the coherent window, but with XCL_UMA_SHADOW=1 each window is shadowed by a video-memory heap of its full size: about 4.6 GB of video memory and as much commit for nothing, on a card that was full. The sparse branch returned before the need was noted, so the stale value never came down. uma_coherent.txt now keeps one size per XCL_COHERENT_HEAPS setting (lines "<bytes> <setting>"; the old single number counts as the setting that puts every heap in the window), and the window is sized from the one of the run's setting. A heap sent to the sparse windows is noted too, and a run that has lasted 60 s stores what it put in the window by then even when that is less than the stored size. A run that ends sooner only grows it, so a run cut short before it made its heaps does not leave the next one a window too small for them. XCL_COHERENT_MB still chooses the size. With one coherent window instead of two, the view windows of the 16-window layout start at window 4 instead of 5. Everything that uses them asks the layout (is_view_window, bind::view_span_of, list_x::pc_va_in, real.rs), and the uma tests already build that layout with a 512 MB window. Shader translation and the shader and driver caches are keyed on the number of windows (pso::mem_windows), which does not change. Tested: cargo check -p xcl --tests; the uma and kernelx unit tests (new: the_stored_coherent_need_is_the_one_of_the_heaps_setting, coherent_heaps_routes), on the software adapter. Not run on the title or on a hardware GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ull views When the shared view heap is full, a page of a console view heap that is first used gets no place there. console_heap::slot then gave its slots the index 2k, the one they would have in a PC heap of their own, and XCL wrote that index into the slot's T# (CreateShaderResourceView, CreateUnorderedAccessView, copies). But that heap is CPU-only once it is meant for the shared heap, and lists bind only the shared heap, so the shaders read descriptor 2k of the shared heap: another heap's view, a memory window's raw buffer UAV for k from 2 to 9 (read as a texture, which hangs NVIDIA), or, for k of 500 000 or more in a large heap, a descriptor past the heap's end that the translators' guard (below 2^21 - 1) lets through. Such a slot now has index 0, the null SRV / UAV pair at 0 / 1, with no shared descriptor and no GPU handle (nothing is copied for it, and a UAV clear of it is skipped as before). A heap that has no shared heap at all keeps its own PC heap and 2k. The frame-trace census takes 0 as such a slot's own index. Every page that finds no room is counted (each try), and the warning comes at the first and at every power of two with the count, where it came only once before. Nothing in the logs of the last three runs of a retail title shows the shared heap full, so this does not explain them; that title's heaps would need 2.56 times the shared heap if every page were placed. Tested on the software adapter only: the new test a_slot_whose_page_finds_no_room_names_the_null_views (a fake shared heap with room for one page, run in a child process) fails without the change (slot 258 got index 516) and passes with it. Not run on the hardware GPU or on a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
How many two-pass record buffers and argument scratch blocks were alive at once was not logged: the analysis of a retail title's world had to work it out from the addresses of the first 48 and the powers of two of "two-pass res buffer #n", and could only guess their share of the 5 GB of video memory the memory line does not name. A two-pass buffer is now a TwoPassBuf that counts itself when it is made and when it is dropped, wherever that happens (FREE_RES letting go of an idle one or one past its cap, the no-allocator hold past its cap, a test). A line, always on, at most every 2 s while the counts change: D3D12.X: two-pass buffers: N made, N taken again, N let go; N alive (N MiB), N of them kept for reuse (N MiB) The line is left out when FREE_RES is locked on the same thread (a buffer dropped there); the next change writes it. No behaviour change besides the line. Tested on the software adapter only (the bind unit tests; the line shows in their output). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dispatch waits for its compute pipeline until it is built, and a bind
whose pipeline no worker has started builds it on its own thread, outside
the gate of huge driver compiles. A lazy compute pipeline is sent to no
worker before its first bind, so its first bind always builds it there. In
a retail title's run one of its threads spent 57 s in the driver's
compiler on one program no earlier run had used (827 KB of DXIL, no driver
blob), and another of its threads waited for that pipeline all the time:
no frame for 57 s.
XCL_CS_PSO_WAIT_MS=<ms> is a budget of compute pipelines, as
XCL_GFX_PSO_WAIT_MS is one of graphics pipelines (it goes before
XCL_PSO_WAIT_MS for them). With it a bind takes the path XCL_PSO_WAIT_MS
takes today (resolve_within): the build goes to the xcl-pso workers, where
a huge driver compile waits for its slot once no thread waits for it, the
bind's thread waits at most the budget and never builds the pipeline
itself, and past the budget the pipeline is late: its dispatches get the
stand-in until it is built. Dispatch, the console list replay and
ExecuteIndirect already skip a dispatch with a stand-in and count it
(Dispatch and the replay as a skipped dispatch, ExecuteIndirect as a
skipped draw). Each late program is logged once ("compute pipeline of
record X not built after N ms: its dispatches are skipped until it is"),
by its console program's hash, which the pipeline now carries from its
creation.
Unset or 0, a compute pipeline is waited for exactly as before: the
budget is XCL_PSO_WAIT_MS, and without that, until it is built.
What a skipped dispatch breaks: what it computes is missing or old until
the pipeline is built. When that is the count of a later ExecuteIndirect
(culling and compaction programs), indirect_guard replaces only counts out
of range; an old count in range still draws or dispatches over old data.
Tested with the unit tests only (software adapter): the choice of the
budget, a bind that waits no longer than it while a worker (not the bind's
thread) builds a lazy compute pipeline, and one log line a program. Not run
on a GPU or on the title: what skipped dispatches do to its frames is not
known.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pool tile that flush_parked unmapped went straight to the free list, and take_tile popped it last in, first out: the tile unmapped last was the next one mapped, cleared and filled for another address on the "xcl sparse queue". When the free list was empty, take_tile even flushed the parked tiles itself and took one of them in the same submit. That queue waits for no title queue (with the readback queue, the normal case), so work the title submitted before the unmap and still running on its own queues could read the new owner's zeros or bytes, or write into its tile through the old mapping. vram.rs keeps its freed pages cooling for 2 s (COOL) for the same reason; sparse.rs had nothing of the kind. Freed pool tiles (flush_parked, and release_if_unused when a placed buffer's last user goes) now go to State::cooling with the time they were freed. take_tile takes the oldest tile freed 2 s ago or more, then one of the free list (tiles of a pool never used), and otherwise takes back a retired pool or makes a heap: a tile freed less than 2 s ago is never handed out, and take_tile no longer flushes the parked tiles (they would only start cooling). retire_free_pools counts only free and cooled tiles, so a pool with a tile still cooling is not retired. new_mirror's "tiles at hand" check after a failed heap counts free, cooled and retired tiles, no longer parked ones. pool_bytes counts the cooling tiles as not mapped. This is a time bound, not a fence: a GPU frame longer than 2 s can still race. It holds more video memory while a title gives back and asks for tiles (about 2 s of freed tiles, 60 MB at the 466 tiles/s measured). Tested on the software adapter: cargo test --release -p xcl --lib sparse (51 passed, 0 failed, 1 ignored). New tests a_freed_pool_tile_cools_before_it_is_used_again and a_pool_with_a_tile_still_cooling_is_not_retired (an injected clock), and a_tile_given_back_is_not_used_again_before_it_cooled (a state on the software device); all three fail with COOL set to 0. a_tile_decommitted_and_committed_again_keeps_its_video_memory, changed here for the new rule, opens the hardware device and was not run. Not run on a GPU or a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 64 MiB pool heaps that back the 64 KiB pages of textures in title memory (vram::Pages) only grew: bind made a heap when the pool had no free tile, and nothing ever let one go. In two runs of a retail title 350 MB of those pools sat free, more after a streaming burst, on a card that was full. A pool heap all of whose tiles are free goes now. A tile is only in a free list after COOL in the cooling queue, so such a heap has no page in use, idle or cooling. After each placement, TilePool::take_free_heaps takes such heaps out: their tiles are not handed out again, and their index becomes free (TilePool::live, Pages.pools holds None there). The next heap takes the first free index. take_batch now gives make_heap the index to fill, so the pool and Pages.pools cannot disagree on it. A tile of a given-back heap that came back to the pool (none should) is dropped instead of handed out. A heap that came free is retired first, as sparse.rs retire_free_pools does with its pools. The next pool that is needed takes it back before a new heap is made, so placing and freeing in turn does not make and end a heap each time. It is let go once the page-mapping fence is past the value it had when the heap came free and 2 s went by. Even then it does not go at once: it goes through late_release (new: hold_heap, Dead::Heap), in a batch sealed after it. A texture the title released is held there and still maps pages of the heap, and work queued before that release may still read them. A heap destroyed under that work is a GPU page fault, where a page reused under it only gives wrong texels. So the heap goes once every queue XCL knows of is past that work, never before the textures held with it. If a queue never gets past, the heap is never released, which is no worse than before. The 'pools' figure of the memory line (page_bytes) counts the retired heaps that are not let go yet. Tested: cargo check -p xcl --tests; the vram and late_release unit tests on the software adapter (new: tile_pool_gives_back_wholly_free_heaps_and_reuses_their_index, retired_pool_heaps_go_after_the_fence_and_a_moment). The test of the churned pool now also checks the index each new heap gets. Not run: the tests that place textures on a hardware device (d32s8_targets_take_their_own_size_of_video_memory, reservable_agrees_with_the_driver and the other hardware tests), the title, and any real D3D12 run of bind with a heap given back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build-ahead backlog took a lazy compute pipeline only when an earlier run had used its shaders (used-pipelines.txt). Any other compute pipeline was built at its first bind, which waits for it: in a retail title's run one of its threads spent 57 s in the driver's compiler on a program the two runs before had never used, while another of its threads waited for it. Compute pipelines of shaders no earlier run used now go to the backlog too, in a lane of their own. The backlog serves the known compute pipelines first, then this lane, then the known graphics ones, then the other graphics ones (translated first, then built) as before. The known compute ones, which used to share a lane with the known graphics ones in the order they were made, now all come before them. The new lane is under the rules of every pipeline no earlier run used: built only with XCL_PSO_AHEAD's cap not reached and 8 GB of commit free (ahead_room), counted against that cap, on the lowest-priority preload workers, a huge driver compile behind the gate and giving its turn to any build a bind waited for, and one a bind wants is left to the bind's workers. This shortens how long a new compute pipeline is waited for (or, with XCL_CS_PSO_WAIT_MS, how long its dispatches are skipped) and fills the driver blob folder for the next run. It cannot build all of a title's compute programs in its menus on a first run: a retail title has ~1 600 it never used, many of them taking the driver seconds to a minute. The cost: each pipeline built keeps ~400 KB in the driver whether it is used or not, and the known graphics pipelines are built later than before, so a draw is more likely to wait for one (or, with XCL_GFX_PSO_WAIT_MS, to be skipped). The test of known pipelines built ahead no longer says an unknown compute pipeline is still pending before its first bind (it may now be built ahead); it still says nobody used it before then. Tested with the unit tests only (software adapter): the lane order, room and cap, and a lazy compute pipeline of new shaders built with no bind when commit is free. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…texel size A dumped texel was read as 4 bytes at a 4-byte stride whatever its format, and only four formats had a colour. A retail title's scene colour (RGBA16F), its normals and velocities (R16G16), ids (R32_UINT) and masks (R8) were written as black pictures, "format not decoded", with every other half texel in the raw values; a one-byte target was read past its rows. The picture stayed flat over a drawn G-buffer and the stages between could not be looked at. Texels are read at the size of their format and the float, 16-bit, 8-bit and integer render-target formats get a colour (floats tone-mapped as R11G11B10 is, NaN and infinity white). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sparse windows' timing line is written only at power-of-two submit counts, and TILE_WORK is read only with XCL_LOOK_STATS=2, so the logs of a run that ended in a graphics driver hang had no rate of mapping changes in its last minute: the UpdateTileMappings calls and tiles a second could only be inferred. map_tiles and unmap_tiles now count their calls and tiles with relaxed atomics, always, split by the kind of window the resource lies in (sparse windows, view windows for GPU views; a placed buffer counts with its window), and the activity thread logs them every 2 s: tile mappings (2 s): sparse windows N calls mapping N tiles, N calls unmapping N tiles; GPU views N calls mapping N tiles, N calls unmapping N tiles The line is left out when there were no calls. The vram.rs tile-mapping queue (textures in title memory) is not counted here. Tested on the software adapter: cargo test --release -p xcl --lib sparse (52 passed, 0 failed, 1 ignored), new test the_tile_mapping_line_counts_since_the_last. The line was not seen in a run of a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in the log said how full the shared view heap got: the only line was the warning once it was full, so a run that came near the end, or how fast pages were placed, could not be told from the log. A retail title's heaps would need 2.56 times the heap if every page were placed. The shared heap now counts the pages of console heaps placed in it (placing one adds, a heap's release takes its pages off), and the first time the descriptors in use (those below the cursor, less the released ranges; the null views and memory windows at the start count) pass 50, 75 and 90 % of the heap, one info line says the mark, the descriptors in use, the heap's size and the pages placed. The full warning gives the same numbers. The 2 s "memory:" line in host.rs is left as it is: adding the heap there is more than a one-line change, and the marks give the same answer. Tested on the software adapter only: shared_heap_use_and_the_marks_it_passes (the arithmetic) and the placed-page count and marks in a_slot_whose_page_finds_no_room_names_the_null_views. Not run on a title, so the log lines have not been seen in a run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing bounded the two-pass record buffers and argument scratch blocks alive at once: each recording holds its own until the GPU is done with it, and a retail title's world had about 0.8 GB of them a few seconds in, on a card its process kept nearly full. A committed buffer made there succeeds above the OS budget, so nothing else would have stopped them. A two-pass buffer is now made only if the bytes of those alive (held by recordings, waiting for their allocator, or free) stay within the cap: 1024 MiB by default, XCL_TWO_PASS_MB to choose. When they would not, the free ones in FREE_RES are let go first, oldest first, as many as it takes (the GPU is done with them). If that is not enough, the buffer is not made and the draw that asked for it is skipped, as one whose record does not fit the record buffer is today, with a warning the first 8 times and a count on the "two-pass buffers" line. The count is reserved before the buffer is made, so threads making them at once do not pass the cap together. Buffers held for a recording are never let go for the cap: when they go does not change. Tested on the software adapter only (unit test of the reservation and of making room). Not run with the title: whether 1 GiB skips draws in its world is not known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit lowered the compute keep threshold to 20 ms, but translated_compute_pso reaches driver_cache::keep only when keep_compute_blob returns a blob, and keep_compute_blob returned none for a program under 16 KB of DXIL (COMPUTE_BLOB_MIN_DXIL). So the case that commit gave as its reason, a 4 KB program a retail title's thread spent 228 ms on in the driver, still kept no file and was compiled again in every run; its test called keep() directly and skipped that floor. The 16 KB floor now applies to the in-memory store only (compute_blob_kept): a compute build of the keep threshold or longer gives its blob to the disk cache whatever the program's size, and a small program's blob is not put in memory. A program of 16 KB or more is kept exactly as before. The graphics path keeps its floor. The blob of a small program goes through the same file and load path as the others (the driver refuses one of another driver, adapter or root signature, and the program is compiled as before). Tested with the unit tests only (software adapter): the new test of compute_blob_kept says a 4 KB program built in 228 ms goes to disk and not to memory. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit wrote one line "<bytes> <setting>" per
XCL_COHERENT_HEAPS setting into <data>/cache/uma_coherent.txt. Every
build of a title shares that folder, and builds from before that commit
read the file with trim().parse::<usize>(): on the new text they got 0
and made a 512 MB coherent window with XCL_COHERENT_HEAPS unset, too
small for a retail title's 4.4 GB of GPU heaps, which then go to plain
memory where its shaders read zeros. They then wrote a bare number over
the file and dropped the other settings' sizes, so the two formats kept
overwriting each other, and a main run after a run of this build (as
the smoke comparison does) started with the small window.
uma_coherent.txt now stays one number, the size for the setting that
puts every heap in the window, read and written as before. The other
settings keep theirs in uma_coherent_<setting>.txt (':' as '_'), which
earlier builds never open. A uma_coherent.txt in the per-line format
reads as none here too and is written over with a number at the run's
first GPU heap.
Tested: cargo check -p xcl --tests; cargo test --release -p xcl --lib
coherent (7 passed, on the software adapter), with the changed test
the_stored_coherent_need_is_the_one_of_the_heaps_setting. Not run on
the title or on a hardware GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…frees none Since freed pool tiles cool for 2 s before reuse, a pool can only be retired once its last tile has cooled. retire_free_pools was still called only right after flush_parked() freed tiles, and the tiles that flush freed were stamped with its own instant, so they could never complete a pool there. When the title stopped giving tiles back after a level unload or forget_mirrors, nothing called retire_free_pools again: the 64 MB heaps stayed (and retired heaps were not dropped) until some later give-back. A submit now also tries retire_free_pools when no tile was flushed but a tile in cooling has cooled or a retired heap waits to be dropped, at most once per COOL after the last try (retire_due, retire_tried), so a submit does not count the cooling queue every frame. A pool goes at most about 2 x COOL after its last tile was freed. The other call sites (the PARKED_MAX flushes while decommitting) are unchanged. Retiring later than the flush uses a fence value at least as new as the one the flush signalled after its unmap, so the heap is not dropped earlier than before. Tested through the software adapter only (no hardware GPU): a_submit_with_nothing_freed_retires_pools_once_tiles_cooled (pure, with an injected clock) and a_pool_goes_once_its_last_tile_cooled_with_nothing_parked (state on WARP: the pool's last tile is freed at a submit, then a submit COOL later with nothing parked retires it; it fails without the change). cargo test --release -p xcl --lib -- --test-threads=2: 1221 passed, 0 failed, 23 ignored, 52 tests that open the hardware GPU not run. Not run on a GPU or a title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a new two-pass buffer would take the buffers alive past XCL_TWO_PASS_MB, TwoPassBuf::make let the freed ones in FREE_RES go, oldest first, until they came to the bytes over the cap. It did so also when all of them came to less: the whole pool was let go, the second reserve still failed and the draw was skipped anyway. The recordings after it, which would have taken those buffers again and drawn, then found the pool empty, asked make() for new ones and were refused too. At the cap that skipped more draws than needed and sent a burst of resource destructions to the driver when the card is fullest. FreePool::take_room now gives nothing and keeps the pool when all it holds is less than asked, and make() works out the bytes over the cap with FREE_RES locked, so the free ones are in the load it compares. One attempt still (a buffer another thread reserves in between can make it fail after the free ones went, as before). Verified: the two_pass unit tests on the software adapter (take_room of more than the pool holds gives None and keeps it). Not run: a title, and the tests that open the hardware GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lane of compute pipelines no earlier run used, added two commits ago, came before the known graphics pipelines with no bound: every preload worker took from it while it held anything, and pipelines made later joined it ahead of all queued known graphics ones. A retail title makes ~1 600 compute pipelines it never used, some taking the driver a minute, and there are 2 to 4 preload workers, with one huge driver compile at a time behind the gate: all workers could sit on that lane (one compiling, the others parked at the gate) for the whole session, and no known graphics pipeline, not even one whose driver blob loads in milliseconds, would be built ahead. Each would then be built at its first draw on the title's thread. That commit's message said they are built "later than before"; they could be starved. Backlog::next now hands out one pipeline of that lane at a time (compute_out, cleared by Backlog::built when the worker's build is over or a bind took the job): while a worker builds one, the other workers take the known graphics pipelines and the rest in the order as before. The known compute pipelines still come first, and the lane is still under ahead_room, ahead_cap and the gate. Left out: when nothing else is queued the other workers stay idle rather than build more new compute pipelines; the lane drains at one worker's speed. A known huge graphics build can still wait at the gate while the lane's build holds the only huge slot (XCL_HUGE_PSO_CONCURRENCY default 1), as any two huge builds ahead of their use do. Tested with the unit tests only (software adapter): the new test takes pipelines from the backlog without finishing them and gets the known graphics ones while a new compute one is out, and the next new compute one only after it is built; the lane order test still passes. Not run on a GPU or on the title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A picture regression on this branch: single black frames during loading, about every 16th frame, that Tested
Not tested
AI use: Claude Code (Claude Fable 5.2) ran the runs, counted the frames with a script and wrote this. |
|
@throny we traced the same flicker on our tree: it comes from the hot-block CPU-write looks, Why. A look before each submit takes only the 2 MiB blocks written in the last What we measured (RTX 5070 Ti, retail title, art screens):
What we run instead, to keep the cheaper looks: write guards on cold blocks. When a block leaves the hot set, a guard thread makes it read-only ( AI-assisted. |
|
@claudetools-gh confirmed on the RTX 4080, thanks: with
AI use: Claude Code (Claude Fable 5.2) ran this and wrote it. |
… CLZERO CLZERO is AMD's; on an Intel CPU each clzero raises an illegal-instruction exception that XCL answers by emulating the loop it starts (insn::ConsoleOnly::ClzeroLoop): one exception for every run of the loop. A retail title's memset is such a loop. While its world loaded on an Intel CPU one of its threads was in that exception at every thread dump (300, 360 and 400 s of several runs), and XCL_GPU_TIMES measured 0.17 to 0.51 s of GPU work in world frames that took 17 to 43 s: the card stood idle while the CPU side crawled. When an image is mapped on a CPU without CLZERO, each such loop (12 bytes) becomes a call of a stand-in next to the image that zeroes the same whole lines with rep stosb and leaves rax, the flags and every other register as the loop does. XCL_CLZERO_PATCH=0 keeps the emulation. A lone clzero is still emulated. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ommit headroom With a wait budget (XCL_GFX_PSO_WAIT_MS, XCL_CS_PSO_WAIT_MS) a bind gives up on a pipeline after its budget and the build is no longer wanted, so its huge driver compile waits at the gate for the full commit headroom (3 GB). On a machine with 4.5 GB of commit left (44.6 of 49.1 GB) 33 such builds stood there, one for 129 s, while 44,596 draws of a retail title's world were left out for want of them and 2 frames were presented in 200 s. A late build now waits for half the headroom: 1.5 GB for the class from 256 KB, what one such compile takes. Builds ahead of first use and builds nobody used wait as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…form in the call An indirect dispatch of a split compute program runs its whole form, which was built at its first use on the title's thread (Chain::whole, under build_whole). On a retail title's first world frame a render thread stood in bind::execute_indirect -> dispatch_chain::whole behind that lock (thread dumps at 240, 300, 360 and 400 s of a run on an RTX 3060 Ti) while the driver compiled 1.1 MB of DXIL: no present and no submit from 224 s to the end of the run at 420 s. Where compute dispatches go on without a pipeline still being built (XCL_CS_PSO_WAIT_MS), the whole form is now built once by a thread of its own, and until it is there the program's indirect dispatches are left out and counted as skipped, as those of any late compute pipeline. Unset, as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rote A title that commits a pool up front gets a video-memory tile for every page at once (Series S profile of a retail title: 70,724 tiles in 2 s). The line says how many of the windows' own tiles never had a CPU write sent to them, so the cost of mapping at commit can be read from a log. No behaviour change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Target pages grew from 1,910 MB at a retail title's menu to 6,408 MB while its world loaded (Series S profile, RTX 3060 Ti 8 GB), and the memory line gives one figure for them. The new line splits them into textures with all their pages and sampled textures with pages by level (XCL_TEXTURE_LEVEL_PAGES), a shared page counted for each texture on it, and counts the idle pages waiting to go back to the pools. Logged next to the memory line, only when there are target pages. No behaviour change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… memory at its first use A tile the title commits in a sparse window got a pool tile at the commit (State::commit_range -> ensure_mapped). A retail title on the Series S profile commits a page pool of 63,632 pages of 64 KiB in a sparse window up front: 4.3 GB of video memory at once, 3,751 MB of it in tiles the CPU never wrote, on an 8 GB card. With XCL_SPARSE_LAZY=1 a committed tile is listed with no pool tile (LAZY) and gets one when it is first used: - the CPU's first bytes for it at an upload (upload_dirty); a pool tile used before is cleared right behind its mapping, before those bytes go up; - a memory write recorded on a list (immediates, fills, copies, timestamps: will_write), before the list runs; - a buffer placed on it (buffer_tiles); a tile that finds no video memory is left out of the buffer's mapping instead of naming pool u32::MAX; - bytes that found no video memory at an upload are owed (starved) and go up whole once there is some. A copy back of a tile with no memory copies nothing. The switch is left out on a device whose unmapped tiles do not read zeros (tiled resources tier under 2). Off by default. Measured on an RTX 3060 Ti 8 GB, 60 s with no input, Series S profile: local video memory 7,503 MB without the switch, 3,022 MB with it; 542 frames against 376; 0 draws skipped either way. Tests (sparse::tests, real GPU, skipped without tiled resources tier 2): a tile's first bytes reach the GPU and are still there two submits later; bytes that found no memory go up once there is some; a recorded write gives memory and a buffer never maps the sentinel; a decommitted tile frees and parks nothing, and with the switch off a commit maps at once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3D12.X: XCL_SPARSE_LAZY=1 gives a committed sparse-window tile video memory at its first use
…-owners-line D3D12.X: the activity log says who holds the target pages
…ve-loops PE loader: a title's CLZERO loops run as native code on a CPU without CLZERO
…half-headroom D3D12.X: a build the title already draws without waits for half the commit headroom
…ole-off-thread D3D12.X: an indirect dispatch does not build a split program's whole form in the call
|
What I do now: the runs on this head go on with AI use: Claude Code (Claude Fable 5.2) ran this and wrote it. |
…wave32 Options::default() is wave64, so the "HLSL wave32" form of gpu_compute_thread_limits_leave_the_lanes_past_them_out was the native wave64 form: on a GPU without wave64 (every NVIDIA card) CreateComputePipelineState refused it with E_INVALIDARG and the test failed before it checked anything. The test only ever ran on the software adapter, where it skips. With wave64 off it passes on an RTX 5090 in all six forms that card runs (HLSL, direct and per-lane; wave32 and split wave64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On our card, a compute pipeline created from its stored driver blob takes as long as a fresh compile (RTX 4080 16 GB, driver 621.40, Windows 11 26300; This explains two things we kept seeing on this head: the shader preparation takes 7-8 minutes at every launch (also directly after a launch that completed it), and the world shows no frame for the first 10 minutes. Measured with a local timing line in the preparation workers (one line per pipeline over 1 s; two launches, 192 lines):
So for these large programs the stored blob saves nothing here. Questions for the other NVIDIA testers: do you see "driver blob supplied" followed by a finish line over 10 s for compute pipelines on your driver version? If someone on an older driver sees them load in under a second, this is a driver regression and worth knowing before anyone tunes around it. What I can try next, unless someone already has: the same launch with the profile at 2048 MB; one launch with the NVIDIA cache folder for this exe cleared and rebuilt (in case the driver's own cache entry for these programs is rejected each time); and splitting, i.e. whether the pieces of a split program load fast where the whole form does not. Tell me which is most useful. Numbers are from logs of real runs on the hardware above. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this; the timing line is a local diagnostic, not a PR. |
|
Re your question about other NVIDIA versions: in earlier runtime logs from a 12 GB RTX 5070 Ti Laptop on 621.24, 141 of 147 compute PSO calls of at least 750,000 B DXIL with
I paired start/finish lines by compile ID and verified matching thread and DXIL size. These are the title-runtime calls from the same release run on Windows 11: |
|
Follow-up to the stored-blob timing above: I posted a plan on #2088 for a small PR that lets the shader preparation skip records whose blob it has already verified (marker with driver identity and blob length), which should cut the 7-8 minutes per launch on NVIDIA to seconds: #2088 (latest comment). Starting now in a branch off |
|
@ettehn thank you, that is exactly the comparison I needed: under 1 s with a supplied blob on 621.24, against 15-20 s here on 621.40 for the same size class. So the blobs can load fast and something on this machine prevents it. What differs here besides the driver version: AI use: Claude Code (Claude Fable 5.2). |
|
Six tests fail on the clean
I have not looked into causes; posting so that nobody takes them for regressions of a PR tested on NVIDIA. If they pass for others on this head, tell me and I will dig into what differs here. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this. |
|
Follow-up on the slow blob loads (RTX 4080, driver 621.40): the 1 GiB profile is not the cause. The same build under another exe name (no profile), second launch, so with the driver's own cache for that name warm: 67 creations from stored blobs at 750 KB-1 MB of DXIL took 19.7 s on average, 13 above 1 MB took 28.2 s (with the profile: 14.9 s and 19.7 s). The first launch under that name, with the driver's cache cold, took 50 s and 74 s for the same size classes, like a compile without a blob. So on this machine the stored blob never makes creation fast; whatever speed there is comes from the driver's own cache, and for the large programs that is 15-30 s each. @ettehn measured under 1 s on 621.24 and @andrewDoing milliseconds on 616.92 (small synthetic programs, on #2951), which leaves the driver version as the main suspect here. A rollback to 621.24 would settle it; that needs the machine's owner, so it will not happen tonight. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this. |
What is in it
Tested
cargo test --workspace -- --test-threads=4: N passed, N failed, N ignored (SKIPPED GPU tests: …)Regression run
main:
PR:
Not tested
AI use