perf(gpu): prototype event-driven resident shadow dirty queue #608

Open
github-bot wants to merge 5 commits from github-bot/gh-608 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-05 17:24 UTC · original
tommiehansen:perf/phase12-event-dirty-shadows-20261205 → main · +439 −20 · 2 files · 5 commits · open

Scope

Opt-in VICTORY_EVENT_DIRTY_SHADOWS=1 (default off). Use the existing dirty-range publication lock to enqueue weak shadow owners once per dirty generation; drain only pending shadows, preserving the existing upload, staging and fence lifetime path. No new residency policy; no migration or readback elimination claimed.

Validation

Head d916b93d5d4fc9875c2fe6f1f41547d525b73d17, CI 47546793728: concurrent generation oracle, paired CPU benchmark and all-target compile passed. Eight paired blocks per workload.

Total/dirty buffers Median paired change
64/1 -60.0% (8/8)
1024/1 -96.9% (8/8)
8192/1 -99.7% (8/8)
64/16 +23.2%
1024/256 +7.3%
8192/2048 +6.2%
64/64 +36.3%
1024/1024 +34.3%
8192/8192 +32.6%

These are CPU model timings using the same queue helpers, not full production upload or frame times. Baseline model uses Arc traversal, candidate model omits final ordering sort. Dense regressions are real in the model. Draft blocker: adaptive sparse/dense admission and representative actual upload scheduling, with independent bytes/waits/output verification; no default enablement. Follow-on work: streamed immutable generation/alias/fence integration and elimination of redundant refresh/migration.

Adaptive sparse/dense admission and actual upload audit — 2026-12-05

Head fe17d1f caps pending weak entries at max(4, registry size / 8), switches to a full scan for dense epochs, and resets admission before draining so writes racing the scan remain visible. Non-opt-in path remains the original scan. The benchmark now uses actual two-sided shadows, weak registry traversal, ordered dirty drains, upload preludes and synchronous fence completion, exact GPU buffer readback, 64/256/1024 buffers with sparse/quarter/dense changes, and four successive submissions per sample. CI 47549087814 is in progress; the earlier model results are not evidence of this revision's net upload benefit.

Attribution and scope

Independently implemented XMEM dirty-queue/admission logic, inspired by CNF/Larp's explicit resource-generation and write lifecycle design by gamingwithhomie (source revision 85b5b41, finals.rs, streamed.rs, bufobj.rs). No CNF source or assets copied. This change retains XMEM's existing Shadow and upload infrastructure; it does not yet infer final placement, skip write-watch, or eliminate migrations. Those require lifecycle proof, write/alias invalidation and independent differential verification; coordinate with #368 and #596 rather than replacing their changes.

Completed production-path synthetic WARP benchmark (fe17d1f)

CI 47549087814 passed the generation tests, 288 exact upload samples, and diagnostic all-target check. Each sample contains four fenced submissions; table shows median of per-block A/B means in ms and median paired change (negative is faster).

Buffers/active Baseline ms Adaptive ms Paired change Wins/8
64/1 0.4167 0.39935 -2.94% 6
64/16 0.63935 0.6424 +0.72% 3
64/64 0.8625 0.880975 +2.85% 3
256/1 0.408225 0.405925 +1.46% 3
256/64 0.9307 0.923125 -0.80% 4
256/256 1.88805 1.92035 +1.16% 4
1024/1 0.5002 0.430375 -15.53% 8
1024/256 2.200775 2.1681 -0.99% 5
1024/1024 6.847175 6.8302 +0.37% 4

Large sparse workload wins; dense effects are now small on this different, end-to-end software workload, not a directly matched comparison against the earlier non-adaptive model. No real-game FPS inference. Follow-up cfc4b93 preserves registry insertion order rather than allocation ID (concurrent construction may reorder registration), CI 47549854007 running. Keep draft until latest revision and representative benefit/ordering gates verified.

Ordering follow-up — current head cfc4b93

CI 47549854007 passed the concurrent-generation oracle, adaptive dense-transition oracle, 288 exact production upload samples (8 ABBA/BAAB blocks per workload), and diagnostic all-target check.

Buffers/active Baseline ms Adaptive ms Paired median change Wins/8
64/1 0.8523 0.8232 −2.94% 6
64/16 1.2522 1.2420 −0.74% 4
64/64 1.7009 1.6862 +0.79% 3
256/1 0.8648 0.8383 −3.50% 6
256/64 1.6619 1.6447 −0.95% 5
256/256 3.0824 3.0990 +2.20% 2
1024/1 0.9086 0.8413 −7.57% 7
1024/256 3.1895 3.1570 −0.47% 4
1024/1024 9.2404 9.4511 +2.02% 2

The large sparse benefit repeats, with about 0.067 ms saved across four fenced submissions in this fixture. Small dense net regressions remain (up to 2.2% paired); the older CPU-only non-adaptive model still exhibits substantial dense overhead and is not equivalent to this adaptive production upload test. Ready for review as an opt-in experimental path, not a recommendation to enable by default. Larger production registries, native AMD timing, immutable ownership/migration elimination and actual gameplay impact remain unverified. No FPS claim.

**@⁠tommiehansen** on GitHub · 2026-12-05 17:24 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/608) `tommiehansen:perf/phase12-event-dirty-shadows-20261205` → `main` · +439 −20 · 2 files · 5 commits · open ## Scope Opt-in `VICTORY_EVENT_DIRTY_SHADOWS=1` (default off). Use the existing dirty-range publication lock to enqueue weak shadow owners once per dirty generation; drain only pending shadows, preserving the existing upload, staging and fence lifetime path. No new residency policy; no migration or readback elimination claimed. ## Validation Head `d916b93d5d4fc9875c2fe6f1f41547d525b73d17`, [CI 47546793728](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47546793728): concurrent generation oracle, paired CPU benchmark and all-target compile passed. Eight paired blocks per workload. | Total/dirty buffers | Median paired change | |---|---:| | 64/1 | -60.0% (8/8) | | 1024/1 | -96.9% (8/8) | | 8192/1 | -99.7% (8/8) | | 64/16 | +23.2% | | 1024/256 | +7.3% | | 8192/2048 | +6.2% | | 64/64 | +36.3% | | 1024/1024 | +34.3% | | 8192/8192 | +32.6% | These are CPU model timings using the same queue helpers, not full production upload or frame times. Baseline model uses Arc traversal, candidate model omits final ordering sort. Dense regressions are real in the model. Draft blocker: adaptive sparse/dense admission and representative actual upload scheduling, with independent bytes/waits/output verification; no default enablement. Follow-on work: streamed immutable generation/alias/fence integration and elimination of redundant refresh/migration. ### Adaptive sparse/dense admission and actual upload audit — 2026-12-05 Head [fe17d1f](https://github.com/tommiehansen/VIctory-xmem/commit/fe17d1f361d4a45e93b27ef8f0552897917d5ed4) caps pending weak entries at max(4, registry size / 8), switches to a full scan for dense epochs, and resets admission before draining so writes racing the scan remain visible. Non-opt-in path remains the original scan. The benchmark now uses actual two-sided shadows, weak registry traversal, ordered dirty drains, upload preludes and synchronous fence completion, exact GPU buffer readback, 64/256/1024 buffers with sparse/quarter/dense changes, and four successive submissions per sample. [CI 47549087814](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47549087814) is in progress; the earlier model results are not evidence of this revision's net upload benefit. ### Attribution and scope Independently implemented XMEM dirty-queue/admission logic, inspired by CNF/Larp's explicit resource-generation and write lifecycle design by gamingwithhomie ([source revision 85b5b41](https://github.com/gamingwithhomie/larp/commit/85b5b41a99d7685823ce43854b5f524f3109f536), [finals.rs](https://github.com/gamingwithhomie/larp/blob/85b5b41a99d7685823ce43854b5f524f3109f536/crates/larp-gpu/src/finals.rs), [streamed.rs](https://github.com/gamingwithhomie/larp/blob/85b5b41a99d7685823ce43854b5f524f3109f536/crates/larp-gpu/src/streamed.rs), [bufobj.rs](https://github.com/gamingwithhomie/larp/blob/85b5b41a99d7685823ce43854b5f524f3109f536/crates/larp-gpu/src/bufobj.rs)). No CNF source or assets copied. This change retains XMEM's existing Shadow and upload infrastructure; it does not yet infer final placement, skip write-watch, or eliminate migrations. Those require lifecycle proof, write/alias invalidation and independent differential verification; coordinate with #368 and #596 rather than replacing their changes. ### Completed production-path synthetic WARP benchmark (fe17d1f) [CI 47549087814](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47549087814) passed the generation tests, 288 exact upload samples, and diagnostic all-target check. Each sample contains four fenced submissions; table shows median of per-block A/B means in ms and median paired change (negative is faster). | Buffers/active | Baseline ms | Adaptive ms | Paired change | Wins/8 | |---:|---:|---:|---:|---:| | 64/1 | 0.4167 | 0.39935 | -2.94% | 6 | | 64/16 | 0.63935 | 0.6424 | +0.72% | 3 | | 64/64 | 0.8625 | 0.880975 | +2.85% | 3 | | 256/1 | 0.408225 | 0.405925 | +1.46% | 3 | | 256/64 | 0.9307 | 0.923125 | -0.80% | 4 | | 256/256 | 1.88805 | 1.92035 | +1.16% | 4 | | 1024/1 | 0.5002 | 0.430375 | -15.53% | 8 | | 1024/256 | 2.200775 | 2.1681 | -0.99% | 5 | | 1024/1024 | 6.847175 | 6.8302 | +0.37% | 4 | Large sparse workload wins; dense effects are now small on this different, end-to-end software workload, not a directly matched comparison against the earlier non-adaptive model. No real-game FPS inference. Follow-up [cfc4b93](https://github.com/tommiehansen/VIctory-xmem/commit/cfc4b932a6cf0beddbc656479905327bb3b800aa) preserves registry insertion order rather than allocation ID (concurrent construction may reorder registration), [CI 47549854007](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47549854007) running. Keep draft until latest revision and representative benefit/ordering gates verified. ### Ordering follow-up — current head cfc4b93 [CI 47549854007](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47549854007) passed the concurrent-generation oracle, adaptive dense-transition oracle, 288 exact production upload samples (8 ABBA/BAAB blocks per workload), and diagnostic all-target check. | Buffers/active | Baseline ms | Adaptive ms | Paired median change | Wins/8 | |---:|---:|---:|---:|---:| | 64/1 | 0.8523 | 0.8232 | −2.94% | 6 | | 64/16 | 1.2522 | 1.2420 | −0.74% | 4 | | 64/64 | 1.7009 | 1.6862 | +0.79% | 3 | | 256/1 | 0.8648 | 0.8383 | −3.50% | 6 | | 256/64 | 1.6619 | 1.6447 | −0.95% | 5 | | 256/256 | 3.0824 | 3.0990 | +2.20% | 2 | | 1024/1 | 0.9086 | 0.8413 | −7.57% | 7 | | 1024/256 | 3.1895 | 3.1570 | −0.47% | 4 | | 1024/1024 | 9.2404 | 9.4511 | +2.02% | 2 | The large sparse benefit repeats, with about 0.067 ms saved across four fenced submissions in this fixture. Small dense net regressions remain (up to 2.2% paired); the older CPU-only non-adaptive model still exhibits substantial dense overhead and is not equivalent to this adaptive production upload test. Ready for review as an opt-in experimental path, not a recommendation to enable by default. Larger production registries, native AMD timing, immutable ownership/migration elimination and actual gameplay impact remain unverified. No FPS claim.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 17:29:51 +00:00
Author
Owner

@⁠fsrajner on GitHub · 2026-12-05 20:06 UTC · original

A/B data point on RDNA 4. This PR was tested together with #612, #599, #553 and #608 in one build. All are opt-in, so the arms differ only by env.

Setup: RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, repo-patched Mesa 26.3.1 RADV + vkd3d-proton, proton-cachyos-slr. Series X profile, 4K output with FSR 4.1.2 Quality, hardware RT (HW_RT + LEAN_BUILDER + REUSE), frame generation off, headless gamescope. Base: main @ 49f5f9e + rt-7-reuse + #542 (+ #611/#596, switched off). The four PRs merged with no conflicts.

Method: the same intro snapshot every run, 120 s after the first A press. One warm-up run, then two rounds of all five arms, interleaved. "Long frames" are the long frame lines (≥ 50 ms). This scene is GPU-bound: the submit thread waits ~16 ms a frame on the card.

arm ms/frame 5 s windows > 40 ms worst window gpu_wait long frames
base 40 / 42 22/36 50.1 / 59.7 ms 16.0 / 16.2 ms 262 / 249
#612 SUBRENDER_WORKERS=8 40 / 40 22/36 55.2 / 55.9 ms 20.9 / 21.6 ms 233 / 220
#599 THIN_SPLIT=1 40 / 41 25/36 46.5 / 49.3 ms 17.5 / 15.9 ms 246 / 246
#553 JOIN_BARRIERS=1 40 / 40 21/36 51.5 / 52.5 ms 16.3 / 15.6 ms 242 / 239
#608 EVENT_DIRTY_SHADOWS=1 42 / 41 28/36 56.1 / 48.9 ms 17.1 / 16.7 ms 268 / 270
  • For this PR: no gain here; slightly more slow windows and long frames (+5 %), likely noise. No errors.
**@⁠fsrajner** on GitHub · 2026-12-05 20:06 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/608#issuecomment-7444535802) A/B data point on RDNA 4. This PR was tested together with #612, #599, #553 and #608 in one build. All are opt-in, so the arms differ only by env. **Setup:** RX 9070 XT 16 GB, Ryzen 7 7800X3D, CachyOS, repo-patched Mesa 26.3.1 RADV + vkd3d-proton, proton-cachyos-slr. Series X profile, 4K output with FSR 4.1.2 Quality, hardware RT (`HW_RT` + `LEAN_BUILDER` + `REUSE`), frame generation off, headless gamescope. Base: `main` @ `49f5f9e` + `rt-7-reuse` + #542 (+ #611/#596, switched off). The four PRs merged with no conflicts. **Method:** the same intro snapshot every run, 120 s after the first A press. One warm-up run, then two rounds of all five arms, interleaved. "Long frames" are the `long frame` lines (≥ 50 ms). This scene is GPU-bound: the submit thread waits ~16 ms a frame on the card. | arm | ms/frame | 5 s windows > 40 ms | worst window | gpu_wait | long frames | |---|---|---|---|---|---| | base | 40 / 42 | 22/36 | 50.1 / 59.7 ms | 16.0 / 16.2 ms | 262 / 249 | | #612 `SUBRENDER_WORKERS=8` | 40 / 40 | 22/36 | 55.2 / 55.9 ms | 20.9 / 21.6 ms | 233 / 220 | | #599 `THIN_SPLIT=1` | 40 / 41 | 25/36 | 46.5 / 49.3 ms | 17.5 / 15.9 ms | 246 / 246 | | #553 `JOIN_BARRIERS=1` | 40 / 40 | 21/36 | 51.5 / 52.5 ms | 16.3 / 15.6 ms | 242 / 239 | | #608 `EVENT_DIRTY_SHADOWS=1` | 42 / 41 | 28/36 | 56.1 / 48.9 ms | 17.1 / 16.7 ms | 268 / 270 | - For this PR: no gain here; slightly more slow windows and long frames (+5 %), likely noise. No errors.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/608/head:github-bot/gh-608'
git switch 'github-bot/gh-608'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-608'
git switch 'github-bot/gh-608'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-608'
git switch 'github-bot/gh-608'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-608'
git switch 'main'
git merge --squash 'github-bot/gh-608'
git switch 'main'
git merge --ff-only 'github-bot/gh-608'
git switch 'main'
git merge 'github-bot/gh-608'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.