[pr-performance][memory] dstorage: address destinations in views kept in the books are written through their sections #337
Loading…
Reference in a new issue
No description provided.
Delete branch "MesoPlz/Darner:pr-dstorage-soft-destinations"
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
DARNER_SOFT_VIEWS=1(orpool), the title's pool views are kept in our books alone, but almost all of them are made views of the host's anyway. In a drive onmainplus #334: 538k views noted in the books, 198k made real, nearly all "asked for by the GPU side" (the log'stitle views kept in the books aloneline). A temporary counter of the callers ofwatch::materialize(not in this PR) put 99.8 % of them (42,002 of 42,086 in its run) ondstorage.rs'sinto_destination: a DirectStorage request with an address destination is written at that address through the kernel, sodarner_gpu::kernel_writingmakes each view it covers a mapping of the host's first, a map now and an unmap later, each waiting for the process's address-space lock with the title's streaming thread.A destination that views in our books alone cover wholly, one after another, is now written through the sections' own views of their pages, as a page destination already is (
page_window):xmem::soft_targetscollects those views (the title maps its pool a page a call, so a destination often spans several), and the bytes are written in place when the pages are one run of a section, else through a buffer that starts with the bytes there and gives back only the bytes the fill produced (a zlib stream may end short of the destination; the title packs small textures side by side).SoftTargets::writtenthen tells the GPU side at every address that shows those pages, aspages_writtendoes for page destinations. Any other destination is written at its address, as before. Nothing changes where no view is kept in the books (DARNER_SOFT_VIEWS=0). With the default,copies, only a destination inside the page-mapping copies' views would take the new path: in a 2-minute drive withcopiesand this change, none did (0 of 182,297 address destinations; 181,416 had no view in the books near them, 881 began outside one). The A/B runs below used1.How it was tested
Tested revision:
16a24e0onmainf3840d7. The game runs used the same change on top of #334 (d5aa933), and run B also carried the temporary counters named above.Commands and results:
cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked --no-fail-fast: 2,789 passed, 0 failed in the test binaries that finished, 105 ignored. Indarner-shader,emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shadersfailed (#92 reports it failing onmain1a5286atoo), and the binary then hung afteremit::valu_tests::cost_checks::the_median_of_a_value_and_two_constants_is_a_clampwith no game running; it was stopped, so not all of its tests ran. This change does not touchdarner-shader.cargo test --profile fast --locked -p darner-hle --lib -- xmem dstorage: 92 passed, 11 ignored (on the three unsquashed commits, the same diff)xmem::tests::writes_into_views_in_the_books_alone_go_to_their_pages(a write across two views of one section run, in place; across views of pages out of order, through the buffer; a fill that ends short leaves the rest as it was; nothing made a view of the host's; destinations past the views or with none written at the address).Changes a default: no.
A/B result: the same route twice, built with the
fastprofile, RTX 4080 16 GB, driver 621.40, 64 GB RAM, Series X profile, 1440p, DLSS quality, frame generation off, hardware RT,DARNER_SOFT_VIEWS=1and the streaming log in both. Non-default rows in both:DARNER_CARD_WINDOWS_MB=1536,DARNER_WINDOWS_BAR_MB=0,DARNER_ASK_FAST=1,DARNER_HW_RT_BLAS_HEAPS=0,DARNER_KEEP_SHOWN=checked. One run each, hand-driven:Frame rate did not improve in these runs (B drove further into the city); what changed is how fast streamed data arrives. The player saw clearly less pop-in in B ("much better"); no screenshot comparison.
Gates run on that revision: all three, results above.
Gameplay: see the A/B row.
Shader wave sizes tested: not relevant (no shader change).
Hardware dependence: likely general (it saves Windows calls, not GPU work); measured on one PC only.
Coverage gaps: one card, one player, one run each, about 3 minutes; not tested on AMD, Series S, Linux/Proton, or with frame generation. An earlier version wrote the whole destination back from a zeroed buffer and broke a face texture (dotted pattern, a zlib stream shorter than its destination); fixed and covered by the test before this commit. A refresh of a texture that copies it while the bytes are being written may read it half-written, until the next refresh, as for page destinations; not seen in the runs.
Checklist
main.docs/asset-policy.md.Checked for overlap
LAZYmap this reads (would conflict textually); #334 (same drives; independent change).🤖 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.