perf(gpu): async copy/reset, fast bind/stand/views, texevents pool, and steady-world async PSOs #424
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/gamingwithhomie--larp!424
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-424"
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?
@kirksw on GitHub · 2026-12-06 00:40 UTC · original
kirksw:perf/wave-2→main· +4069 −826 · 21 files · 1 commits · openTL;DR
Follow-up wave of Tracy-driven CPU-overhead and worst-frame-low optimizations for
larp-gpuon top of PR #185, targeting the remaining recording (draw: bind,heap_buffers,ExecuteIndirect, descriptor views), submission (copy_send, allocator resets,texeventsuploads), and steady-world PSO compilation hotspots:7.1–10.3 ms/f(PR #185) →1.8–2.2 ms/f(~3–4× lower prep overhead)94–123 msspikes →47.6 msavg worst (21.0 fps), with37.8 fpsavg (peak47.1 fps) and24.2 fps(41.4 ms, best25.7 ms) 1% lows at7,153draws/frameSend/64 MiB byte budget,TableScratchundo,FLAG_EVENT_SHOWN,HeapSpansper-list materialization)<FLAG>=0to disable);LARP_OPT_ASYNC_WORLD_PSOSis opt-in (default OFF,<FLAG>=1to enable) because it trades momentary pop-in on newly-seen non-lasting geometry/decal draws for worst-frame consistency. Every flag is documented indocs/environment-variables.md, with no shader-cache invalidation.Overall Progression (Series X · 4K · Hardware RT ON · RTX 4090)
f9fb54c, 48.8 min)perf/cpu-and-lows)LARP_OPT_ASYNC_WORLD_PSOS=1(11.2 min driving)Test Machine & Configuration
2048 MiB, D3D12 Agility SDK1.620.2)--console series-x(4K3840x2160, Hardware RT ON Tier 1.2, DLSS Preset M via Streamline, Frame Generation OFF)settings.inioverrides:frame_rate = 60,desired_fps = 60frame_generation = off,reflex = offlighting_quality = ultra,reflection_quality = ultrahair_gpu_memory_budget = ultra,hair_simulation_quality = ultraProfiling
Captured 30-second fine-grained open-world traces with Tracy (
--profile tracy --features tracy,LARP_TRACY_FINE=1, 888 frames /154MCPU zones /915kGPU events). Each remaining hotspot mapped directly to one of the optimizations below:draw: bind/stand()49.4 ms/fself (recording threads)ArcclonesLARP_OPT_FAST_STAND,LARP_OPT_FAST_BINDdraw: heap buffer views pass11.3 ms/fself (5.2k calls/f)HEAP_PICKSlock convoy, globalWHOLEmap, linear watch scans, per-list span rebuildLARP_OPT_FAST_BIND(HeapPass+HeapSpans)ExecuteIndirect+ descriptor viewsbuffers/changedlocks innote_buffer, double record reads, per-slot copy lookupsLARP_OPT_FAST_VIEWScopy_send/small_and_heap_send6.5 ms/fon submission threadHost::submitLARP_OPT_ASYNC_COPYlarp-land& submit tail spikesallocator.Reset(),Vec::remove(0)on held queues, inline deferred COM dropsLARP_OPT_ASYNC_RESETtexeventsuploads & reaper burststexeventsupload allocs, unpaced reaper drops,shadow::looseunder lockLARP_OPT_TEX_POOL94–123 msworst-frame spikeswait_for()on newly-seen non-lasting geometry/decal PSOs during open-world drivingLARP_OPT_ASYNC_WORLD_PSOS=1(opt-in)Changes
LARP_OPT_ASYNC_COPY)copy_sendran synchronously on the submission thread, dominatingHost::submitprep time (6.5+ ms/f).larp-copyworker thread (with FIFO fence ordering anddrain_copy_worker()sync points), switchescopy_runstoO(N log N)BTreeMapoverlap merging, and coalesces contiguous upload ranges.HeapSpanssnapshot (LARP_OPT_FAST_BIND)draw::State::bindre-walked unchanged root slots and re-kept PSOs per draw, whileheap_buffers()serialized all recording threads onHEAP_PICKSand rebuilt span lists repeatedly.stage_listslast view & per-list kept PSOs, publishes an immutable per-heapHeapSpansArconce per frame (HeapPass), uses a two-tierBTreeMapwatch index, and materializesHeapSpansonce per batch inHost::submit.TableScratchbump allocator &stand()fast paths (LARP_OPT_FAST_STAND)State::place()lockedlist.scratchand rounded every 16–64 B table up to 256 B;stand()re-decoded transient layouts/records multiple times and clonedArc<Shadow>on every lookup.TableScratchbump allocator (withscratch_undorollback on view failure), bit-exactmemcmplayout verification, single-readDecodedRecorddecoding, borrowedMemo::find_ref, and fixes astand()carry-bit bug.ExecuteIndirectfast paths (LARP_OPT_FAST_VIEWS)note_bufferand view mirroring contended on per-heap locks and re-read descriptor records multiple times per slot.changed_bits/changed_summarybitmap,FLAG_EVENT_SHOWNtracking, single-readmirror_written, contiguouscopy_simpleheap-lookup hoisting, andExecuteIndirectrepeat caching.LARP_OPT_ASYNC_RESET)larp-landandHost::submit.ReapedDeferred, paced and bounded by the64 MiBREAPER_BYTE_BUDGET) to background workers, and switches held queue storage toVecDeque.LARP_OPT_TEX_POOL)texeventsupload arenas and contended onHostHeap::madeandshadow::loose.texeventsupload arenas, paces large reaper batches (yield_now()every 16 drops), dropsshadow::looseoutside the lock, and expandsHostHeap::madeto 256 stripes.LARP_OPT_ASYNC_WORLD_PSOS, opt-in / default OFF)LARP_OPT_ASYNC_WORLD_PSOS=1) and steady 3D world rendering is established (>= 120consecutive frames with>= 500draws), lets newly-seen non-lasting graphics PSOs compile asynchronously on background workers without blocking the frame.dropped_once) until background workers finish compiling the PSO, whereas all lasting, compute, lighting, hair, and LUT pipelines still wait synchronously. Kept OFF by default so default rendering remains 100% exact.LARP_*environment variables and defaults indocs/environment-variables.md.Verification
cargo check --release --locked -p larpandcargo check --release --locked -p larp-gpu --features diagnosticspass with zero warnings inlarp-gpu.git diff --checkpasses cleanly on top ofgamingwithhomie/larp:main(d2a79dd, including#335dropped_oncefix).larp-play-20261206-005035.log:37.8 fpsavg,2.2 msprep,41.4 ms1% low,47.6 msworst frame) and 30-second fine Tracy captures (cnf-post-p12-fix-30s).crates/larp-shaderorshader_cache.rs(does not invalidate existing shader caches).<FLAG>=0;LARP_OPT_ASYNC_WORLD_PSOSis opt-in (=1to enable).Made with assistance of AI:
@vanya890 on GitHub · 2026-12-06 00:47 UTC · original
One user-visible trade-off to make explicit before enabling this by default: when the new branch in
pipeline/make.rs::ready()skips waiting,ready()returnsNoneuntil the worker publishes the PSO.pipeline::host_pipeline()propagates thatNone, anddraw::State::prepare_for()returnsfalse, so draws using that PSO are dropped on every frame until compilation finishes.Unlike the existing wait-budget path, this branch does not set/use
dropped_onceto cap the drop to one frame. WithLARP_OPT_ASYNC_WORLD_PSOSdefaulting on, newly encountered non-lasting geometry/decals/props may therefore remain absent for multiple frames on slower CPUs. That may be an acceptable hitch-vs-pop-in trade-off, but I think the PR and env-var docs should state it explicitly; alternatively consider keeping this opt-in by default until the visual behavior is validated on lower-end CPUs.@kirksw on GitHub · 2026-12-06 00:50 UTC · original
Good point - I am allergic to poor frame pacing, usually playing games at 100+ fps so I took this approach, to trade off accuracy for consistency. But not everyone would agree.
I'm not sure what the optimal default would be however?
@vanya890 on GitHub · 2026-12-06 00:55 UTC · original
I agree that avoiding frame-pacing stalls can justify this trade-off, especially on high-refresh systems. I would separate the policy from the implementation: keep the asynchronous path available, but make the default conservative until the visual behavior has been exercised on slower CPUs. A short wait budget (or the existing one-frame
dropped_oncebehavior) could preserve most of the hitch reduction without allowing newly encountered draws to disappear for an unbounded number of frames. At minimum, the env-var docs should explicitly say that first-time world PSOs can cause repeated draw omission until compilation completes, and mention the CPU-dependent duration. This is a product default decision rather than a correctness bug; I don't think the optimization itself needs to be removed.@kirksw on GitHub · 2026-12-06 01:02 UTC · original
@vanya890 noted, i will change this to default disabled and add the clarifications around the tradeoff
d4f00c0ab2to4b93c8bc794b93c8bc79to592fe49f0f@kirksw on GitHub · 2026-12-06 01:22 UTC · original
@vanya890 Updated in
592fe49: \LARP_OPT_ASYNC_WORLD_PSOS\ now defaults to off (opt-in via =1/\on), and both \docs/environment-variables.md\ and the PR description explicitly document the multi-frame draw-omission / CPU-dependent duration tradeoff (and that lasting/compute/lighting/hair/LUT pipelines still wait synchronously). Thanks for the feedback!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.