feat(build): one shader that crashes or hangs the GPU driver costs the preparation that shader, not the whole run #2323
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2323
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:feat/prepare-supervisor-continued"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This continues pull request #1334 by HumanBean. Its shader-preparation supervisor was a second topic that rode in with the trace replay, so it is offered here on its own, on current
main. HumanBean's commit is kept under their name, with follow-up fixes on top, and was taken to currentmain(it applied without a conflict). It was done with AI agents under TrashPanda's direction, and it is offered to HumanBean to take, fold back into #1334 or supersede with their own, as they prefer. The trace replay half is in a second branch,feat/trace-replay-continued.What it does (HumanBean's description, shortened): the preparation a build runs after it (
longshot --prepare-shaders) kept all or nothing, so one shader that crashed or hung the GPU driver lost the whole run. The run now keeps a journal of each driver compile;nx2/prepare_supervisor.pyreads it when the run dies, hangs or passes a limit on one entry, identifies the program that was inside the driver, serializing calls on a retry when several programs were active. It quarantines crashed programs for that driver version (cache/longshot_driver_faults.txt), skips timed-out programs for this preparation only, and starts again past them. An incomplete journal stops diagnosis without attributing the run.docs/dev/reference/shader-preparation.mdhas the whole of it. Read first:nx2/prepare_supervisor.py,gpu/vk/prepare_journal.h,gpu/vk/vk_draw.cpp(the journal entries),docs/dev/reference/shader-preparation.md.Does it stand alone? Yes: it shares nothing with the trace but rows in
gpu/vk/switches.defand the docs index, which merge as they are. The suite, with and without it, differs by its two new checks only.Testing
Tested on the earlier head: by the agents, Linux, this PC (RTX 4070 Ti):
python -I -B tests/run_all.pythroughsuite.py compareagainstmainat753fb5af: 930 passed, 3 failed, 26 skipped on the branch; 928 passed, 3 failed, 26 skipped onmain; no check fails only on the branch;tests/test_prepare_journal.pyandtests/test_prepare_supervisor.pyare the two new ones and pass. Not run here, and not repeated on this head: a build's preparation in the game, the forced crash and hang HumanBean ran (see Measurements).Still to test:
RX_VK_TEST_PREPARE_FAULT=crash:5000, thenhang:5000, expecting the preparation to finish and the game to log how many programs the driver faulted on (by hand).@Beanstalkon the pull request).Measurements
Verdict: HumanBean's, from #1334 on an RTX 3090, not repeated on this head: a clean run journalled 259,795 entries; five programs forced to crash were each named over 11 runs and quarantined; a forced hang was stopped at its 20 s limit, and the game then logged
5 programs the driver faulted on in earlier runs are not asked of itand played.Setup: HumanBean's, RTX 3090, NVIDIA 620.70. Switches it adds, and the default each ships at:
LONGSHOT_PREPARE_JOURNAL,LONGSHOT_PREPARE_SKIP,LONGSHOT_PREPARE_FROMandLONGSHOT_PREPARE_ONLYare unset (the journal and the supervisor's help are off in a game run; the supervisor sets the first three for the run it starts,--prepare-shadersthe last), andLONGSHOT_PREPARE_ENTRY_Sis unset, meaning no limit on one driver call unless--prepare-entry-limitgives one (the supervisor passes 240 s). Nothing was measured by the agents for this branch; the speed of an ordinary preparation is unmeasured (the journal is off unless the supervisor asks for it).753fb5af6841e3e3cf(HumanBean's numbers, earlier head)Risks
A slow but finite compile is left out (the 240 s limit;
LONGSHOT_PREPARE_ENTRY_S=0turns it off), and a program can be blamed wrongly; the quarantine file iscache/longshot_driver_faults.txt, safe to delete. The preparation's exit codes 6 and 7 are new. A revert is enough; nothing in a player's saves or options changes.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named): the earlier head had 3 failures that also failed onmain; not repeated on this head.main, or Measurements says why there is nothing to measure. Not ticked: HumanBean's measurement is not repeated here.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Possibly related, for context:
841e3e3cff7f0c9fa35b@review
Recommendation: Request changes. The supervisor can permanently exclude working programs, including a known finite Intel compile and programs merely running beside the actual crash. Its file error handling can also turn an incomplete journal into a false quarantine.
The change journals shader compiler calls and retries preparation after excluding a suspected program. It could let builds recover from driver crashes and hangs, but a mistaken exclusion removes that program's draws during play until the fault list is cleared or the driver changes.
Blocking (3): must change before merging.
nx2/prepare_supervisor.py:43: The default timeout permanently quarantines a shader simply because its compile takes more than 240 seconds. (more on the line) Do: Do not persistently quarantine a program solely for exceeding this unvalidated time limit; use a safe policy for slow finite compiles and test it on the affected hardware.nx2/prepare_supervisor.py:183: Serializing only the previous suspects does not establish that the one open suspect caused the next crash. (more on the line) Do: Isolate the candidate driver calls from all other calls during diagnosis, or avoid quarantining a candidate until the failing call is unambiguously identified.gpu/vk/prepare_journal.h:163: Journal write and flush failures are ignored, so the supervisor can mistake a completed call for the call that killed the process. (more on the line) Do: Detect and propagate journal write and flush failures, and disable attribution and persistent quarantine when the journal is incomplete.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Reduce or batch journal I/O while preserving enough durable information to identify an interrupted call.)@fixcan do L1, L2, L3 and L5.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on this head. The PR reports 5 of 5 forced crashes identified over 11 runs and one forced hang stopped on an earlier head with an RTX 3090; the branch itself has not had a game preparation or forced-fault run.
Other systems: The supervisor runs during Builder and development-runtime preparation on Windows and Linux, and its fault list affects subsequent gameplay on the same driver. NVIDIA, AMD, Intel and Steam Deck behavior on this head is not established; the PR also reports an Intel compile that exceeds the new default limit.
Switches: LONGSHOT_PREPARE_JOURNAL, LONGSHOT_PREPARE_SKIP and LONGSHOT_PREPARE_FROM default unset; LONGSHOT_PREPARE_ENTRY_S defaults unset for a direct game run but the supervisor supplies 240 seconds; RX_VK_TEST_PREPARE_FAULT defaults off. The 240-second supervised default is unsafe for the reported 389-second finite compile. All five have switch-table rows.
Reviewed:
7f0c9fa35bagainst0e32bc100d: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the full supervisor, journal header, argument header, shader-preparation documentation and new tests; inspected the remaining diffs and related renderer, build, cache and fault-list paths. The large existing renderer and build files were read around the changed code and callers, not in full; the full switch table was skimmed. No recorded runs or translations were changed. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the pull request, builds or tests were run, as requested. The supplied CI checks were still running and no head-only failures were reported.
Overlaps and merge order: The PR describes this as extracted from #1334, with a separate trace-replay branch; merge order and current overlap could not be checked without network access.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +160,4 @@};/// One line, written and handed to the system (the header's durability note). Under mu_void put(const char* line) {fwrite(line, 1, strlen(line), f_);L3 (blocking): Journal write and flush failures are ignored, so the supervisor can mistake a completed call for the call that killed the process.
When: If the disk fills after a begin line is flushed, its end line can be lost. A later unrelated process crash leaves that earlier entry apparently open, and the supervisor writes its working program to the persistent fault list.
Do: Detect and propagate journal write and flush failures, and disable attribution and persistent quarantine when the journal is incomplete.
@ -0,0 +40,4 @@# (seconds one driver call gets. Below the run's own 300 s with nothing moving, so that a stuck shader is named before the# whole run is given up; LONGSHOT_PREPARE_ENTRY_S in the Builder's environment sets another, 0 none)ENTRY_LIMIT_S = 240L1 (blocking): The default timeout permanently quarantines a shader simply because its compile takes more than 240 seconds.
When: On the UHD system reported in the PR, a compile that completes in 389 seconds is killed at 240 seconds and its program is added to the driver fault list. Later gameplay skips that program's draws even though the driver would have completed it.
Do: Do not persistently quarantine a program solely for exceeding this unvalidated time limit; use a safe policy for slow finite compiles and test it on the affected hardware.
@ -0,0 +180,4 @@narrowed = [k for k in keys if k in self.suspects] or keysif len(narrowed) > 1: # (several threads were inside the driver: built one at a time, the next death names one)self.suspects = narrowedreturn self._restart()L2 (blocking): Serializing only the previous suspects does not establish that the one open suspect caused the next crash.
When: After programs A and B are open during a crash, the retry serializes A and B but permits unrelated C to compile concurrently. If C crashes while A is open, the intersection selects A and permanently excludes its draws, while C remains able to crash the next run.
Do: Isolate the candidate driver calls from all other calls during diagnosis, or avoid quarantining a candidate until the failing call is unambiguously identified.
@fix
7f0c9fa35be2911d5b81Recommendation: Approve. The code is ready: only testing is left. The recovery feature has evidence from an earlier head, but it has not been exercised on this head on the Windows and Linux systems it affects. The cost of journaling during ordinary preparation is also unmeasured. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
e2911d5b81. I rebased it ontomain(59f9632bef). I edited its description to match the change.Changed
Not done
Nothing was built or run: the checks run again on the new head.
The supervisor attempts to preserve shader preparation after a driver crash or hang by identifying and skipping the offending program. It adds journal I/O to every supervised compiler call and serializes calls during diagnosis.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven on this head. On an earlier head, the author reported five forced crashes identified over 11 runs and one forced hang stopped; ordinary preparation cost was not measured.
Other systems: The change affects shader preparation on Windows and Linux across GPU drivers. Windows crash handling, Intel's slow compiles, and ordinary preparation time still need validation; the documented 240-second limit can skip a finite compile.
Switches: LONGSHOT_PREPARE_JOURNAL, LONGSHOT_PREPARE_SKIP, LONGSHOT_PREPARE_FROM and LONGSHOT_PREPARE_ONLY default to unset; the supervisor supplies the first three as needed and preparation supplies the last. LONGSHOT_PREPARE_ENTRY_S defaults to unset, with a 240-second supervisor default; its suitability on slow hardware remains unverified. RX_VK_TEST_PREPARE_FAULT defaults to unset and is for testing.
Reviewed:
e2911d5b81against59f9632bef: Read AGENTS.md, CONTRIBUTING.md, the pull request template, gpu/vk/prepare_journal.h and nx2/prepare_supervisor.py in full. Inspected the fix diff, relevant vk_draw.cpp and make_game.py paths, and the commit list; the remaining changed files and the full base diff were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run. CI has not yet run on this head; the reported suite and driver runs are from earlier heads.
Overlaps and merge order: The description identifies #1334 as the source of this work; its intended relationship and merge order need maintainer coordination.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
WIP: feat(build): one shader that crashes or hangs the GPU driver costs the preparation that shader, not the whole runto feat(build): one shader that crashes or hangs the GPU driver costs the preparation that shader, not the whole run