d3d12_xs: a gate held for a later write opens on the GPU, behind the writer (RT-XS-LATE-RELAY) #2484

Closed
j-rally wants to merge 1 commit from upstream-pr/2484 into main
j-rally commented 2026-11-27 17:34:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by j-rally on 2026-11-27T17:34:02Z.


Claimed in the coordination issue as: RT-XS-LATE-RELAY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7224539005). Measurements behind it: #2464 (https://github.com/ubiquitarianism/leonida/issues/2464#issuecomment-7224144108). AI-assisted (Claude Code, Claude Opus 5.5).

What and why

A list value wait (slots 73/74) whose write was submitted after it — the waiter's ExecuteCommandLists came first, the usual order in the world load here — cannot be relayed at submission, because Pump::relay only sees writes already in flight. It becomes a gate, and the gate opens only after the writer's part has run on the GPU, the write has landed through the pump, the pump's 1 ms poll has read it back, and the single releaser thread has signalled it (running the held work on the way). On an RTX 4070 Ti SUPER in the world load, every held gate was met by such a later write (1,041 of 1,041 in 300 s, counted by this PR's new counter), and the releaser spent 89.5 s of the 300 s signalling them.

LEONIDA_LATE_RELAY=1 (off by default) takes those off the CPU. In ValueSubmission::flush, right after a queue signals its written fence behind a group of writes, Pump::take_late_relays(writer) returns the first gate still shut on each other queue whose waits are all met in memory or by writer's writes in flight, and the writer's queue signals that gate's fence to its value next. The waiter's held work is released when that Signal is submitted, and the GPU runs it behind the writer's part, as a relayed wait does today. The write still lands through the pump as before.

Invariants kept:

  • Order on the waiter's queue: a late-relayed gate stays in gates_, marked gpu_signalled. It never times out, is never handed to the releaser, and keeps its queue's later gates shut until the gate fence shows its value (take_open). So no CPU Signal of a later value can open it before the writer has run.
  • Only the writer's own writes count (plus waits already met in memory). The Signal sits behind them in the writer's queue order; a write on a third queue would not be ordered by it.
  • Not on the writer's own queue (the writer stands behind the gate there: a GPU deadlock), not an action gate (slot 31 remaps run on the CPU before their Signal), and none while the releaser still has gates to signal (one could be an action this gate must not overtake).
  • Only the first shut gate per queue, since gates open in order per queue.

Also added, always on: the list values line counts the gates a later write meets (and of those, the first shut on their queue), and with the switch, the gates signalled this way and the ones seen open. Exposed through xs::list_value_stats().

Tested

  • xs_proxy_mock case 9 (new): the gate of case 2's shape is signalled by the writer's queue right behind Signal(written); the gate stays shut until the GPU reaches it; it goes without a releaser Signal; the write lands. A writer on the waiter's own queue gets no late relay.
  • ctest -R "xs_proxy_mock|list_value_wait_budget": 10/10 pass (Windows, MSVC RelWithDebInfo). tests/test_docs_env_vars.py, test_docs_encoding.py, scripts/check_no_game_data.py: pass.
  • Game run A/B, same executable, only the variable changed:
RUN relayA | 2026-11-27 | j-rally | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        55bd6f4f1 + this change + local: LEONIDA_ARENA_MEMORY (arena in cached memory, a diagnostic switch not in this PR) | shaders: make_game.py --stages check,shaders,runtime (wave64 auto), from an earlier main of the same day
MACHINE:     RTX 4070 Ti SUPER 16 GB, desktop, Resizable BAR on | NVIDIA 621.40 | Windows 11 Pro 26300 | 32 GB
RECIPE:      documented ("Windows, NVIDIA") + DEVIATIONS: ASYNC_PIPELINES=1 ASYNC_MIN_BYTES=1048576 VALUE_WAIT_TIMEOUT_MS=30000 MAP_READBACK=1 PIPELINE_PREWARM_ORDER=1 COMPILE_HELPER=1 GPU_LATENCY=1 ARENA_MEMORY=cached | precompile: yes, all compute pipelines journaled
OS/DRIVER:   TdrDelay default
TARGET:      gate cost | PREDICTED (written before the run): releaser time and held time far lower in B, frames/s up
MEASURED:    4,009 waits, 2,472 met at submission, 428 relayed, 1,041 gates held (1,041 met by a later write, 527 first on their queue), 0 timed out; releaser 89.5 s, longest 2,830 ms; direct queue held operations 196 ms on average (27 windows), busy 25%; world frames/s from 150 s median 0.39, max 0.59
END:         time limit (300 s), no crash, no device loss
CACHES:      warm | RUN 1 of 1
INSTRUMENTS: LEONIDA_GPU_LATENCY=1
VERDICT:     -

RUN relayB | same, + LEONIDA_LATE_RELAY=1
MEASURED:    3,309 waits, 2,548 met at submission, 38 relayed, 683 gates held, 350 of them signalled on the GPU by the writer's queue (350 seen open), 333 by the releaser, 0 timed out; releaser 1.2 s, longest 300 ms; direct queue held operations 14 ms on average (24 windows), busy 22%; world frames/s from 150 s median 0.38, max 0.59
END:         time limit (300 s), no crash, no device loss; captures at the same frame numbers match A's (mean colour)
VERDICT:     prediction held for the gate cost, missed for frames/s: unchanged

So the CPU round trips behind gates are mostly gone (held time ~14x lower, releaser ~70x), but the frame rate in this phase does not move: something else limits it there (the GPU is still idle about three quarters of the time). That is why it stays opt-in for now; a game run on another GPU, and a longer one, would say whether it should become the default. n=1 per arm.

Not done

  • Gates that become their queue's first shut gate only after their writer flushed are not late-relayed (that needs a Signal from the writer's queue later, under its order lock). 333 of 683 gates in B still went through the releaser.
  • No picture comparison beyond mean colour of the periodic captures.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5530733705 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2484). Originally posted by [j-rally](https://github.com/j-rally) on 2026-11-27T17:34:02Z. --- Claimed in the coordination issue as: RT-XS-LATE-RELAY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7224539005). Measurements behind it: #2464 (https://github.com/ubiquitarianism/leonida/issues/2464#issuecomment-7224144108). AI-assisted (Claude Code, Claude Opus 5.5). ### What and why A list value wait (slots 73/74) whose write was submitted **after** it — the waiter's `ExecuteCommandLists` came first, the usual order in the world load here — cannot be relayed at submission, because `Pump::relay` only sees writes already in flight. It becomes a gate, and the gate opens only after the writer's part has run on the GPU, the write has landed through the pump, the pump's 1 ms poll has read it back, and the single releaser thread has signalled it (running the held work on the way). On an RTX 4070 Ti SUPER in the world load, every held gate was met by such a later write (1,041 of 1,041 in 300 s, counted by this PR's new counter), and the releaser spent 89.5 s of the 300 s signalling them. `LEONIDA_LATE_RELAY=1` (off by default) takes those off the CPU. In `ValueSubmission::flush`, right after a queue signals its `written` fence behind a group of writes, `Pump::take_late_relays(writer)` returns the first gate still shut on each **other** queue whose waits are all met in memory or by `writer`'s writes in flight, and the writer's queue signals that gate's fence to its value next. The waiter's held work is released when that Signal is submitted, and the GPU runs it behind the writer's part, as a relayed wait does today. The write still lands through the pump as before. Invariants kept: - **Order on the waiter's queue:** a late-relayed gate stays in `gates_`, marked `gpu_signalled`. It never times out, is never handed to the releaser, and keeps its queue's later gates shut until the gate fence shows its value (`take_open`). So no CPU Signal of a later value can open it before the writer has run. - **Only the writer's own writes count** (plus waits already met in memory). The Signal sits behind them in the writer's queue order; a write on a third queue would not be ordered by it. - **Not on the writer's own queue** (the writer stands behind the gate there: a GPU deadlock), **not an action gate** (slot 31 remaps run on the CPU before their Signal), and **none while the releaser still has gates to signal** (one could be an action this gate must not overtake). - Only the first shut gate per queue, since gates open in order per queue. Also added, always on: the `list values` line counts the gates a later write meets (and of those, the first shut on their queue), and with the switch, the gates signalled this way and the ones seen open. Exposed through `xs::list_value_stats()`. ### Tested - `xs_proxy_mock` case 9 (new): the gate of case 2's shape is signalled by the writer's queue right behind `Signal(written)`; the gate stays shut until the GPU reaches it; it goes without a releaser Signal; the write lands. A writer on the waiter's own queue gets no late relay. - `ctest -R "xs_proxy_mock|list_value_wait_budget"`: 10/10 pass (Windows, MSVC RelWithDebInfo). `tests/test_docs_env_vars.py`, `test_docs_encoding.py`, `scripts/check_no_game_data.py`: pass. - Game run A/B, same executable, only the variable changed: ``` RUN relayA | 2026-11-27 | j-rally | AI-assisted: Claude Code (Claude Opus 5.5) BASE: 55bd6f4f1 + this change + local: LEONIDA_ARENA_MEMORY (arena in cached memory, a diagnostic switch not in this PR) | shaders: make_game.py --stages check,shaders,runtime (wave64 auto), from an earlier main of the same day MACHINE: RTX 4070 Ti SUPER 16 GB, desktop, Resizable BAR on | NVIDIA 621.40 | Windows 11 Pro 26300 | 32 GB RECIPE: documented ("Windows, NVIDIA") + DEVIATIONS: ASYNC_PIPELINES=1 ASYNC_MIN_BYTES=1048576 VALUE_WAIT_TIMEOUT_MS=30000 MAP_READBACK=1 PIPELINE_PREWARM_ORDER=1 COMPILE_HELPER=1 GPU_LATENCY=1 ARENA_MEMORY=cached | precompile: yes, all compute pipelines journaled OS/DRIVER: TdrDelay default TARGET: gate cost | PREDICTED (written before the run): releaser time and held time far lower in B, frames/s up MEASURED: 4,009 waits, 2,472 met at submission, 428 relayed, 1,041 gates held (1,041 met by a later write, 527 first on their queue), 0 timed out; releaser 89.5 s, longest 2,830 ms; direct queue held operations 196 ms on average (27 windows), busy 25%; world frames/s from 150 s median 0.39, max 0.59 END: time limit (300 s), no crash, no device loss CACHES: warm | RUN 1 of 1 INSTRUMENTS: LEONIDA_GPU_LATENCY=1 VERDICT: - RUN relayB | same, + LEONIDA_LATE_RELAY=1 MEASURED: 3,309 waits, 2,548 met at submission, 38 relayed, 683 gates held, 350 of them signalled on the GPU by the writer's queue (350 seen open), 333 by the releaser, 0 timed out; releaser 1.2 s, longest 300 ms; direct queue held operations 14 ms on average (24 windows), busy 22%; world frames/s from 150 s median 0.38, max 0.59 END: time limit (300 s), no crash, no device loss; captures at the same frame numbers match A's (mean colour) VERDICT: prediction held for the gate cost, missed for frames/s: unchanged ``` So the CPU round trips behind gates are mostly gone (held time ~14x lower, releaser ~70x), but the frame rate in this phase does not move: something else limits it there (the GPU is still idle about three quarters of the time). That is why it stays opt-in for now; a game run on another GPU, and a longer one, would say whether it should become the default. n=1 per arm. ### Not done - Gates that become their queue's first shut gate only after their writer flushed are not late-relayed (that needs a Signal from the writer's queue later, under its order lock). 333 of 683 gates in B still went through the releaser. - No picture comparison beyond mean colour of the periodic captures. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-27 21:10:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T21:10:44Z.

Review: CHANGES_REQUESTED


Reviewed 020d1dd95 and tested on Windows 11 (MSVC 19.44): xs_proxy_mock passed (2.69 s).

The design of LEONIDA_LATE_RELAY is clear and well-scoped (off by default), but I found three concurrency / edge-case bugs in the new path:

  1. TOCTOU race on pending_releases_ (runtime/shims/d3d12_xs_list_values.h:440-441):
    take_late_relays() checks if (pending_releases_.load(std::memory_order_acquire) != 0) return out; before taking std::lock_guard lock(mutex_);. Meanwhile pass() pops earlier gates (including action gates) into opening and increments pending_releases_ under mutex_ (lines 966-970). If pass() runs between line 440 and line 441, take_late_relays() enters under mutex_, no longer sees the earlier gate in gates_, treats the following gate on that queue as the first shut gate, and lets writer signal a higher gate value on the GPU before the releaser has run the earlier action. Moving the pending_releases_ check inside std::lock_guard lock(mutex_); closes the window.
  2. Permanent stall on failed Signal or force teardown (runtime/shims/d3d12_xs_device.cpp:3952, runtime/shims/d3d12_xs_list_values.h:897-907):
    • take_late_relays() marks gate.gpu_signalled = true before ValueSubmission::flush() calls signal(waiter->gate, gate_value). If signal(...) returns FAILED, the gate stays gpu_signalled = true forever, never times out, and permanently blocks all subsequent gates on waiter. On FAILED, gpu_signalled should be cleared (or handed back to the normal gate path).
    • In take_open() (d3d12_xs_list_values.h:897-907), if (gate.gpu_signalled) executes continue before bool open = force;. On force == true (e.g., stop() / teardown after a GPU hang or device loss), a gpu_signalled gate whose fence never reaches gate.value is never drained.
  3. Stale-write match when writer overwrites the same address (runtime/shims/d3d12_xs_list_values.h:450-456):
    take_late_relays() iterates writes_ forward and returns true on the first matching write from writer. If writer writes a matching value (e.g. 1 for == 1) and then overwrites the same address with a non-matching value (e.g. 2) in the same or a later in-flight WriteGroup, take_late_relays() still signals the gate after the later write even though the final value at Signal time does not satisfy the wait. Checking the last in-flight write by writer to wait.address (matching relay's semantics) avoids false early signals.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6093382888 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2484#pullrequestreview-6093382888). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T21:10:44Z. **Review:** CHANGES_REQUESTED --- Reviewed `020d1dd95` and tested on Windows 11 (MSVC 19.44): `xs_proxy_mock` passed (2.69 s). The design of `LEONIDA_LATE_RELAY` is clear and well-scoped (off by default), but I found three concurrency / edge-case bugs in the new path: 1. **TOCTOU race on `pending_releases_` (`runtime/shims/d3d12_xs_list_values.h:440-441`):** `take_late_relays()` checks `if (pending_releases_.load(std::memory_order_acquire) != 0) return out;` *before* taking `std::lock_guard lock(mutex_);`. Meanwhile `pass()` pops earlier gates (including action gates) into `opening` and increments `pending_releases_` *under* `mutex_` (lines 966-970). If `pass()` runs between line 440 and line 441, `take_late_relays()` enters under `mutex_`, no longer sees the earlier gate in `gates_`, treats the following gate on that queue as the first shut gate, and lets `writer` signal a higher gate value on the GPU before the releaser has run the earlier action. Moving the `pending_releases_` check inside `std::lock_guard lock(mutex_);` closes the window. 2. **Permanent stall on failed `Signal` or `force` teardown (`runtime/shims/d3d12_xs_device.cpp:3952`, `runtime/shims/d3d12_xs_list_values.h:897-907`):** - `take_late_relays()` marks `gate.gpu_signalled = true` before `ValueSubmission::flush()` calls `signal(waiter->gate, gate_value)`. If `signal(...)` returns `FAILED`, the gate stays `gpu_signalled = true` forever, never times out, and permanently blocks all subsequent gates on `waiter`. On `FAILED`, `gpu_signalled` should be cleared (or handed back to the normal gate path). - In `take_open()` (`d3d12_xs_list_values.h:897-907`), `if (gate.gpu_signalled)` executes `continue` before `bool open = force;`. On `force == true` (e.g., `stop()` / teardown after a GPU hang or device loss), a `gpu_signalled` gate whose fence never reaches `gate.value` is never drained. 3. **Stale-write match when `writer` overwrites the same address (`runtime/shims/d3d12_xs_list_values.h:450-456`):** `take_late_relays()` iterates `writes_` forward and returns `true` on the *first* matching write from `writer`. If `writer` writes a matching value (e.g. `1` for `== 1`) and then overwrites the same address with a non-matching value (e.g. `2`) in the same or a later in-flight `WriteGroup`, `take_late_relays()` still signals the gate after the later write even though the final value at `Signal` time does not satisfy the wait. Checking the *last* in-flight write by `writer` to `wait.address` (matching `relay`'s semantics) avoids false early signals. AI-assisted (Antigravity, Gemini).
timbot103 commented 2026-11-28 00:53:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T00:53:20Z.


Independently checked head 020d1dd95 on Windows 11 Pro 26200, MSVC 2022 (19.44.35230.0, RelWithDebInfo, Ninja), no game files.

Local build & test verification:

  • Clean MSVC build of xs_proxy_mock_test (zero new warnings in d3d12_xs_device / d3d12_xs_list_values beyond standard C4996 getenv).
  • xs_proxy_mock_test: PASS (12 allocations refused on purpose).

Static review findings on 020d1dd95 (behind off-by-default LEONIDA_LATE_RELAY):

  1. Permanent queue hang if the relayed Signal fails: take_late_relays sets gate.gpu_signalled = true before the caller submits the fence Signal. In ValueSubmission (~lines 3952–3957), a failed Signal only logs late relay: the gate Signal failed. Because gpu_signalled remains true, the releaser never releases that gate and it never times out, leaving that queue (and every subsequent gate on it) permanently blocked. Committing gpu_signalled = true only after Signal succeeds — or clearing it under mutex_ on failure so normal release/timeout takes over — closes this.
  2. Timeline-semaphore backwards-signal race to verify: pending_releases_ is checked before acquiring mutex_. If the pump opens gate G1 under mutex_ (queueing CPU Signal(V1) on the releaser) while a writer relays gate G2 with GPU Signal(V2) (V2 > V1), the releaser's CPU Signal(V1) can arrive after V2, signaling a timeline semaphore non-monotonically (invalid in Vulkan). Re-checking pending_releases_ under mutex_ (or skipping releaser signals <= completed) prevents out-of-order signals.
  3. Read-order semantics to confirm/document: the waiter's GPU work can now run immediately behind the writer's GPU work while the waited label value still lands via the CPU pump after written completes; if the waiter's GPU commands read that label address directly, they could observe the old value. Confirming this matches existing waits_relayed assumptions (or documenting it) is helpful.
  4. Two minor notes:
    • "Met" currently accepts any write in the group to that address; if a later write in the same group overwrites it with a non-matching value, using the last write in group order is more accurate.
    • count_late_relayable_locked runs under mutex_ on every add_writes even when LEONIDA_LATE_RELAY is off (O(gates * writes * waits) plus an O(gates^2) scan); gating it behind late_relay_enabled() or a diagnostics flag keeps the default hot path free.
  5. Suggested extra tests: failed gate Signal fallback, action gate first on waiter's queue (must not relay), two waiting queues relayed by one write group, and stop() while a relayed gate is still shut.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7231265007 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2484#issuecomment-7231265007). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T00:53:20Z. --- Independently checked head `020d1dd95` on Windows 11 Pro 26200, MSVC 2022 (`19.44.35230.0`, RelWithDebInfo, Ninja), no game files. **Local build & test verification:** - Clean MSVC build of `xs_proxy_mock_test` (zero new warnings in `d3d12_xs_device` / `d3d12_xs_list_values` beyond standard `C4996 getenv`). - `xs_proxy_mock_test`: **PASS** (`12 allocations refused on purpose`). **Static review findings on `020d1dd95` (behind off-by-default `LEONIDA_LATE_RELAY`):** 1. **Permanent queue hang if the relayed `Signal` fails:** `take_late_relays` sets `gate.gpu_signalled = true` *before* the caller submits the fence `Signal`. In `ValueSubmission` (~lines 3952–3957), a failed `Signal` only logs `late relay: the gate Signal failed`. Because `gpu_signalled` remains `true`, the releaser never releases that gate and it never times out, leaving that queue (and every subsequent gate on it) permanently blocked. Committing `gpu_signalled = true` only after `Signal` succeeds — or clearing it under `mutex_` on failure so normal release/timeout takes over — closes this. 2. **Timeline-semaphore backwards-signal race to verify:** `pending_releases_` is checked *before* acquiring `mutex_`. If the pump opens gate G1 under `mutex_` (queueing CPU `Signal(V1)` on the releaser) while a writer relays gate G2 with GPU `Signal(V2)` (`V2 > V1`), the releaser's CPU `Signal(V1)` can arrive after `V2`, signaling a timeline semaphore non-monotonically (invalid in Vulkan). Re-checking `pending_releases_` under `mutex_` (or skipping releaser signals `<= completed`) prevents out-of-order signals. 3. **Read-order semantics to confirm/document:** the waiter's GPU work can now run immediately behind the writer's GPU work while the waited label value still lands via the CPU pump after `written` completes; if the waiter's GPU commands read that label address directly, they could observe the old value. Confirming this matches existing `waits_relayed` assumptions (or documenting it) is helpful. 4. **Two minor notes:** - "Met" currently accepts *any* write in the group to that address; if a later write in the same group overwrites it with a non-matching value, using the last write in group order is more accurate. - `count_late_relayable_locked` runs under `mutex_` on every `add_writes` even when `LEONIDA_LATE_RELAY` is off (`O(gates * writes * waits)` plus an `O(gates^2)` scan); gating it behind `late_relay_enabled()` or a diagnostics flag keeps the default hot path free. 5. **Suggested extra tests:** failed gate `Signal` fallback, action gate first on waiter's queue (must not relay), two waiting queues relayed by one write group, and `stop()` while a relayed gate is still shut. AI-assisted.
zmasi commented 2026-11-28 11:36:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:36:17Z.


#2484 | head 020d1dd95b (merged cleanly with main 4a54aedcb6) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xs_proxy_mock.*|list_value_wait_budget)$" --output-on-failure + tests/test_docs_encoding.py | red on main: xs_proxy_mock_test.cpp fails compile on main (C2039: gates_late_relayed / set_list_value_late_relay absent), and stubbing take_late_relays empty fails case 9 at xs_proxy_mock_test.cpp:4287 (g_queue_call_count == 2, no GPU gate Signal queued behind a_written) | green on PR+main: 10/10 CTests pass (all 9 xs_proxy_mock variants + list_value_wait_budget), test_docs_encoding.py passes, LEONIDA_LATE_RELAY documented cleanly in test_docs_env_vars.py, check_no_game_data.py 0 violations (non-blocking note: if signal(waiter->gate, gate_value) ever returns FAILED at d3d12_xs_device.cpp:3954, gate.gpu_signalled stays true in gates_, and take_open checks gpu_signalled ahead of force) | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238661319 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2484#issuecomment-7238661319). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:36:17Z. --- #2484 | head 020d1dd95ba3d949c78d4bf9ab71afc9b029aecd (merged cleanly with main 4a54aedcb6b66525e0c9f72a6ea10263337c9141) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(xs_proxy_mock.*|list_value_wait_budget)$" --output-on-failure` + `tests/test_docs_encoding.py` | red on main: `xs_proxy_mock_test.cpp` fails compile on `main` (`C2039`: `gates_late_relayed` / `set_list_value_late_relay` absent), and stubbing `take_late_relays` empty fails case 9 at `xs_proxy_mock_test.cpp:4287` (`g_queue_call_count == 2`, no GPU gate `Signal` queued behind `a_written`) | green on PR+main: 10/10 CTests pass (all 9 `xs_proxy_mock` variants + `list_value_wait_budget`), `test_docs_encoding.py` passes, `LEONIDA_LATE_RELAY` documented cleanly in `test_docs_env_vars.py`, `check_no_game_data.py` `0` violations (non-blocking note: if `signal(waiter->gate, gate_value)` ever returns `FAILED` at `d3d12_xs_device.cpp:3954`, `gate.gpu_signalled` stays `true` in `gates_`, and `take_open` checks `gpu_signalled` ahead of `force`) | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes
timbot103 commented 2026-11-29 01:05:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:05:58Z.

Review: COMMENTED


I recommend changes on head 020d1dd95. This was a static audit only. I did not run builds, tests, or GPU workloads.

  • Blocker — runtime/shims/d3d12_xs_list_values.h:475. Submit two unmet gates first, then submit each gate's producer behind the other gate. Both gates get marked gpu_signalled and both queue signals are held behind the waits they need to release. Please leave the CPU timeout active whenever the writer's actual signal point could depend on a pending gate or unresolved fence wait. The existing mutual-cycle budget test provides a starting case.
  • Major — runtime/shims/d3d12_xs_list_values.h:468. The pump can move a ready remap gate to the releaser between the pending-release check and lock acquisition. A higher GPU fence value can then open the wait before the remap runs. Move the check under mutex_ and cover a pending remap followed by a matching memory gate.
  • Major — runtime/shims/d3d12_xs_device.cpp:3954. A failed gate signal leaves the gate permanently on the GPU path, including when the Vulkan layer accepts the call and the deferred submission fails later. Please resolve the relay reservation on actual submission or failure and restore CPU release on confirmed failure. On Vulkan, the failed fence claim also needs to be undone to allow a same-value retry.
  • Major — runtime/shims/d3d12_xs_list_values.h:478. For a gate waiting on x == 1, a later group containing x = 1 followed by x = 2 triggers a relay even though the pump would observe 2 after landing the group. Base eligibility on the final ordered write touching the waited bytes and cover an overwrite in one group.
  • Minor — runtime/test/xs_proxy_mock_test.cpp:4006. With LEONIDA_LATE_RELAY=1 inherited from the environment, case 2 takes the GPU path but advances only the written fence. Set the switch explicitly at test entry so case 2 exercises CPU release and case 9 exercises GPU release.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6100839366 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2484#pullrequestreview-6100839366). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T01:05:58Z. **Review:** COMMENTED --- I recommend changes on head `020d1dd95`. This was a static audit only. I did not run builds, tests, or GPU workloads. - **Blocker** — `runtime/shims/d3d12_xs_list_values.h:475`. Submit two unmet gates first, then submit each gate's producer behind the other gate. Both gates get marked `gpu_signalled` and both queue signals are held behind the waits they need to release. Please leave the CPU timeout active whenever the writer's actual signal point could depend on a pending gate or unresolved fence wait. The existing mutual-cycle budget test provides a starting case. - **Major** — `runtime/shims/d3d12_xs_list_values.h:468`. The pump can move a ready remap gate to the releaser between the pending-release check and lock acquisition. A higher GPU fence value can then open the wait before the remap runs. Move the check under `mutex_` and cover a pending remap followed by a matching memory gate. - **Major** — `runtime/shims/d3d12_xs_device.cpp:3954`. A failed gate signal leaves the gate permanently on the GPU path, including when the Vulkan layer accepts the call and the deferred submission fails later. Please resolve the relay reservation on actual submission or failure and restore CPU release on confirmed failure. On Vulkan, the failed fence claim also needs to be undone to allow a same-value retry. - **Major** — `runtime/shims/d3d12_xs_list_values.h:478`. For a gate waiting on `x == 1`, a later group containing `x = 1` followed by `x = 2` triggers a relay even though the pump would observe `2` after landing the group. Base eligibility on the final ordered write touching the waited bytes and cover an overwrite in one group. - **Minor** — `runtime/test/xs_proxy_mock_test.cpp:4006`. With `LEONIDA_LATE_RELAY=1` inherited from the environment, case 2 takes the GPU path but advances only the written fence. Set the switch explicitly at test entry so case 2 exercises CPU release and case 9 exercises GPU release. AI-assisted.

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
ProjectLeonida/mandy!2484
No description provided.