d3d12: parallelize in-place placement checks without XMem lock contention #474

Merged
DrArroway merged 1 commit from upstream-pr/474 into main 2026-11-29 14:38:05 +00:00
DrArroway commented 2026-11-29 13:20:53 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by DrArroway on 2026-11-29T13:20:53Z.


Summary

Parallelizes in-place Texture placement checks (digest_runs, copy_runs, Digest::of) across a persistent worker pool without any cross-thread xmem::POOL lock contention:

  • Three-phase CheckPool (2..=6 persistent workers, STEAL_CHUNK = 4, chunk size 128, active when check_queue.len() >= 32 outside #[cfg(test)]):
    1. Phase 1 (calling thread): runs profile classification, Watch::rearm, backing::guest_runs_mapped (Step::Resolve), and fallback reads for non-XMem, refused, or previously faulted textures sequentially on the calling thread (Texture::prepare_parallel).
    2. Phase 2 (CheckPool workers): digests and copies changed in-place mips purely over the pre-resolved GuestRuns holds in parallel (PreparedInPlace::check_in_place), with zero XMem lock calls.
    3. Phase 3 (calling thread): completes any guest page fault encountered in Phase 2 via sequential XMem reads (PreparedInPlace::finish_fallback), then drops PreparedInPlace sequentially on the calling thread so TuxBoxReleasePhysicalBacking never contends across threads.
  • Parallel submit-profile merge: adds Tally::merge_parallel in submit_profile.rs (taking wall-time max per step across workers and summing units/bytes/counts).
  • Helps both TUXBOX_XMEM_PRIVATE_VIEWS=1 and #464 default section-backed main (see #472), where every batch digests all section-backed textures.

Tested

  • Unit & hygiene checks (GE-Proton11-14 Wine):
    • tests.test_repository_hygiene: 7/7 pass.
    • tuxbox-d3d12 device::placement: 93/93 pass, including check_chunk_collects_all_changes_and_merges_profile and check_chunk_runs_xmem_access_only_on_caller_thread (asserting 64/64 access and release calls run strictly on the caller thread with 0 worker-thread XMem calls).
  • AMD RX 6900 XT (1002:73bf, RADV, Mesa 26.3.1, GE-Proton11-14) — tuxbox.py check:
    • All 11 steps pass: 123/123 Lanes & fixtures, 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI suites.
  • AMD Raphael Radeon 610M (1002:164e, RADV, Mesa 26.3.1, GE-Proton11-14) — tuxbox.py check:
    • All 11 steps pass: 122/122 Lanes & fixtures, 22/22 D3D12 regression controls, shader translator on GPU, all CPU/CI suites.
  • Live ProjectScarlett (3840x2160, offline, RX 6900 XT, RADV, Mesa 26.3.1, GE-Proton11-14):
    • TUXBOX_XMEM_PRIVATE_VIEWS=1 (with #462): placement digest dropped from 7.7% to 3.4%–4.4% of wall time (~2x faster) while placement resolve (3.9%) and placement read (1.4%) stayed free of XMem lock contention, helping lift steady 3D world frame pace from 3.84 s/f to 3.39 s/f (best window 2.75 s/f) when combined with the write-watch/slab optimizations.
    • Default #464 section-backed main (6e2c5dab combined with the write-watch/slab PR): ran 17+ minutes (74 3D world windows) with zero crashes or GPU faults, digesting 113.2M mips (~34 GiB per 5 s window) in 14.8% of wall time.
  • AMD and NVIDIA: AMD tested (1002:73bf and 1002:164e); NVIDIA still needs to run checks.

Checks

No evidence JSON changed.

<!-- greyfinch-sync:brcly/TuxBox:issue:5551112937 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/474). Originally posted by [DrArroway](https://github.com/DrArroway) on 2026-11-29T13:20:53Z. --- ## Summary Parallelizes in-place `Texture` placement checks (`digest_runs`, `copy_runs`, `Digest::of`) across a persistent worker pool without any cross-thread `xmem::POOL` lock contention: - **Three-phase `CheckPool` (`2..=6` persistent workers, `STEAL_CHUNK = 4`, chunk size `128`, active when `check_queue.len() >= 32` outside `#[cfg(test)]`):** 1. **Phase 1 (calling thread):** runs profile classification, `Watch::rearm`, `backing::guest_runs_mapped` (`Step::Resolve`), and fallback reads for non-XMem, refused, or previously faulted textures sequentially on the calling thread (`Texture::prepare_parallel`). 2. **Phase 2 (`CheckPool` workers):** digests and copies changed in-place mips purely over the pre-resolved `GuestRuns` holds in parallel (`PreparedInPlace::check_in_place`), with zero XMem lock calls. 3. **Phase 3 (calling thread):** completes any guest page fault encountered in Phase 2 via sequential XMem reads (`PreparedInPlace::finish_fallback`), then drops `PreparedInPlace` sequentially on the calling thread so `TuxBoxReleasePhysicalBacking` never contends across threads. - **Parallel submit-profile merge:** adds `Tally::merge_parallel` in `submit_profile.rs` (taking wall-time `max` per step across workers and summing units/bytes/counts). - Helps both `TUXBOX_XMEM_PRIVATE_VIEWS=1` and `#464` default section-backed `main` (see #472), where every batch digests all section-backed textures. ## Tested - **Unit & hygiene checks (`GE-Proton11-14` Wine):** - `tests.test_repository_hygiene`: `7/7` pass. - `tuxbox-d3d12 device::placement`: `93/93` pass, including `check_chunk_collects_all_changes_and_merges_profile` and `check_chunk_runs_xmem_access_only_on_caller_thread` (asserting 64/64 `access` and `release` calls run strictly on the caller thread with `0` worker-thread XMem calls). - **AMD RX 6900 XT (`1002:73bf`, RADV, Mesa 26.3.1, GE-Proton11-14) — `tuxbox.py check`:** - All 11 steps pass: `123/123` Lanes & fixtures, `22/22` D3D12 regression controls, shader translator on GPU, all CPU/CI suites. - **AMD Raphael Radeon 610M (`1002:164e`, RADV, Mesa 26.3.1, GE-Proton11-14) — `tuxbox.py check`:** - All 11 steps pass: `122/122` Lanes & fixtures, `22/22` D3D12 regression controls, shader translator on GPU, all CPU/CI suites. - **Live ProjectScarlett (3840x2160, offline, RX 6900 XT, RADV, Mesa 26.3.1, GE-Proton11-14):** - `TUXBOX_XMEM_PRIVATE_VIEWS=1` (with `#462`): `placement digest` dropped from `7.7%` to `3.4%–4.4%` of wall time (~2x faster) while `placement resolve` (`3.9%`) and `placement read` (`1.4%`) stayed free of XMem lock contention, helping lift steady 3D world frame pace from `3.84 s/f` to `3.39 s/f` (best window `2.75 s/f`) when combined with the write-watch/slab optimizations. - Default `#464` section-backed `main` (`6e2c5dab` combined with the write-watch/slab PR): ran 17+ minutes (`74` 3D world windows) with zero crashes or GPU faults, digesting `113.2M` mips (`~34 GiB` per 5 s window) in `14.8%` of wall time. - **AMD and NVIDIA:** AMD tested (`1002:73bf` and `1002:164e`); NVIDIA still needs to run checks. ## Checks No evidence JSON changed.
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
brcly/TuxBox!474
No description provided.