shadow: 32-byte AVX2 fast-skip in merge_piece #440
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!440
Loading…
Reference in a new issue
No description provided.
Delete branch "Paliton/Darner-fork:pr/avx2-merge-piece"
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
shadow::merge_piece(crates/darner-gpu/src/shadow.rs) compared and updatednow,held, andtitlebyte-by-byte, writing every byte oftitleandheldeven across unchanged stretches during GPU-to-CPU shadow read-back merges.Ports the 32-byte AVX2 fast-skip path for
merge_piecefromProjectLeonida/mandy653f60d37(PR #2699,bobcatchris, GPL-3.0), runtime-dispatched viais_x86_feature_detected!("avx2")with a scalar fallback (merge_piece_scalar). Refined so that when a 32-byte chunk has differences, only the differing byte positions (trailing_zerosover the negated equality mask) are stored intotitle— avoiding writing neighbouring unchanged bytes that a title thread may be updating concurrently. Adds unit testmerge_piece_avx2_matches_scalar_across_lengths_and_patterns.How it was tested
Tested revision:
545354f(based onf3840d7)Commands and results:
cargo xtask policy->asset policy: 555 files okcargo clippy --workspace --all-targets --locked -- -D warnings-> ok (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings-> ok (0 warnings)cargo test -p darner-gpu --lib --locked merge_piece -- --test-threads=1->1 passed; 0 failed(merge_piece_avx2_matches_scalar_across_lengths_and_patterns)cargo test --workspace --locked-> all non-flaky tests pass (1773/1774indarner-gpu; the single failure is the pre-existingwatch::tests::ask_once_by_res_splits_reservations_without_refusalsflake fixed by #262)Changes a default: yes (automatic AVX2 dispatch on x86_64 CPUs that support AVX2; identical observable output, stricter non-overwriting writes to
title).A/B result:
Isolated CPU microbenchmark (
rustc -O, Intel Core i7-14700KF, 4 MiB buffer, 200 iterations, 2 runs):In-game A/B (2 runs each, 240 s automated opening sequence,
--profile diag --features diagnostics, pureplay-defaults, RTX 5070 12 GB + i7-14700KF, Series X, 1440p -> 4K, DLSS off, FG off, RT off). Note this rig is primarily GPU-bound at 1440p -> 4K (run-to-run GPU variance ~1 ms), so average FPS gain is partly within GPU noise, while p99 spikes dropped cleanly and read-backs were spotless:f3840d7)545354f)Gates run on that revision: all three
AGENTS.mdgates +cargo xtask policyon545354f.Gameplay, when relevant: RTX 5070 12 GB + i7-14700KF, Series X, 1440p -> 4K, DLSS off, FG off, RT off. Zero read-back corruption or regressions.
Hardware dependence: x86_64 CPUs with AVX2 (safe scalar fallback elsewhere).
Coverage gaps: in-game A/B was run on a GPU-bound system rather than a CPU-bound one; non-AVX2 fallback verified via direct
merge_piece_scalarequivalence in unit tests.Checklist
main.docs/asset-policy.md.Checked for overlap
crates/darner-gpu/src/shadow.rs, non-overlapping functions)Test report, together with #442 (both merged on A): no measurable change in this scene, and nothing wrong on screen.
PC: RTX 4080 16 GB (driver 621.40), i7-13700K (24 logical processors), 64 GB, Windows 11 26300. Series X profile, 1440p with DLSS Quality, frame generation off, hardware ray tracing on, Reflex off,
DARNER_ALIAS_SHARE=1,DARNER_D3D12_BACKGROUND=0.Method: the opening scene of one save, entered the same way every run (no input after the start screen); medians of per-second values from the host log in three 45-second windows from the moment the world appears; warm pipelines; one run each. A = main
47d21cd+ #334, #337, #457, #274, #397, #312, #304, #303, #438, #439.f24eeae) + #442 (c971d13)The merge got about 0.05 ms a frame (3%) faster, within the spread; the scene is static, so little is merged or re-hashed.
Not tested: more than one run each, scenes with streaming (driving), other CPUs.
Tested merged on
c8258f9on Intel Core Ultra 7 265KF (AVX2) across 3 full Series X sessions (30,000+ frames, up to537,076texture uploads /26,087 MBuploaded per run): zero corruption or crashes,landmerge cost measured0.00 msper frame in the steady state, andpolicy/clippy --all-features -D warnings/1,819 darner-gputests passed cleanly.I tested
f24eeaeon a Core Ultra 5 225F. The merge output matchedmain(d91d8e4) across 1,026 synthetic lengths, including unaligned starts. For reused 64 KiB buffers, the median went from 0.032 to 0.017 ns/byte at 0% dirty, to 0.187 at 10% dirty, and to 0.719 at 100% dirty. Five alternating samples per side, compiled withrustc -C opt-level=3.A small follow-up restored the fully dirty case to 0.033 ns/byte. When the held comparison mask is zero and all 32 title bytes also differ from the new values, it uses one vector store. Other masks keep your per-byte stores. The 97 dense merge checks and the repository's focused
merge_piecetest passed. The scattered 10% case is still slower in this test. I haven't measured how often dense merges occur during play, so this is complementary to the in-game results above.[pr-performance][memory] shadow: 32-byte AVX2 fast-skip in merge_pieceto shadow: 32-byte AVX2 fast-skip in merge_pieceTest needed — commit
f24eeae6; what to check:shadow::merge_piece(crates/darner-gpu/src/shadow.rs) compared and updatednow,held, andtitlebyte-by-byte, writing every byte oftitleandheldeven across unchanged stretches during GPU-to-CPU shadow read-back merges.Ports the 32-byte AVX2 fast-skip path for
merge_piecefromProjectLeonida/mandy653f60d37(PR #2699,bobcatchris, GPL-3.0), runtime-dispatched viais_x86_feature_detected!("avx2")with a scalar fallback (merge_piece_scalar). Refined so that when a 32-byte chunk has differences, only the differing byte positions (trailing_zerosover the negated equality mask) are stored intotitle— avoiding writing neighbouring unchanged bytes that a title thread may be updating concurrently. Adds unit testmerge_piece_avx2_matches_scalar_across_lengths_and_patterns.Evidence 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.