[pr-performance][memory] texback: texture read-backs wait only for remaps of their own range (DARNER_RANGE_LOCK=1) #341
Loading…
Reference in a new issue
No description provided.
Delete branch "Yorivel/Darner:pr/texback-range-lock"
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?
Refs #287
Contributor role (optional)
What it changes
texback::landputs each texture read-back into title memory underwatch::title_memory_reading(), which waits for every mapping change of the title's, even withDARNER_RANGE_LOCK=1(it readsrangelock::ALL). It runs on the thread that lands flights (the relay), in the step the landing line calls "read-backs and lists". While the world streams, the title's mapping calls take hundreds of milliseconds a second, and the relay waits behind them for every read-back (about 600 a second in my runs).It now takes
watch::title_memory_reading_of(at, end - at)for the texture's own range, astexture.rsalready does for its reads of a texture's memory. Everything it reads or writes under the lock lies in that range (read_previous, the tiled copy,copy_mapped), and nothing under it takes the lock again. WithDARNER_RANGE_LOCKunset nothing changes:title_memory_reading_ofistitle_memory_readingthen.How it was found: a city run with
DARNER_UNIFIED_STATS=1andDARNER_DSTORAGE_LOG, seconds sorted by frames over 50 ms. Of the landing's steps only "read-backs and lists" grew in the bad seconds, and per second it followed the milliseconds of the title's mapping calls (the streaming log'sMlines), correlation 0.85:DirectStorage was not the cause in that run (no request stuck over 250 ms, p99 from enqueue to done 9 ms calm and 14 ms in the bad seconds), nor merging, fetching or the volume landed (all flat between those rows).
How it was tested
Tested revision: this commit's change on a local build of
f3840d7with #310, #274 and #283 merged (PGO); both runs below are on that tree, the A without this change. The gates are on this branch (25acf1b, onmainf3840d7).Commands and results: the two runs below; the gates below.
Changes a default: no (only with
DARNER_RANGE_LOCK=1, off by default).A/B result: RTX 4090, the same save, the same drive into the city, 10 min each,
DARNER_UNIFIED_STATS=1, the sameDARNER_LAND_LEAVElist in both. A = the tree without this change andDARNER_RANGE_LOCKunset; B = with this change andDARNER_RANGE_LOCK=1. (B is therefore the switch and this change together; I have no run of the switch alone.)The title's mapping calls were as heavy in B (755 ms a second in its worst seconds against 748), so the streaming did not get lighter; the relay just no longer waits for it. B also spent six times as many frames at 9,000 draws and more.
Gates run on
25acf1b: the asset policy (555 files ok) and gates 1 and 2 (both clippy runs) pass. Gate 3: every crate passes except onedarner-shadertest,emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders(DXIL validation: "Not all elements of output SV_Depth were written"). It fails alone too,darner-shaderdoes not depend ondarner-gpu, and #227 fixes that test's fixture.darner-gpu's library tests: 1,773 passed, 81 ignored.Gameplay: RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, DLSS frame generation 2x, hardware RT. No new kinds of warnings in B's log (the same kinds as A's, no errors). No visual faults seen; to my eye fewer short black spots on textures in the city in B, not measured.
Hardware dependence: the wait is the CPU's; any PC whose title streams while the relay lands should see it. Other PCs untested.
Coverage gaps: one run each; both with the leave list of #310 and with #274; the switch's other effects (the texture refresh's reads also wait only for their own range) are in B as well, so B is not this change alone.
Checklist
main.docs/asset-policy.md.DARNER_RANGE_LOCK=1)Checked for overlap
texback.rsor the mapping locks. #321, #219, #150 and #50 changewatch.rselsewhere; trial merges with #321, #219 and #150 have no conflict (#50 conflicts withmainalready, intexture/ahead.rs). No open or closed PR or issue mentionsDARNER_RANGE_LOCK; #331, #182 and #162 showtexbacklines only as routine log lines.🤖 Generated with Claude Code
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.