D3D12.X: arm intermediate pre-cell fence signals and initialise cell before publishing #1287

Open
b3IKK wants to merge 1 commit from upstream-pr/1297 into main
b3IKK commented 2026-11-24 14:29:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T14:29:19Z.


fence_x::note_queue_signal only recorded the maximum signalled value (f.signalled) before completed_value_address was first called. If a queue signalled V1 and then V2 (V2 > V1) before completed_value_address, only V2 was armed: when the GPU completed V1 and paused before V2, the completion event never fired and *cell stayed stale at 0 even though GetCompletedValue() == V1 (deadlocking any caller waiting on *cell >= V1).

In addition, completed_value_address published Cell(0) into FENCES before calling refresh(), allowing a concurrent caller of completed_value_address to observe 0 instead of the fence's current GetCompletedValue().

This records pre-cell queued signal values in a pruned BTreeSet<u64> so completed_value_address arms every pending value > initial, and initialises the cell from GetCompletedValue() before inserting it.

What is in it

  • crates/xcl/src/hle/d3d12x/fence_x.rs: track pre-cell queued signals in Fence::pending (pruning completed values when pending.len() >= 16), initialise Cell with GetCompletedValue() before publishing, and arm all pending values > initial; add GPU test intermediate_signal_queued_before_completed_value_address_updates_cell (verified failing before the fix with cell stayed at 0 while fence GetCompletedValue() == 1).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib intermediate_signal_queued_before_completed_value_address_updates_cell and the_cell_follows_the_fence: both pass (first timed out at cell == 0 before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: cb60656233fc6537600105941ba65124f211e733
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1644 (PresentX 1644)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14606 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited fence_x.rs, wrote the fix and GPU test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5474094533 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1297). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T14:29:19Z. --- `fence_x::note_queue_signal` only recorded the maximum signalled value (`f.signalled`) before `completed_value_address` was first called. If a queue signalled `V1` and then `V2` (`V2 > V1`) before `completed_value_address`, only `V2` was armed: when the GPU completed `V1` and paused before `V2`, the completion event never fired and `*cell` stayed stale at `0` even though `GetCompletedValue() == V1` (deadlocking any caller waiting on `*cell >= V1`). In addition, `completed_value_address` published `Cell(0)` into `FENCES` before calling `refresh()`, allowing a concurrent caller of `completed_value_address` to observe `0` instead of the fence's current `GetCompletedValue()`. This records pre-cell queued signal values in a pruned `BTreeSet<u64>` so `completed_value_address` arms every pending value `> initial`, and initialises the cell from `GetCompletedValue()` before inserting it. **What is in it** - `crates/xcl/src/hle/d3d12x/fence_x.rs`: track pre-cell queued signals in `Fence::pending` (pruning completed values when `pending.len() >= 16`), initialise `Cell` with `GetCompletedValue()` before publishing, and arm all pending values `> initial`; add GPU test `intermediate_signal_queued_before_completed_value_address_updates_cell` (verified failing before the fix with `cell stayed at 0 while fence GetCompletedValue() == 1`). **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 `no wave64` — `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`) - `cargo test -p xcl --lib intermediate_signal_queued_before_completed_value_address_updates_cell` and `the_cell_follows_the_fence`: both pass (first timed out at `cell == 0` before the fix) **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1226 (PresentX 1226) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15341 MB ``` PR: ``` xcl-smoke v1 commit: cb60656233fc6537600105941ba65124f211e733 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1644 (PresentX 1644) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14606 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: audited `fence_x.rs`, wrote the fix and GPU test, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
futurepro62 commented 2026-11-24 15:06:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:37:11Z.


Full-suite run, since this PR has no test report yet. Tested exact head cb60656 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: intermediate_signal_queued_before_completed_value_address_updates_cell.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7134672035 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1297#issuecomment-7134672035). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:37:11Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `cb60656` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `intermediate_signal_queued_before_completed_value_address_updates_cell`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 16:07:21 +00:00 (Migrated from github.com)

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


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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7136855067 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1297#issuecomment-7136855067). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T15:56:03Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified `main`.) Thanks!
thehollowedone commented 2026-11-25 10:10:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T09:59:33Z.


Independent Windows run on cb60656. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC.

cargo build --workspace --offline --locked -j 4 passed. cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4 finished with 752 passed, 0 failed, 41 ignored, including two wave64 runtime skips in Cargo’s pass count. The PR's intermediate-signal regression passed.

With the D3D12 debug layer enabled, cargo test --offline --locked -j 4 -p xcl --lib local_signal_x_keeps_intermediate_fence_values_observable -- --nocapture --test-threads=1 passed 1 of 1 without skips. The scratch fixture called XCL's SignalX implementation on a native queue. The first completed-value address read was 16. As the fixture released five queue gates in turn, the value at that address followed the native fence through 17, 18, 19, 20 and 21. Signals 17–20 were queued before the address was requested. Signal 21 was queued after. When the scratch control armed only the highest pre-address value, the native fence reached 17 while the value at the address stayed 16. The control edit was restored. Synthetic queue coverage only.

AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7159076474 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1297#issuecomment-7159076474). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-25T09:59:33Z. --- Independent Windows run on [cb60656](https://github.com/xcl-dev/xcl/commit/cb60656233fc6537600105941ba65124f211e733). Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC. `cargo build --workspace --offline --locked -j 4` passed. `cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4` finished with **752 passed, 0 failed, 41 ignored**, including two wave64 runtime skips in Cargo’s pass count. The PR's intermediate-signal regression passed. With the D3D12 debug layer enabled, `cargo test --offline --locked -j 4 -p xcl --lib local_signal_x_keeps_intermediate_fence_values_observable -- --nocapture --test-threads=1` passed 1 of 1 without skips. The scratch fixture called XCL's `SignalX` implementation on a native queue. The first completed-value address read was 16. As the fixture released five queue gates in turn, the value at that address followed the native fence through 17, 18, 19, 20 and 21. Signals 17–20 were queued before the address was requested. Signal 21 was queued after. When the scratch control armed only the highest pre-address value, the native fence reached 17 while the value at the address stayed 16. The control edit was restored. Synthetic queue coverage only. AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
SzczepanGrela commented 2026-11-25 11:09:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-25T11:03:04Z.


Linux/RADV + Wine GPU test report on PR #1297 head cb60656 (cb60656233fc6537600105941ba65124f211e733, local merge c374a88d6b8a0ed5c522057456eb565d07bdb3e4 onto origin/main 568e7db7729c8fa6c8f0f4b32d798faaf11462bb).

Setup

  • OS/kernel: CachyOS Linux (7.3.0-5-cachyos)
  • GPU/driver: AMD Radeon RX 9070 (RADV GFX1201, native wave64) (device 0x7550, Vulkan 1.4.354, Mesa RADV 26.2.5-arch3.1)
  • Wine/DX: GE-Proton11-12 (wine-11.0 (Staging)), vkd3d-proton v3.1, DXVK dxgi.dll, DXC 1.9.2602.17 (21d28f72)
  • Build/env: rustc 1.97.1, cargo test --target x86_64-pc-windows-gnu --release --workspace --no-run (43.42s, exit 0, zero compiler warnings), XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0

Results

  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::fence_x::tests -- --nocapture: 2 passed, 0 failed, 0 ignored (0.09s, exit 0; both the_cell_follows_the_fence and new intermediate_signal_queued_before_completed_value_address_updates_cell passed), vs baseline 568e7db (hle::d3d12x::fence_x) 1 passed, 0 failed, 0 ignored (0.08s, exit 0).
  • hle::d3d12x::fence_x::tests -- --nocapture under concurrent Vulkan compute load (vk_tool burn burner.spv gfx 2048 4096 256 30, 803 dispatches, avg dispatch 6.34-6.81 ms): 5 of 5 consecutive runs passed (2 passed, 0 failed, 0 ignored in 0.07s per run, exit 0).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::late_release: 2 passed, 0 failed, 0 ignored (0.18s, exit 0), matching baseline 568e7db 2 passed, 0 failed, 0 ignored (0.19s, exit 0).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::real -- --test-threads=1: 45 passed, 1 failed, 0 ignored (1.18s, exit 101; dma_list_release_cleans_up_list_state at crates/xcl/src/hle/d3d12x/real.rs:6752:120 with HRESULT(0x80070057)), matching baseline 568e7db 45 passed, 1 failed, 0 ignored (1.12s, exit 101, same file, line, and error).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x -- --test-threads=4: 157 passed, 21 failed, 2 ignored (1.72s, exit 101), vs baseline 568e7db 156 passed, 21 failed, 2 ignored (1.63s, exit 101; +1 passed from fence_x::tests, identical set of 21 pre-existing failures).
  • cargo test --target x86_64-pc-windows-gnu --release --test d3d12_resource_and_sync (default and -- --test-threads=1): 2 passed, 1 failed, 0 ignored in both (0.62s and 0.64s, exit 101; fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console failed at crates/xcl/tests/d3d12_resource_and_sync.rs:481:118 with HRESULT(0x80070057)), matching baseline 568e7db 2 passed, 1 failed, 0 ignored in both (0.25s and 0.26s, exit 101, same file, line, and error).
  • cargo test --target x86_64-pc-windows-gnu --release --test gpu_compute_e2e: 2 passed, 2 failed, 0 ignored (1.49s, exit 101; console_wave64_compute_through_the_pso_hook_dispatch_and_read_back failed with 0x80070057 and heap_window_out_of_memory_falls_back_to_the_switch_form failed with no heap windows, but XCL_REQUIRE_GPU=wave64), matching baseline 568e7db 2 passed, 2 failed, 0 ignored (1.03s, exit 101, same 2 failures).

Not tested

  • No retail game workload and no scripts/smoke.ps1 (no retail title files locally).
  • XCL_HEAP_WINDOWS=1 (left unset) and --lib / --test targets outside those listed above.
  • d3d12_resource_and_sync (fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console) and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back hit the pre-existing Wine real::init() HRESULT(0x80070057) failure present on baseline 568e7db.

AI use

  • Diff audit, test execution, and comment drafting used Antigravity (Gemini 4 Neon) multi-agent verification, reviewed by me before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7160520581 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1297#issuecomment-7160520581). Originally posted by [SzczepanGrela](https://github.com/SzczepanGrela) on 2026-11-25T11:03:04Z. --- Linux/RADV + Wine GPU test report on PR `#1297` head `cb60656` (`cb60656233fc6537600105941ba65124f211e733`, local merge `c374a88d6b8a0ed5c522057456eb565d07bdb3e4` onto `origin/main` `568e7db7729c8fa6c8f0f4b32d798faaf11462bb`). **Setup** - OS/kernel: CachyOS Linux (`7.3.0-5-cachyos`) - GPU/driver: `AMD Radeon RX 9070 (RADV GFX1201, native wave64)` (device `0x7550`, Vulkan `1.4.354`, Mesa RADV `26.2.5-arch3.1`) - Wine/DX: `GE-Proton11-12` (`wine-11.0 (Staging)`), `vkd3d-proton v3.1`, DXVK `dxgi.dll`, DXC `1.9.2602.17` (`21d28f72`) - Build/env: `rustc 1.97.1`, `cargo test --target x86_64-pc-windows-gnu --release --workspace --no-run` (43.42s, exit `0`, zero compiler warnings), `XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0` **Results** - `cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::fence_x::tests -- --nocapture`: **2 passed, 0 failed, 0 ignored** (0.09s, exit `0`; both `the_cell_follows_the_fence` and new `intermediate_signal_queued_before_completed_value_address_updates_cell` passed), vs baseline `568e7db` (`hle::d3d12x::fence_x`) **1 passed, 0 failed, 0 ignored** (0.08s, exit `0`). - `hle::d3d12x::fence_x::tests -- --nocapture` under concurrent Vulkan compute load (`vk_tool burn burner.spv gfx 2048 4096 256 30`, 803 dispatches, avg dispatch 6.34-6.81 ms): **5 of 5 consecutive runs passed** (**2 passed, 0 failed, 0 ignored** in 0.07s per run, exit `0`). - `cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::late_release`: **2 passed, 0 failed, 0 ignored** (0.18s, exit `0`), matching baseline `568e7db` **2 passed, 0 failed, 0 ignored** (0.19s, exit `0`). - `cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::real -- --test-threads=1`: **45 passed, 1 failed, 0 ignored** (1.18s, exit `101`; `dma_list_release_cleans_up_list_state` at `crates/xcl/src/hle/d3d12x/real.rs:6752:120` with `HRESULT(0x80070057)`), matching baseline `568e7db` **45 passed, 1 failed, 0 ignored** (1.12s, exit `101`, same file, line, and error). - `cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x -- --test-threads=4`: **157 passed, 21 failed, 2 ignored** (1.72s, exit `101`), vs baseline `568e7db` **156 passed, 21 failed, 2 ignored** (1.63s, exit `101`; +1 passed from `fence_x::tests`, identical set of 21 pre-existing failures). - `cargo test --target x86_64-pc-windows-gnu --release --test d3d12_resource_and_sync` (default and `-- --test-threads=1`): **2 passed, 1 failed, 0 ignored** in both (0.62s and 0.64s, exit `101`; `fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console` failed at `crates/xcl/tests/d3d12_resource_and_sync.rs:481:118` with `HRESULT(0x80070057)`), matching baseline `568e7db` **2 passed, 1 failed, 0 ignored** in both (0.25s and 0.26s, exit `101`, same file, line, and error). - `cargo test --target x86_64-pc-windows-gnu --release --test gpu_compute_e2e`: **2 passed, 2 failed, 0 ignored** (1.49s, exit `101`; `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back` failed with `0x80070057` and `heap_window_out_of_memory_falls_back_to_the_switch_form` failed with `no heap windows, but XCL_REQUIRE_GPU=wave64`), matching baseline `568e7db` **2 passed, 2 failed, 0 ignored** (1.03s, exit `101`, same 2 failures). **Not tested** - No retail game workload and no `scripts/smoke.ps1` (no retail title files locally). - `XCL_HEAP_WINDOWS=1` (left unset) and `--lib` / `--test` targets outside those listed above. - `d3d12_resource_and_sync` (`fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console`) and `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back` hit the pre-existing Wine `real::init()` `HRESULT(0x80070057)` failure present on baseline `568e7db`. **AI use** - Diff audit, test execution, and comment drafting used Antigravity (Gemini 4 Neon) multi-agent verification, reviewed by me before posting.
Foniass commented 2026-12-01 05:22:02 +00:00 (Migrated from github.com)

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


Triage (#1607) – head cb60656

No open or merged PR makes the same change. The bug is still on main: FenceTable::completed_value_address_with creates the cell at 0 and arms only the highest signalled value, so intermediate signals queued earlier never update the cell.
Main rewrote fence_x.rs into FenceTable (per-cell refresh lock, fence_completed instead of the hooked GetCompletedValue, cell stores gated by complete_fence_downloads), so the rebase must read the initial value through real::fence_completed and keep that gating.
note_queue_signal now inserts into a BTreeSet on every signal of every fence that never gets a cell, and calls GetCompletedValue under the table lock once 16 are outstanding. This is cheap, but it runs on every Signal.
Recommendation: keep open.

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:7301695534 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1297#issuecomment-7301695534). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:22:02Z. --- **Triage (#1607)** – head cb60656 No open or merged PR makes the same change. The bug is still on main: `FenceTable::completed_value_address_with` creates the cell at 0 and arms only the highest `signalled` value, so intermediate signals queued earlier never update the cell. Main rewrote `fence_x.rs` into `FenceTable` (per-cell refresh lock, `fence_completed` instead of the hooked `GetCompletedValue`, cell stores gated by `complete_fence_downloads`), so the rebase must read the initial value through `real::fence_completed` and keep that gating. `note_queue_signal` now inserts into a `BTreeSet` on every signal of every fence that never gets a cell, and calls `GetCompletedValue` under the table lock once 16 are outstanding. This is cheap, but it runs on every Signal. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
thehollowedone commented 2026-12-01 05:28:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T05:28:02Z.


Source review of head cb606562 against main d0832e6. The intermediate-signal fix is still needed; the existing rebase note covers the newer fence table and download gating. Two additional points are worth addressing during that rebase:

  1. Pending-signal pruning scales quadratically while a queue is gated. In the PR's note_queue_signal, once 16 distinct values are pending, every later signal calls BTreeSet::retain over the entire growing set while holding the shared fence lock. If the GPU is held behind a wait and completion stays at zero, N pre-cell signals cause roughly N² predicate visits and delay unrelated fences. Query completion outside the table lock, then remove only completed values from the ordered front (first/pop_first) after reacquiring it. Recheck whether the cell was installed while the lock was released. A regression can queue many distinct values behind a closed gate, confirm none is lost, and check that a signal on a separate fence can proceed while the native completion query is held.

  2. The new test's fence lifetime is unsafe on failure. intermediate_signal_queued_before_completed_value_address_updates_cell puts the raw fence pointer into the global table, but calls mem::forget(fence) only on the success path. Its timeout branch panics; the fence then drops while the background refresh worker can still dereference that pointer. On current main, use forget_fence_for_test in a scope guard before the COM owner drops, including on assertion failure. Alternatively, keep the test fence alive on every exit as the old test intended.

For the rebase, keep main's zero-initialized mirror and refresh_one publication gate: a native completed value must not appear in the title's cell before pending readbacks and downloads are published. If concurrent first callers must observe the initial value synchronously, serialize their first refresh attempt outside the table lock; a withheld download still returns the conservative cell value.

This is source analysis, not a current-head build, GPU run, or merge-check. AI use: OpenAI Codex (GPT-6.2 Sol) traced the PR and current source; OpenAI Codex (GPT-6.2 Astra) independently checked the fence lifecycle and lock path.

<!-- greyfinch-sync:ivall/xcl:comment:7301800019 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1297#issuecomment-7301800019). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-12-01T05:28:02Z. --- Source review of [head `cb606562`](https://github.com/xcl-dev/xcl/commit/cb60656233fc6537600105941ba65124f211e733) against [`main` `d0832e6`](https://github.com/xcl-dev/xcl/commit/d0832e614fa7d6ae027bb4feb27ccb9121f54a8f). The intermediate-signal fix is still needed; [the existing rebase note](https://github.com/xcl-dev/xcl/pull/1297#issuecomment-7301695534) covers the newer fence table and download gating. Two additional points are worth addressing during that rebase: 1. **Pending-signal pruning scales quadratically while a queue is gated.** In the [PR's `note_queue_signal`](https://github.com/xcl-dev/xcl/blob/cb60656233fc6537600105941ba65124f211e733/crates/xcl/src/hle/d3d12x/fence_x.rs#L74-L93), once 16 distinct values are pending, every later signal calls `BTreeSet::retain` over the entire growing set while holding the shared fence lock. If the GPU is held behind a wait and completion stays at zero, N pre-cell signals cause roughly N² predicate visits and delay unrelated fences. Query completion outside the table lock, then remove only completed values from the ordered front (`first`/`pop_first`) after reacquiring it. Recheck whether the cell was installed while the lock was released. A regression can queue many distinct values behind a closed gate, confirm none is lost, and check that a signal on a separate fence can proceed while the native completion query is held. 2. **The new test's fence lifetime is unsafe on failure.** [`intermediate_signal_queued_before_completed_value_address_updates_cell`](https://github.com/xcl-dev/xcl/blob/cb60656233fc6537600105941ba65124f211e733/crates/xcl/src/hle/d3d12x/fence_x.rs#L192-L240) puts the raw fence pointer into the global table, but calls `mem::forget(fence)` only on the success path. Its timeout branch panics; the fence then drops while the background refresh worker can still dereference that pointer. On current `main`, use `forget_fence_for_test` in a scope guard before the COM owner drops, including on assertion failure. Alternatively, keep the test fence alive on every exit as the old test intended. For the rebase, keep `main`'s zero-initialized mirror and `refresh_one` publication gate: a native completed value must not appear in the title's cell before pending readbacks and downloads are published. If concurrent first callers must observe the initial value synchronously, serialize their first refresh attempt outside the table lock; a withheld download still returns the conservative cell value. This is source analysis, not a current-head build, GPU run, or merge-check. AI use: OpenAI Codex (GPT-6.2 Sol) traced the PR and current source; OpenAI Codex (GPT-6.2 Astra) independently checked the fence lifecycle and lock path.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1297:upstream-pr/1297'
git switch 'upstream-pr/1297'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1297'
git switch 'upstream-pr/1297'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1297'
git switch 'upstream-pr/1297'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1297'
git switch 'main'
git merge --squash 'upstream-pr/1297'
git switch 'main'
git merge --ff-only 'upstream-pr/1297'
git switch 'main'
git merge 'upstream-pr/1297'
git push origin 'main'
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!1287
No description provided.