Skip to content

GPU: remember pipelines whose creation crashed the process (VICTORY_PIPELINE_JOURNAL) - #491

Open
desplmfao wants to merge 11 commits into
Marvisak:mainfrom
desplmfao:diag/pipeline-journal
Open

desplmfao wants to merge 11 commits into
Marvisak:mainfrom
desplmfao:diag/pipeline-journal

Conversation

@desplmfao

@desplmfao desplmfao commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Some host drivers crash while compiling a translated shader. Under Wine (vkd3d-proton) the fault inside vkCreate*Pipelines ends the process with exit code 3 before any handler runs (err:vulkan:vkCreateComputePipelines Exception 0xc0000005 in Unix call), so crashes.log stays empty, nothing names the shader, and the same crash comes back at the same point on every run (#144, #49).

Change

With VICTORY_PIPELINE_JOURNAL=1, each host pipeline is noted in pipeline-journal/pending/ (next to the pipeline cache) while it is created, and the note is removed when creation returns. A note left at the next start names the pipeline that was being created when the process ended: it is added to pipeline-journal/crashed.txt and refused from then on, its draws and dispatches dropped like those of any refused pipeline, and the log names it. Pipelines are still created in parallel. A crash that leaves one note names that pipeline. A crash that leaves several makes them suspects (pipeline-journal/suspects.txt): they are not refused, but each is created alone (the other workers wait) until its creation returns, so a repeat crash leaves one note and names it. Deleting a line from crashed.txt lets that pipeline be tried again. Off by default; nothing changes without it.

New pipeline/journal.rs; a hook at the start of host pipeline creation in pipeline/host.rs; the folder set next to the pipeline cache in pipeline.rs; a paragraph in the README.

Tested

RTX 5080, Linux (proton-cachyos, vkd3d-proton 3.2.0), Series X 1.0.2.1, this branch alone (main d2a4bae + this commit, without #259), its own cache folder:

  1. Run 1: vkCreateComputePipelines Exception 0xc0000005 while loading; one note left, pending/ef05293f6107fc99@32-67.
  2. Run 2: at start, the last run ended while creating these host pipelines; they are refused from now on pipelines=["ef05293f6107fc99"], and crashed.txt lists it. The title got past it to the next crash, again with one note: 9938c251a313fe28.

Both are compute programs whose pipeline creation crashes the NVIDIA driver, fixed in #259. Before pipelines were created one at a time, a crash left several notes and the others had to be removed by hand.

Update: the first version created all pipelines one at a time while the journal was on. With the wave64 programs of #233/#439, which take seconds each to compile, the pipeline backlog at the loading screen shrank by about 0.1 per second instead of about 5, with seven of the eight pipeline workers idle. afedb15 creates them in parallel again and only isolates suspects.

Four tests in journal.rs (no GPU): a note left by a crash refuses that pipeline on the next start and lists it; a pipeline whose line was removed is tried again; notes left by pipelines created together become suspects, a suspect is created alone and leaves the list when it succeeds, and a suspect that crashes alone is refused; ordinary pipelines are created together. They pass under Wine; cargo clippy and rustfmt report nothing new.

Related

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Some host drivers crash while compiling a translated shader. Under Wine
the fault inside vkCreate*Pipelines ends the process with exit code 3
before any handler runs, so nothing names the shader and the same crash
comes back on every run.

With VICTORY_PIPELINE_JOURNAL=1, each host pipeline is noted in
pipeline-journal/pending/ while it is created, and the note is removed
when creation returns. A note left at the next start names the pipeline
that was being created when the process ended: it goes into
pipeline-journal/crashed.txt and is refused from then on, its draws and
dispatches dropped like those of any refused pipeline. Pipelines are
created one at a time while the journal is on, so a crash names only the
pipeline that caused it. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fromthemoonx

Copy link
Copy Markdown

Tested 24c419b merged onto current main (ffe310e, merges cleanly) natively on Windows.

Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1 x86_64-pc-windows-msvc.

CI's commands, on the merge: both clippy runs (-D warnings, with and without --all-features) clean; cargo test --workspace --locked: 344 passed, 0 failed, 6 ignored. The victory-gpu lib tests also pass with VICTORY_PIPELINE_JOURNAL=1 set (52 passed).

Two ways a pipeline gets refused without having crashed anything. A throwaway test (not pushed) runs the test binary again as a child process against a temporary journal folder:

scenario result
the child calls enter("eeee…") and then exits normally (std::process::exit(0), exit code 0) at the next Journal::open, eeee… is refused and written to crashed.txt
our process holds enter("ffff…") (a pipeline being created) while another process opens the same journal the other process refuses ffff… and writes it to crashed.txt
  • Exit during creation. pending/ can't tell a crash from any other way the process ends while a pipeline is being created. Closing the window while shaders compile, ExitProcess from the title, or a crash elsewhere on another thread all leave the note. With pipelines made by worker threads during loading, quitting mid-load would blacklist whichever pipeline was in flight, permanently and with a "creating it ended an earlier run" warning.
  • Two processes. A second process (two victory instances, or victory translate --pipelines next to a running title) finds the first one's in-flight note and lists it as crashed.

Possible ways to narrow it, none of them tested here:

  • In open, skip notes whose process id (already in the file name) is still running.
  • Remove notes on a clean shutdown, or have the crash reporter confirm the crash.
  • Refuse a pipeline only after its note has been left twice. One extra crash per bad pipeline, but no permanent false refusals.

Since the journal is opt-in and crashed.txt is editable, this is about how much to trust the list rather than a correctness problem for default runs.

Smaller note: the key string (hash+hash) is built for every host pipeline even with the journal off. It's cheap next to pipeline creation, but it could move behind the journal() check.

Not tested: a real driver crash during creation (none reproduces on this GPU), Wine/vkd3d-proton; no game data used.

AI-assisted (Claude Code) ran the checks and drafted this comment.

@mercuryVM mercuryVM 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.

Tested 24c419b on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 45 passed, including the journal tests. Clippy's 1 warning is the existing one in host.rs. I couldn't reproduce a driver crash here, so the "next run refuses it" path is covered by the unit tests only.

  • Off by default: with VICTORY_PIPELINE_JOURNAL unset, journal() is None, enter is a no-op and creation stays parallel. With it on, the one mutex serialises creation so a leftover note names only one pipeline. That's the right trade for a diagnostic.
  • Notes and crashed.txt live next to the pipeline cache, which already passes ensure_outside_repo, and they hold only shader hashes. No title bytes are written.
  • Small things:
    • A pending note is only turned into a crashed.txt line at the next start. If the user deletes the cache folder between runs, the knowledge is lost, which is acceptable but worth one README sentence.
    • The ? on journal::enter makes a refused pipeline fail like any other refusal, so the existing drop logging covers it.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…n crashed the process (VICTORY_PIPELINE_JOURNAL)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao and others added 2 commits November 24, 2026 08:11
A crash with one pipeline in creation names it (crashed.txt) as before. A
crash with several in creation makes them suspects (suspects.txt): they
are not refused, but each is created alone until its creation returns, so
a repeat crash leaves one note and names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fromthemoonx

Copy link
Copy Markdown

Re-tested 027926b merged onto main ffe310e (same RTX 3060 machine). Running pipelines in parallel and isolating only suspects is a good change for loading time.

  • CI's commands, on the merge: both clippy runs (-D warnings, with and without --all-features) clean; cargo test --workspace --locked: 346 passed, 0 failed, 6 ignored. All four journal tests pass.

  • The two cases from my earlier comment, re-run with the same throwaway child-process test:

    scenario result on 027926b
    child calls enter("eeee…") and exits normally (exit code 0) eeee… is refused at the next start and written to crashed.txt
    another process opens the journal while ours is creating ffff… it refuses ffff… and writes it to crashed.txt

    A single note still means "refused", so both still blacklist a pipeline that didn't crash. The suspects path helps when a crash leaves several notes, but quitting during loading with exactly one pipeline in flight, or a second instance, still lands in crashed.txt. Treating a lone note as a suspect too (refusing only after it is left again while created alone), or skipping notes whose process id is still running, would cover both.

AI-assisted (Claude Code); synthetic tests only, no game data.

@YaBulochka

Copy link
Copy Markdown

Confirmed on Linux/RADV, and on this title it is the difference between a hard wall and reaching the intro. Build ffe310e + #994 + this PR; Wine 11.22 in a Proton 11.0 prefix (vkd3d-proton from Proton, DXVK dxgi), RADV from Mesa 26.3.1, RX 7600 XT, VICTORY_PIPELINE_JOURNAL=1.

Three runs of the retail title, cold shader cache:

run refused pending left mesh pipelines outcome
1 1 4e296b1885c37b29@32-23 3 died while creating that compute pipeline
2 2 5 (8bb272e763f76148@32-35 + suspects) 20 past both refused ones, died on the next compute pipeline, 6.8 fps
3 2 1 3 alive, the intro's title cards render, 0.6–1.6 fps, 7.7 GB VRAM

So the mechanics work exactly as described: the note names the pipeline that ended the process, it is refused on the next start, and each run buys one more shader. After two refusals the run no longer dies in vkCreate*Pipelines at all — the remaining stop is the title's own fault at +0x23cf683 during Prestream Metadata, and before that it plays the intro. The cost is visible and honest: 20 draws/dispatches dropped for the two refused pipelines, one line per pipeline in the log.

Two small suggestions, if you want them:

  • the note carries only <hash>@<something>; adding the stage and the container size to the file name (or a sidecar) would make pending/ readable without going back to the log;
  • when a pipeline is refused at start-up, it would help to say up front how many draws/dispatches will be dropped from then on (the run-time victory_gpu::draw line does that, the start-up line does not).

I can rerun with any build you want, or hand over the two hashes with their stage and container size if you'd like to look at the shaders themselves.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
crashed.txt now starts with the translator its pipelines crashed under
(# translator <source hash>). When the translator has changed, or the list
has no such line, the listed pipelines are not refused: each becomes a
suspect, made alone, and is listed again (under the new translator) if it
ends the run again.

Found in Grand Theft Auto VI on Linux: CS_Prop_BatchNoCull and
CS_LaserLightShadowRaytracing overflowed the stack while being made under a
morning build, and the journal skipped them in every run after, including
builds where they are made fine (checked with a cold pipeline library and
vkd3d cache). Their dispatches were dropped for hours for nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

Copy link
Copy Markdown
Contributor Author

Added 3d6521b after finding a weakness of this PR in the title: entries in crashed.txt never expired.

What happened: under a build from this morning, CS_Prop_BatchNoCull and CS_LaserLightShadowRaytracing overflowed the stack while being made (Grand Theft Auto VI on Linux; the overflow was caught by #2292). The journal listed them, and from then on it skipped them in every run, including later builds where they are made without trouble. I checked that with a cold pipeline library, an empty vkd3d cache and the NVIDIA disk cache off. Their dispatches were dropped for hours for no reason. I only noticed because the frame lines kept naming the same two hashes as refused.

The change:

  • crashed.txt now starts with # translator <hash> (victory_shader::SOURCE_HASH), naming the translator its pipelines crashed under.
  • When the translator differs, or the list has no such line (lists written before this change), the listed pipelines are not refused. Each becomes a suspect: made alone, and listed again under the new translator if it ends the run again.
  • Under the same translator nothing changes: a crashed pipeline stays refused.

Three new tests cover these cases, and the existing ones now expect the header line. cargo test -p victory-gpu --lib pipeline::journal gives 10 passed under Wine on an RTX 5080, and clippy is clean.

The trade-off: a driver or vkd3d update doesn't change the translator hash, so it doesn't re-arm the list on its own. Deleting the line still does that, as before.

desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
…slator they crashed under

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
The previous main (old upstream base) is the first parent; the second is
upstream main with the current heads of our pull requests merged in:
Marvisak#2143, Marvisak#1849 (carried onto main's per-region runtime_pages), Marvisak#259, Marvisak#491,
Marvisak#2153, Marvisak#2099, Marvisak#2071 (main covers it), Marvisak#2162, Marvisak#2218, Marvisak#2088, Marvisak#2389, Marvisak#177's
element-type key on main's three handle maps, and the README. Marvisak#2112
(opt-in, in place) stays in the renderer branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot take it again

A run hung at 0 % CPU with 9 suspects listed: pipeline creation holds the
gate until it returns, and a pipeline made inside another's creation (a
helper) took it again on the same thread. Held alone by a suspect, that
waits on itself; held shared while a suspect waits to hold it alone, the
second shared take waits behind the suspect (SRW locks give a waiting
writer priority). A thread now takes the gate once; nested creations are
still noted, so a crash inside one is still named.

Found in Grand Theft Auto VI on Linux: pipeline creation stopped at 1,721
pipelines being made, 0 % CPU, for minutes, with suspects.txt holding 9
pipelines from runs stopped mid-creation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

Copy link
Copy Markdown
Contributor Author

A bug fix found in the title, in 9bcd755: the gate could deadlock.

Pipeline creation holds the gate until it returns. A pipeline made inside another pipeline's creation (a helper made on the same thread) took the gate a second time. If a suspect held it alone, the thread waited on itself. If the gate was held shared while a suspect waited to hold it alone, the second shared take waited behind the suspect, because SRW locks give a waiting writer priority. In Grand Theft Auto VI on Linux, pipeline creation stopped at 1,721 pipelines being made, at 0 % CPU, for minutes, with 9 suspects listed from runs stopped mid-creation.

A thread now takes the gate once. Nested creations are still noted, so a crash inside one is still named. The new test a_nested_pipeline_does_not_take_the_gate_again (a suspect makes a helper pipeline) times out after 5 s without the fix and passes with it. The tests that simulate a crash with mem::forget now go through a small crash() helper that also clears the thread's hold, as a real crash ending the thread would. pipeline::journal gives 11 passed under Wine, and clippy is clean. #2292 has it merged.

desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
… per thread

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A suspect (a pipeline being created when an earlier run ended) is
created alone so that a crash in it is pinned on it. But other pipelines
then wait as long as it takes: minutes for a large compute shader on a
cold driver cache, or for ever if its creation waits on another thread
that itself needs the gate. The title waits for the pipelines queued
behind it, so the title screen ran at 500 ms per frame.

The gate is now a mutex and condition variable instead of an RwLock: a
suspect holds it alone (or waits to) for at most 5 s, then the others go
ahead. If the run ends after that, the suspect is one of several being
created and stays a suspect instead of being refused.

Found in Grand Theft Auto VI on Linux: the title screen at 500 ms per
frame with 1,714 pipelines being made and none finishing, the journal's
only note a suspect (compute-3360) pending since launch at 0 % CPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
…waiting for at most 5 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
…r at most 5 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
…s gate time cap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

Copy link
Copy Markdown
Contributor Author

A second fix from the title, in f4f3364: a suspect now holds other pipelines up for at most 5 s.

A suspect is created alone, so a crash in it is pinned on it. But every other pipeline then waited for as long as that took. In Grand Theft Auto VI the title screen ran at 500 ms per frame, with 1,714 pipelines being made and none finishing. The journal's only note was a suspect (compute-3360) pending since launch, at 0 % CPU: it was not compiling at all. Its creation was waiting on another thread that itself needed the gate, which is the cross-thread version of the deadlock fixed in 9bcd755. Even without that, a large compute shader on a cold driver cache takes minutes, and the title waits for the pipelines queued behind it.

The gate is now a mutex and condition variable instead of an RwLock. A suspect holds it alone, or waits to, for at most 5 s, and then the others go ahead. If the run ends after that, the suspect is one of several pipelines being created and stays a suspect instead of being refused. The new test a_slow_suspect_holds_others_up_only_for_a_while checks the bound. pipeline::journal gives 12 passed under Wine, and clippy is clean. #2292 has it merged.

…t's window

f4f3364 restarted the window at every return while a suspect waited, so
a suspect waiting behind a busy queue held every pipeline up again and
again: in the title, 7 pipeline threads slept while 2,200 pipelines
waited, and the queue drained at about 80 a minute. Only the suspect's own
return now starts the next suspect's window.

The new test holds six pipelines, lets a suspect wait, and returns them
one by one: a new pipeline waited 601 ms before this change, under the
300 ms window plus scheduling after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
…t restarted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 25, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@desplmfao

Copy link
Copy Markdown
Contributor Author

A follow-up to f4f3364, in 16200ab: in the title, the 5 s window restarted every time an ordinary pipeline returned while a suspect was waiting. A suspect waiting behind a busy queue therefore held every pipeline up again and again. All 7 pipeline threads slept while 2,200 pipelines waited, and the queue drained at about 80 a minute.

Now only the suspect's own return starts the next suspect's window. The new test a_waiting_suspect_does_not_restart_its_window_as_others_return holds six pipelines, lets a suspect wait, and returns the six one by one. Before this change a new pipeline waited 601 ms; now it waits under 500 ms (a 300 ms window plus scheduling). pipeline::journal gives 13 passed under Wine, and clippy is clean. #2292 has it merged.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@fuzeofficlal

Copy link
Copy Markdown
Contributor

Code review and RTX 5090 + WARP verification at head 16200aba750a merged cleanly onto main (63bcca43c6a0):

  • Concurrency & recovery audit (crates/victory-gpu/src/pipeline/journal.rs, pipeline/host.rs:464-474):
    • Each in-flight pipeline writes its own pending/{key}@{detail}@{pid}-{next} file (zero cross-thread file contention), and Journal::open skips live sibling processes (OpenProcess + STILL_ACTIVE).
    • Single leftover pending note marks crashed.txt tagged with # translator {SOURCE_HASH} (auto-demoting to suspects if the translator changes); multiple leftover notes move to suspects.txt and serialize under Gate with a 5s alone_for timeout and thread-local HOLDS_GATE reentrancy guard to prevent deadlocks.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 192 files ok; cargo clippy -p victory-gpu --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
    • victory-gpu --lib -- pipeline::: 36/36 passed on RTX 5090 (default) and 39/39 passed on WARP (--features diagnostics), including all 11 new journal tests.

LGTM.

desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
GPU diagnostics: a pipeline whose creation faults is refused and the title goes on (opt-in, on Marvisak#491)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
… new base

The renderer README of the old branch (5fff8e0, f44ae53, eb4918e,
9a41398, b673d84, f711b62, 9b32e6f), carried over as one change since
main's README moved under each of them: the renderer section with the run
command (raw access chains off, VICTORY_PIPELINE_JOURNAL=1,
VICTORY_LEVELS_ON_DEMAND=1), and the stack's rows after main's. Adapted:
upstream base 67e8ae1; no Marvisak#2366 row (main's 8ff7913 replaces it), no Marvisak#67
row (not in this rebuild); Marvisak#1152 and Marvisak#2389 kept. The journal and soft-crash
notes (e543c44) and the breadcrumbs row (1f0d6c3) are not repeated:
Marvisak#491's and Marvisak#2292's current heads put them in the variables table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
…journal's gate is taken once per thread

Without it pipeline creation hangs and the title screen runs at 500 ms a
frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
desplmfao added a commit to desplmfao/VIctory that referenced this pull request Nov 26, 2026
The previous renderer (old upstream base 940d32f) is the first parent and
is also kept as the branch renderer-2026-11-25-oldbase; the second parent
is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with
the renderer stack merged on it: Marvisak#439 (on main: update/439-main's
resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292,
Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small
windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes.
Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by
main: Marvisak#1769, Marvisak#1763, Marvisak#2366.

The picture on this base still shows the overlay that plain upstream main
shows too; that is being looked into.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants