Skip to content

runtime: say why a held list value gate stays shut - #2863

Closed
aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:runtime/held-gate-line
Closed

aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:runtime/held-gate-line

Conversation

@aznohonza

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: CXX-HELD-GATE-LINE

What and why

A held console wait stays held while anything can make progress, and docs/d3d12_xs_console_abi.md §5.5 lists the three deliberate ways it may go without its value. When none of them applies and the value never lands, the runtime says nothing: on this machine one run stood 101 minutes in one held console value with no presents and no queue calls, and the only way to learn why is to read d3d12_xs_list_values.h.

This adds one diagnostic line, at most once a minute, once the oldest gate has been held for a minute:

[rt] d3d12_xs: a list value gate has been held 61 s (3 held): a write group is running on the GPU

The reason is one of the conditions can_progress() reads, in its order — the releaser signalling, a title ExecuteCommandLists in progress, a running write group, a running action — then the shim's 2 ms present settle, then, when nothing can progress, the title still making queue calls or no candidate gate having waited out the quiet window. Counts and seconds only: no address, no title value.

  • runtime/src/list_value_progress.h: Hold, hold_text(), hold_reason() (the same conditions, in the same order) and report_due() (a minute's age, then one line a minute), next to the policy. decide() and can_progress() are byte-for-byte unchanged; nothing reads the new functions.
  • runtime/shims/d3d12_xs_list_values.h: note_held() and one call at each hold path in choose_release(). It is a GetTickCount64() comparison and two integer tests per pass; fprintf runs once a minute at most.

Tested

  • runtime/test/list_value_progress_test.cpp: every hold_reason() outcome, the decide() answer unchanged beside it, and report_due() at 1 s, one ms short of a minute, exactly a minute, right after a line, a minute after one, and with a clock that went back. Built with clang-cl/xwin and run under Wine 11.22: all checks passed, exit 0.
  • xs_proxy_mock_test (compiles the shim and drives the pump end to end) built and run under the same Wine: PASS (12 allocations refused on purpose), exit 0; no new compiler warnings in either changed file.
  • Configure: cmake -S runtime -B runtime/build/windows -G Ninja --toolchain runtime/cmake/clang-cl-xwin.cmake -DXWIN_DIR=$HOME/.local/share/xwin-sdk -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEONIDA_SDL3=OFF -DLEONIDA_VULKAN_HEADERS_FETCH=OFF.
  • The line cannot appear in the mock run: its scenarios hold a gate for well under a minute, so the due-ness is covered by the pure test, and the call sites are the five hold returns in choose_release().

No game files, no game data and no GPU: both tests are synthetic and CPU-only.

GPUs tested: none needed (CPU-only tests, Wine 11.22 on Linux).

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md. (n/a: runtime diagnostics only)

A gate held past a minute now prints one line a minute naming what kept it: the releaser signalling, a
title ExecuteCommandLists, a running write group or action, the present settle, the title still calling,
or the quiet window. Counts and seconds only.

list_value_progress.h gains hold_reason()/hold_text()/report_due() beside the policy; decide() and
can_progress() are untouched. The pure test covers every outcome and the 59/60/61 s rate limit.
@aznohonza
aznohonza force-pushed the runtime/held-gate-line branch from b6347e8 to 55eb8ab Compare December 1, 2026 10:46
@aznohonza

Copy link
Copy Markdown
Contributor Author

The windows job is red on display_white_cache only, the known flake fiestorra recorded (1 in 30 under load, fixed by the still-open #2713); it is not this change. From that job's log:

  • MSVC 19.52 build: clean for the three changed files, no warnings from them; list_value_progress_test.exe and xs_proxy_mock_test.exe both link.
  • 73/552 Test #73: list_value_progress ... Passed 0.04 sec, and xs_proxy_mock with all six of its variants passed.
  • 99% tests passed, 1 tests failed out of 550: 11 - display_white_cache (Failed).

Every other check passes (check, linux-python-and-viewer, semantic-tests, linux-gpu-tools, no-game-data, change-scope); wine is skipped by the workflow on this tree.

I could not rerun the job — gh run rerun answers "cannot be rerun" for this account — so the run stands as it is; the branch is unchanged since 55eb8ab64.

AI-assisted.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked hold_reason() against can_progress(): same tests, same order, and both are rebuilt from this pass's groups/view/activity under mutex_ (d3d12_xs_list_values.h:1180-1251), so nothing stale or guessed is reported. Log volume is fine — one process-wide Pump (:481-484), one report_due() per 60 s (list_value_progress.h:195-198), not per gate — and the fprintf under mutex_ adds no new lock order. The pure test pins the reason set: removing the write_running branch from hold_reason() fails it (list_value_progress_test.cpp:574).

But several wordings over-claim, and a diagnostics line that blames the wrong thing is worse than none:

  • submitting is the worst. It also fires on queue_holds::any_progress() — unretired GPU work on any attached queue, async inbox items, worker turns, a pump pass, an unpumped signal (queue_holds.h:55-61, :174-181) — so the line can say "a title ExecuteCommandLists is in progress" while the title is completely idle.
  • title_calling reads a masked value. activity.title_call_ms = max(title_call_ms_, last_progress_ms_) (:1192), and choose_release() bumps last_progress_ms_ on layer progress (:1185, :1209, :1238), so for up to 2 s after a landing a silent title is reported as "still making queue calls". Honest to decide(), misleading to a reader.
  • releasing over-claims landed_any: it means "a write landed this pass", not "has gates to signal" (the Activity comment says "or this pass moved"; hold_text drops that).
  • write_running/action_running are half true — the code's own comment at :1204 says "running or already completed (waiting for the next pass to land)", and the done >= … disjunct prints "running" for a group that finished. Usually transient, but a 60 s-old line can name a finished group.
  • young is not a cause. When the title has been quiet ≥2 s, decide() releases a candidate gate as stalled; a gate that still stays shut is not a candidate (an action gate, or a gate chained behind another queue's root), so "no candidate gate has waited out the quiet window yet" restates the last-resort test instead of naming the blocker. settling is a 2 ms window that will essentially never hit a 60 s boundary — drop it or fold it in.

Two coverage notes: nothing tests note_held() or its call sites (removing the shim call at :1212 leaves the pure test green, and xs_proxy_mock_test holds gates far under 60 s), and wording is unpinned beyond non-empty plus young != settling (swapping write_running's text for settling's passes). Also, when any_relaying is set (:1143) choose_release() is not called at all, so a gate held behind a relay still prints nothing.

Suggested: split submitting into "a title call" vs "GPU work still unretired", drop or merge settling, and name the actual blocker in the young fallback (which queue's root or which action gate).

@aslan2142

Copy link
Copy Markdown
Collaborator

Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

@aslan2142 aslan2142 closed this Dec 1, 2026
@aznohonza

Copy link
Copy Markdown
Contributor Author

Review addressed in c94db3f00 on the branch (runtime/held-gate-line), kept there for reference:

  • submitting is split: title_submitting (a title ExecuteCommandLists) and queue_busy (queue_holds::any_progress(), "a queue still has work to retire").
  • title_calling no longer reads the masked tick: Activity gains progress_ms (the layer's last progress) and decide() takes the max itself, so the window is the same but the wording reads the title's own call time (and says "called a queue or presented", since note_present() sets it too).
  • releasing is split from landed ("a write group landed in this pass; the gates open in the next").
  • write_running/action_running say "on the GPU and has not landed", true for both the running and the finished-not-landed disjunct.
  • young names the blocker: action_waiting when every held queue's first gate is an action (which decide() never releases), young only when a releasable first gate exists. Still no address: counts and seconds only.
  • settling is gone: that pass returns without a line, the release is due in the next one.
  • Wording is pinned per value (all nine distinct), and xs_proxy_mock_test reads the reason back through list_value_held_reason() after a gate is held, so removing the note_held() call in the hold path fails it. The flag branches and the two early write/action returns still have no end-to-end case (they need a concurrent title call or an in-flight landing).

On any_relaying: collect_retroactive_relays_locked() sets gate.relaying and apply_retroactive_relays() either erases the gate or clears the flag, so no gate stays held behind a relay — the silence there is right, and I did not add a reason for it.

Not reopening: the close notice says the legacy C++ runtime is deprecated in favour of the Rust d3d12/ tree, and this change only touches runtime/. Thanks for the review — the split caught two real over-claims (the masked tick and landed_any). AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants