Memory: new sparse tiles are mapped together before the next submit #1507

Closed
oishigeso wants to merge 1 commit from upstream-pr/1517 into main
oishigeso commented 2026-11-24 17:10:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oishigeso on 2026-11-24T17:10:12Z.


Follows 7f94c6f (#532), which parks decommitted tiles; this does the same for new ones. A title starting on a Series S profile maps 4.3 GB of physical pages in small pieces (MapTitlePhysicalPages → sparse::committed), and each new tile cost one UpdateTileMappings plus a signal (~0.4 ms on this PC). Its loading thread was held ~25 s with nothing presented, and its stall watchdog ended it. Related: #1268 (the first UpdateTileMappings calls holding the render thread).

New tiles now get their pool tile in mapped at once, and their mapping call is queued (pending). flush_pending sends them, one call per window, before the title's next submit, before XCL's own copies and readbacks on the windows, or past 4,096 tiles. A tile decommitted before the flush is skipped. One decommitted and parked before its mapping was sent stays pending, because taking it back from parked sends no mapping.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: pending, flush_pending, called from before_execute, the upload and readback paths, and commit_range past PENDING_MAX; the existing parking test extended to commit, decommit, flush and commit again

Tested

  • AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release
  • cargo test -p xcl --lib sparse -- --test-threads=1: 16 passed, 0 failed, 1 ignored
  • Written and run before #532 merged in about 10 runs of a retail title on the Series S profile; the ~25 s hold at start was gone. Rebased onto 7f94c6f since; the combination was reviewed against the parking, which found the parked-before-flush case above (now in the test).
  • The regression runs below are on the Series S profile: 1,319 frames in 60 s against 373 on main, presenting every 2 s window at the end.

Regression run

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 373 (PresentX 374)
presents per 2 s (last 3): 0 28 60
device removals: 0
crashes: 0
peak commit: 19259 MB

PR (this PR's head commit; the title is run through a folder named RetailTitle):

xcl-smoke v1
commit: b52f7cb67236473c8a4d9a07eabaf01694d72de0
gpu: AMD Radeon RX 6700 XT
title: RetailTitle
seconds: 60
exit: 0x0
frames shown: 1319 (PresentX 1320)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19347 MB

Not tested

  • NVIDIA, Intel; Linux / Wine

AI use

  • Claude Code (Claude Opus 5.5) wrote the change, its test and this description, and ran the tests and runs above on my PC at my direction.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5476830300 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1517). Originally posted by [oishigeso](https://github.com/oishigeso) on 2026-11-24T17:10:12Z. --- Follows 7f94c6f (#532), which parks decommitted tiles; this does the same for new ones. A title starting on a Series S profile maps 4.3 GB of physical pages in small pieces (`MapTitlePhysicalPages` → `sparse::committed`), and each new tile cost one `UpdateTileMappings` plus a signal (~0.4 ms on this PC). Its loading thread was held ~25 s with nothing presented, and its stall watchdog ended it. Related: #1268 (the first `UpdateTileMappings` calls holding the render thread). New tiles now get their pool tile in `mapped` at once, and their mapping call is queued (`pending`). `flush_pending` sends them, one call per window, before the title's next submit, before XCL's own copies and readbacks on the windows, or past 4,096 tiles. A tile decommitted before the flush is skipped. One decommitted and parked before its mapping was sent stays pending, because taking it back from `parked` sends no mapping. **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: `pending`, `flush_pending`, called from `before_execute`, the upload and readback paths, and `commit_range` past `PENDING_MAX`; the existing parking test extended to commit, decommit, flush and commit again **Tested** - AMD Radeon RX 6700 XT (driver 32.0.21030.2001), Ryzen 5 3600, Windows 10 Pro 19045, rustc 1.100.0, release - `cargo test -p xcl --lib sparse -- --test-threads=1`: 16 passed, 0 failed, 1 ignored - Written and run before #532 merged in about 10 runs of a retail title on the Series S profile; the ~25 s hold at start was gone. Rebased onto 7f94c6f since; the combination was reviewed against the parking, which found the parked-before-flush case above (now in the test). - The regression runs below are on the Series S profile: 1,319 frames in 60 s against 373 on `main`, presenting every 2 s window at the end. **Regression run** main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 373 (PresentX 374) presents per 2 s (last 3): 0 28 60 device removals: 0 crashes: 0 peak commit: 19259 MB ``` PR (this PR's head commit; the title is run through a folder named RetailTitle): ``` xcl-smoke v1 commit: b52f7cb67236473c8a4d9a07eabaf01694d72de0 gpu: AMD Radeon RX 6700 XT title: RetailTitle seconds: 60 exit: 0x0 frames shown: 1319 (PresentX 1320) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19347 MB ``` **Not tested** - NVIDIA, Intel; Linux / Wine **AI use** - Claude Code (Claude Opus 5.5) wrote the change, its test and this description, and ran the tests and runs above on my PC at my direction. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 19:07:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:56Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7141306626 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1517#issuecomment-7141306626). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T18:53:56Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
fladit123 commented 2026-11-25 22:43:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fladit123 on 2026-11-25T22:43:49Z.

Review: CHANGES_REQUESTED


Independent validation on RTX 4060 confirms the substantial potential of batching, but I found a threshold-related performance regression that should be addressed before merging.

Results

Tested against base 930e8b4 and PR HEAD b52f7cb67236473c8a4d9a07eabaf01694d72de0.

Synthetic workload Baseline PR
4,096 individual commits: UpdateTileMappings calls 4,096 4
Median elapsed time through mapping fence 750.89 ms 1.24 ms
Parked-address stress case 3.47 ms 4.26 ms

Finding

commit_range triggers flush_pending() when pending.len() >= PENDING_MAX.

However, flush_pending() retains parked addresses whose mappings have not yet been submitted. These entries continue contributing to the threshold even though they are not ready to be mapped.

With 4,095 such parked addresses, the next 32 commits triggered 32 early flushes, examining 135,167 entries including the final flush.

This effectively defeats batching in that workload and increased median elapsed time by approximately 22.8%.

I recommend tracking only unique, currently eligible mappings toward the flush threshold while preserving the necessary pending state for parked addresses that are subsequently recommitted.

A regression test covering this parked-address workload would be valuable.

Rebase considerations

Current main also has fence-based tile quarantine and per-title-queue synchronization. Please preserve these guarantees when resolving the conflicts in sparse.rs.

Correctness validation

  • 14 targeted tests passed on each revision, with one ignored per revision.
  • Additional integrity fixture verified nine sentinels, remapping to a different slot, and reading from a second queue.
  • No D3D12 validation errors or warnings, and no device removal in the additional fixture.
  • Final measurements used separate build targets and verified executable hashes.

The measurements cover synthetic mapping through fence completion, not game FPS or frame times. Integration with current main has not been validated.

The batching approach looks promising. My

<!-- greyfinch-sync:ivall/xcl:review:6066003228 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1517#pullrequestreview-6066003228). Originally posted by [fladit123](https://github.com/fladit123) on 2026-11-25T22:43:49Z. **Review:** CHANGES_REQUESTED --- Independent validation on RTX 4060 confirms the substantial potential of batching, but I found a threshold-related performance regression that should be addressed before merging. ### Results Tested against base `930e8b4` and PR HEAD `b52f7cb67236473c8a4d9a07eabaf01694d72de0`. | Synthetic workload | Baseline | PR | |---|---:|---:| | 4,096 individual commits: UpdateTileMappings calls | 4,096 | 4 | | Median elapsed time through mapping fence | 750.89 ms | 1.24 ms | | Parked-address stress case | 3.47 ms | 4.26 ms | ### Finding `commit_range` triggers `flush_pending()` when `pending.len() >= PENDING_MAX`. However, `flush_pending()` retains parked addresses whose mappings have not yet been submitted. These entries continue contributing to the threshold even though they are not ready to be mapped. With 4,095 such parked addresses, the next 32 commits triggered 32 early flushes, examining 135,167 entries including the final flush. This effectively defeats batching in that workload and increased median elapsed time by approximately 22.8%. I recommend tracking only unique, currently eligible mappings toward the flush threshold while preserving the necessary pending state for parked addresses that are subsequently recommitted. A regression test covering this parked-address workload would be valuable. ### Rebase considerations Current main also has fence-based tile quarantine and per-title-queue synchronization. Please preserve these guarantees when resolving the conflicts in `sparse.rs`. ### Correctness validation - 14 targeted tests passed on each revision, with one ignored per revision. - Additional integrity fixture verified nine sentinels, remapping to a different slot, and reading from a second queue. - No D3D12 validation errors or warnings, and no device removal in the additional fixture. - Final measurements used separate build targets and verified executable hashes. The measurements cover synthetic mapping through fence completion, not game FPS or frame times. Integration with current main has not been validated. The batching approach looks promising. My
Foniass commented 2026-12-01 05:58:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:58:54Z.


Triage (#1607) – head b52f7cb

This PR's commit is on main: 6831cafe (Memory: new sparse tiles are mapped together before the next submit) is a cherry-pick of b52f7cb, and main's sparse.rs has State::pending, flush_pending and PENDING_MAX with the same call sites (before_execute, submit_slot, readback_ranges).
Recommendation: close (superseded by main commit 6831cafe).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302345020 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1517#issuecomment-7302345020). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:58:54Z. --- **Triage (#1607)** – head b52f7cb This PR's commit is on main: 6831cafe (Memory: new sparse tiles are mapped together before the next submit) is a cherry-pick of b52f7cb, and main's sparse.rs has State::pending, flush_pending and PENDING_MAX with the same call sites (before_execute, submit_slot, readback_ranges). Recommendation: close (superseded by main commit 6831cafe). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:46:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:46:38Z.


Closing as superseded: this change is already on main (6831cafe). main 6831cafe is the same change as head b52f7cb (75 changed lines, only comment wording and the pending field's initial position differ; main also has the self.kept.contains_key check)

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311630904 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1517#issuecomment-7311630904). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:46:38Z. --- Closing as superseded: this change is already on `main` (6831cafe). main 6831cafe is the same change as head b52f7cb (75 changed lines, only comment wording and the pending field's initial position differ; main also has the self.kept.contains_key check) Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1507
No description provided.