perf(gpu): reduce CPU overhead and improve 1%/0.1% lows #185
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!185
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-185"
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-05 20:51 UTC · original
kirksw:perf/cpu-and-lows→main· +845 −94 · 10 files · 8 commits · merged 2026-12-05 21:40 UTCTL;DR
Five targeted, D3D12-safe, zero-RAM-cost CPU-overhead optimizations for
larp-gpu, driven by fine-grained Tracy profiling on an RTX 4090 / i7-12700K where open-world gameplay is 100% CPU-bound (0.6 msGPU wait vs33.3 ms/fbaseline frame time):64 MiB)<FLAG>=0to disable, documented indocs/environment-variables.md), with no shader-cache invalidation.Overall Progression vs Baseline
f9fb54c, 48.8 min)0f03265(pre-patches)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 10-second open-world traces with Tracy (
--profile tracy --features tracy,LARP_TRACY_FINE=1) and exported zone totals viatracy-csvexport(baseline: 251 frames / 48M zones; follow-up: 171 frames / 23M zones). Each hotspot mapped directly to one of the five changes below:views: create / mirror slot12.0 ms/f(30.6k/5.7kcalls)HostHeap::made+ WC flushesLARP_OPT_VIEW_MIRRORlist: reset / close12.2 ms/f(~216 lists/f)HostList::clear()+ per-list recycle locksLARP_OPT_LIST_REUSEdraw: heap buffer views pass7.7 ms/f(5,563calls/f)LARP_FAST_HEAP_TABLESrelease_held(wave 2)7.7 ms/f(14.3 msmax spike)RELEASINGmutex contention + sync COM dropsLARP_OPT_RELEASE_HELDcopy_send/small_send6.5–8.8 ms/f(10.1 msmax spike)LARP_OPT_COPY_BATCHChanges
LARP_FAST_HEAP_TABLES)heap_buffers()andview_shifts()were walking descriptor heaps on ~5,500 draws/frame even though the bound heap almost never changes mid-list.(list, bound heaps)(invalidated onset_heaps), hitting 99.4% of lookups.LARP_OPT_COPY_BATCH)ExecuteCommandListsWDDM calls, cloning COM handles per copy, and stallingCOPY_LISTSduring allocator resets.COPY_DEST → COPY_DESTglobal enhanced barrier between overlapping runs, and drops finished leases outside the pool lock.LARP_OPT_VIEW_MIRROR)HostHeap::mademutex and paid redundant D3D12 null-view calls, mutex locks, and write-combined GPU memory flushes on ~30k view updates/frame.HostHeap::madeinto 64 cache-line-aligned stripes, skips redundant null-view writes and non-buffer map locks, and shadowsstridesin CPU atomics to avoid no-op WC flushes.LARP_OPT_LIST_REUSE)SPARE_STATES/IDLElock acquisition once per landed batch.LARP_OPT_RELEASE_HELD)release_heldcalls blockedsubmitfor 4–14 ms waiting on the globalRELEASINGmutex, and synchronous COMRelease()of completed upload buffers stalledlarp-relay.RECHECKhandoff (keeping fence signals andPresentstrictly synchronous), and offloads release-only upload/shadow COM drops to a low-prioritylarp-reaperthread capped at64 MiB(while keeping side-effectful retirements likert::Remakesynchronous).LARP_*environment variables and defaults indocs/environment-variables.md.Live In-Game A/B Trial Results (Series X · 4K · Hardware RT ON · RTX 4090)
Same session, matched scenes (toggled live via local F10 test menu):
LARP_OPT_RELEASE_HELDLARP_OPT_RELEASE_HELDLARP_OPT_LIST_REUSELARP_OPT_LIST_REUSELARP_OPT_VIEW_MIRROR(above 64-stripemade)LARP_OPT_VIEW_MIRRORLARP_OPT_COPY_BATCHLARP_OPT_COPY_BATCHVerification
cargo check --release --locked -p larpandcargo check --release --locked -p larp-gpu --features diagnosticspass with zero new warnings.crates/larp-shaderorshader_cache.rs(does not invalidate existing shader/pipeline caches).<FLAG>=0for clean regression isolation.Made with assistance of AI:
@gamingwithhomie on GitHub · 2026-12-05 20:53 UTC · original
Thank you - queued for review. Note it currently conflicts with current main (v1.1.1 just landed: #142/#147/#109 pipeline + translator changes), so a rebase will be needed; please keep the per-change perf numbers (1%/0.1% lows methodology) on the PR so we can weigh each hunk. Review next round.
3c3a9c0b32to8a3467585c@aptenstudio on GitHub · 2026-12-05 21:53 UTC · original
Thanks for this, the profiling write-up made it easy to follow. Follow-up now that it's merged: a review found that the
larp-reaper64 MiB budget (LARP_OPT_RELEASE_HELD) doesn't actually bound what it holds. It's still the case onmain(crates/larp-gpu/src/host.rs, the unified copy path around L6218–6240 and the readback path around L6281–6290):Arc<Shadow>goes intoretired_shadowsand on toretire_releasewithout being charged. Pieces are charged by copied length while their whole source/destination resources are retained. So a batch can retain hundreds of MiB while counting as a few, and the reaper delays its release.send.len/q.len, not the allocation.staging.rsreuses any standalone allocation withmade.len >= len, and the heap-feed range can shrink between allocating and queueing, so a large buffer can be charged as a small copy.Suggested fix, which keeps the reaper for what it can budget:
retire(...), dropped inburyonce the submission finishes).retire_release.In the unified copy path:
The readback path gets the same change: drop
retired_bytesand callretire_release(buffers_bytes(&retired_up), retired_up).In-game A/B on 1.1.2 with the same settings: the merged code gave noticeably more hiccups than the same build with this fix applied.
The same review found no other problems:
set_heaps.RECHECKhandoff.COPY_DEST → COPY_DESTbarrier.@Heliumrich on GitHub · 2026-12-05 21:57 UTC · original
Thanks, finally someone using Tracy and other profiling tools that give REAL numbers instead of just asking claude to "make no mistakes"
Tracy, RenderDoc, these will give informations on each function and renderpass cost and help way more than just looking at FPS in one spot between PRs
BTW both of these have MCP servers you can get, though Claude seems to be able to decode Tracy frame captures himself, but may be less efficient and use more tokens