xmem: the world's streaming without its stutter under soft copies: scatter calls in groups, their notes in runs, single-page unmaps behind (three trials, off) #605
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!605
Loading…
Reference in a new issue
No description provided.
Delete branch "HQasper/Darner:pr/stream-groups"
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?
Contributor role (optional)
What it changes
XMemMapPhysicalPagesScattercalls, and the frames wait for it. WithDARNER_SOFT_VIEWS=copies(play's default),side_by_side()is 1, so each scatter call goes a page at a time throughXMemMapPhysicalPages. Each page takes both locks and tells the GPU side alone, and each unmap runsUnmapViewOfFile2in the call. One run counted 148,366 unmaps at 27 us each (3.96 s) and 215,003 maps at 6 us on that thread. #334 already takes the RT tables' walk out of the per-page path; this PR is about what is left.Three switches, all off by default, each its own commit:
DARNER_SCATTER_GROUPS=1: while the title's views are the host's own (DARNER_SOFT_VIEWScopies or off, noDARNER_LAZY_VIEWS), a scatter call of more than one page goes throughscatter(), as withDARNER_MAP_THREADSabove 1: 64 pages under the locks at once, their system calls side by side.DARNER_MAP_NOTES_JOINED=1:change()(the side-by-side path, with either switch) tells the GPU side once per run of neighbouring addresses that its pages were unmapped and mapped anew, and what they now show (a section's consecutive pages), instead of a page at a time.DARNER_UNMAP_BEHIND=1(withDARNER_SCATTER_GROUPS): the single-page views a scatter call unmaps (page number 0) leave our books, and the GPU side is told in the call, as before. The host'sUnmapViewOfFile2is done later by a thread of ours, 16 views a turn, under the change of mapping. It takes a turn once the title's mapping calls have rested 2 ms, or at once when more than 8,192 are left. Anything that maps, cuts or asks about such an address unmaps it there first (behind::settle), and so do the title's own queries and frees. Until then the old view stays readable on the host, where the console would fault. A title that reads memory it has unmapped would see the old bytes instead.How it was tested
Tested revision: d8f96fb (the same code as
1ff8907, which adds the measurement to the README rows and the commit message and corrects one doc comment).Commands and results: the gates below, and the game A/B below. Exe sha256 4F99AA2A05EF… (diag build).
Changes a default: no (all three are off by default).
A/B result: the prison cell bench, 60-210 s after the world's first frame. Both arms use this branch's exe with
DARNER_RANGE_LOCK=1,DARNER_ALIAS_SHARE=1,DARNER_VIEW_THREADS=8andDARNER_SUBMIT_CORE_ALONE=1. A has the three switches off (the code is main's then), B hasDARNER_SCATTER_GROUPS=1,DARNER_MAP_NOTES_JOINED=1andDARNER_UNMAP_BEHIND=1. Three runs each, interleaved (A B A B A B), after one warm-up run that took the shader preload.B is better in each pair at p99.9 and in the median. The streaming stretch's stutter is smaller with it, but not gone: one B run had a 56.9 ms hitch there. The 87.1 and 51.1 ms gaps at 155.9 and 155.8 s are another event, in both arms. The logs have the same kinds of warnings in both arms; the count of the most common one ("a texture picked by index changed after its upload") varies between runs in both (60-201).
On our own branch (
f3840d7plus local trials, the stream agent's bench st4, two runs each, interleaved), the four switches together had both runs with no hitch and the longest gap at 46.6 and 44.9 ms. The base runs had 3.6 and 1.2 hitches a minute and gaps of 128.4 and 96.3 ms, in the streaming stretch. The four are the three here plus the equivalent of #334. #334's equivalent alone left gaps of 51.5-55.7 ms. The median did not change (50.2-51.7 fps everywhere).Gates run on d8f96fb:
cargo clippy --workspace --all-targets --locked -- -D warnings: passed.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed.1ff8907(comment and README only):cargo clippy -p darner-hle --all-targets --locked -- -D warningspassed.cargo test --workspace --locked --no-fail-fast: all passed except one darner-gpu library test,host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end("expected 1 refusal per round with DARNER_SCRATCH_SHARED=0"). Run alone three times while the game ran a bench, it passed twice and failed once. It failed on mainc8258f9under load too. This change does not touch darner-gpu. darner-hle: 511 passed, 15 ignored.Gameplay: RTX 5090, Series X profile, 1440p, DLSS Quality, frame generation off, hardware ray tracing.
Shader wave sizes tested: not relevant.
Hardware dependence: the stutter depends on the CPU's speed at
UnmapViewOfFile2and on Windows; measured on a Ryzen 9 9950X3D only.Coverage gaps: one PC, one scene; not under Wine/Proton;
DARNER_SOFT_VIEWS=poolis not changed (groups are not used with it).Checklist
main. (One change in three steps, each behind its own switch so each can be measured. They can be split into three PRs if wanted; the third needs the first.)docs/asset-policy.md.Checked for overlap
xmem.rsand also merge without conflict. #561 (ReBAR pools) adds apoolcensus::droppedcall just before the GPU side's unmap note inchange(), the lineDARNER_MAP_NOTES_JOINEDputs in an if/else here: a one-line conflict, kept both ways by whichever lands second.Two Windows checks on
1ff8907for the opt-in paths.Deferred unmaps. Queue
A, B, C, settleBsynchronously, then reuse and queue its address whileAis still waiting.peekreturnsA, B, C, B; the current request belongs at the tail asA, C, B. In a second test I took a worker snapshot ofA, Bbefore settling and requeuingB. The old snapshot claimed the new request atBas well. Both regressions failed on the PR head with production code unchanged.The review branch gives each unmap a distinct ticket, keeps the ordered set to live queued requests, and publishes the pending count while holding the same queue lock. It preserves the order after 4,096 reuses of
B, and rejectsBfrom the worker's old snapshot. On that variant,cargo test --locked --offline -p darner-hle --lib modules::xmem::tests:: -- --test-threads=1gave 53 passed and 1 ignored.cargo clippy --locked --offline -p darner-hle --all-targets -- -D warningspassed. A streaming-time comparison is still pending.Grouped failure semantics. On the original head, I mapped three synthetic pages with byte markers
11,22,33(hex), then submitted a valid prefix, an unavailable page in the middle, and a valid suffix. Both runs returned failure. The sequential run read back22,22,33. WithDARNER_SCATTER_GROUPS=1, the middle view was unmapped and the suffix changed to11. Both runs usedDARNER_SOFT_VIEWS=copies,DARNER_MAP_THREADS=1, with deferred unmaps and joined notifications disabled. The grouped path treats the unavailable page as an empty mapping and proceeds past it. That path existed before this PR for parallel mappings, and this PR's option also exposes it to soft copies.Follow-up to the grouped failure reproduction in my previous comment. The address-mapping commit applies the accepted prefix and stops at the first unavailable nonzero page. The rejected view and suffix retain their mappings, and zero still requests an unmap.
On Windows, the same assertions passed with
DARNER_SOFT_VIEWS=copies DARNER_SCATTER_GROUPS=1 DARNER_MAP_THREADS=1and in the existing parallel path withDARNER_SOFT_VIEWS=0 DARNER_SCATTER_GROUPS=0 DARNER_MAP_THREADS=4. Cases cover a rejected middle item, a repeated destination, a rejected first item, and an explicit unmap before a rejection. The defaultxmemfilter passed 54 tests with one ignored, andcargo clippy --locked --offline -p darner-hle --all-targets -- -D warningspassed.[pr-performance][memory] xmem: the world's streaming without its stutter under soft copies: scatter calls in groups, their notes in runs, single-page unmaps behind (three trials, off)to xmem: the world's streaming without its stutter under soft copies: scatter calls in groups, their notes in runs, single-page unmaps behind (three trials, off)Test needed — commit
1ff89073; what to check:XMemMapPhysicalPagesScattercalls, and the frames wait for it. WithDARNER_SOFT_VIEWS=copies(play's default),side_by_side()is 1, so each scatter call goes a page at a time throughXMemMapPhysicalPages. Each page takes both locks and tells the GPU side alone, and each unmap runsUnmapViewOfFile2in the call. One run counted 148,366 unmaps at 27 us each (3.96 s) and 215,003 maps at 6 us on that thread. #334 already takes the RT tables' walk out of the per-page path; this PR is about what is left.Three switches, all off by default, each its own commit:
DARNER_SCATTER_GROUPS=1: while the title's views are the host's own (DARNER_SOFT_VIEWScopies or off, noDARNER_LAZY_VIEWS), a scatter call of more than one page goes throughscatter(), as withDARNER_MAP_THREADSabove 1: 64 pages under the locks at once, their system calls side by side.DARNER_MAP_NOTES_JOINED=1:change()(the side-by-side path, witEvidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.
Reply
testingto take this run; it's free again after 24 h with no results.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.