Skip to content

fix(runtime): publish pipeline checker progress snapshots atomically - #3163

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
matheuskshn:fix/atomic-pipeline-inflight
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
matheuskshn:fix/atomic-pipeline-inflight

Conversation

@matheuskshn

Copy link
Copy Markdown
Contributor

Changes

Write the complete --inflight-file snapshot through the existing checkpoint writer, then replace the previous report. If staging or replacement fails, the last full report remains available and the error is logged. This follows #2111 and keeps the report format and publication points.

Validation

Windows 11, native Clang 23.1.5, RTX 4070 Ti, NVIDIA 621.24. With one synthetic compute pipeline and an open reader sharing write but not delete access, the original checker erased the report; the patched checker left the previous bytes intact, reported the replacement error, and still compiled the pipeline. With no lock, the patched checker published the final empty report. No staging files remained in either run. Native pipeline_cache_file_test and the CMake checker CLI tests also passed.

Coordination claim. AI-assisted (Codex).

Stage the full in-flight report before replacing its destination, using the existing checked checkpoint writer. Preserve the last complete snapshot if staging or replacement fails.
@daemosofchaos

Copy link
Copy Markdown
Contributor

Independent Windows 11 26300 / MSVC 19.52 / RTX 5070 Ti, NVIDIA 621.24 check of f674ba82, using one hand-written compute shader.

With the previous in-flight report open for shared read/write but not delete, base 16282101 erased it; this PR retained its bytes and logged replacement errors, while the synthetic pipeline completed in both cases. With the lock removed, the PR published the final empty report; no staging files remained. A nonexistent report parent also logged the error without preventing the pipeline.

pipeline_cache_file, vk_pipeline_check_cli and all seven index tests passed. Windows only; no game files were used.

— LocalFirst-AI

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested f674ba8 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 130/130.
  • Warnings: none new in the files this PR changes.

AI-assisted (Claude Code).

@matheuskshn

Copy link
Copy Markdown
Contributor Author

I also checked end-to-end recovery on Windows 11 with #3163, #3234, and #3304 combined on f847748c, using the RTX 4070 Ti (driver 621.24) and two hand-written compute fixtures. With eight workers requested, make_game.pipelines started two. The checker’s built-in simulated FPE interrupted one shader. Recovery reported only that shader, compiled the other, saved a 17,394-byte cache, and removed both the in-flight report and its staging files. The overall stage still returned failure for the shader that actually failed. This covers the recovery path in addition to the file-sharing case above.

AI-assisted verification (Codex).

@maxhurst131

Copy link
Copy Markdown
Contributor

Independent GPU check, AI-assisted, NVIDIA RTX 5070.

Environment: Windows 11 build 26300, Vulkan SDK 1.4.363.0, MSVC RelWithDebInfo, llvm-mc 21.1.8 (WSL Ubuntu), python -I scripts/run_gpu_tests.py.

Ran the full synthetic GPU test suite (189 tests) on commit a4eb501 (test/line-endings-update-mode) with LEONIDA_VK_DEVICE=NVIDIA:

143/189 passed, 46 skipped

Passes include: ps_sdwa_f16_const, ps_sdwa, ps_sff_imm, ps_ssharp, ps_tex, ps_texoff, ps_texture_, ps_uniform_branch, ps_valu16_, ps_vcc_x2, ps_vcmpx_forms, ps_vop3_const_mods, vs_clip*, vs_m15/m2/m3 (skipped), ps_w64x_readlane (skipped - needs 64-wide fragment subgroup), ps_wqm, etc.

Skipped tests: those requiring 64-wide fragment subgroup (device has 32-only subgroups), vs_m15/m2/m3 (d3d12 tests), and a few others.

No game files used; counts only. The test suite is the repository's own hand-written programs (runtime/test/shaders), so no game shaders or logs quoting them are included.

For PR #3163 (fix(runtime): publish pipeline checker progress snapshots atomically), the GPU test suite runs the translator and checks SPIR-V validity + GPU execution. The above results represent the baseline on this hardware/driver against which any translator changes can be measured.

Caveat: 46 tests were skipped, mostly due to the device's 32-wide subgroup limit vs. the test suite's 64-wide requirements. Comparisons against earlier commits or other GPUs should account for this.

No game files used; counts only.

@umnitus

umnitus commented Nov 22, 2026

Copy link
Copy Markdown

Independent Windows check at f674ba8 with one synthetic compute module on an RTX 3060.

With the --inflight-file report open for reading without delete sharing, the checker logged "Access is denied", exited 0, and preserved the previous report byte-for-byte. After I released the lock, it exited 0 and published the expected empty final snapshot. pipeline_cache_file and vk_pipeline_check_cli both passed.

AI-assisted testing and write-up.

@zzEmmazz

Copy link
Copy Markdown
Contributor

Tested f674ba82, applied alone on main 16282101: one finding.
Windows 11 (26200), MSVC 14.50 (VS 2026), Ninja RelWithDebInfo. Two GPUs: Ryzen 7 9700X iGPU (RDNA2, AMD 32.0.21042.62) and RTX 3070 (NVIDIA 610.74), picked with LEONIDA_VK_DEVICE.

Input: the 96 synthetic compute modules that run_gpu_tests.py --filter cs_ leaves in <work>/spirv, checked with vk_pipeline_check <spirv> --stage cs --jobs 2 --large-module-bytes 1 --inflight-file F, so F is rewritten around every module (about 300 writes per run). Numbers are RTX 3070 / Radeon.

  • Normal run: exit 0, 96/96 pipelines, F empty at the end, no .tmp. staging file left. Same as main.
  • VK_PIPELINE_CHECK_SIMULATE_CRASH=<one module>: exit 3 and F holds one line naming that module, on main and with the change. The line now ends in LF (20 bytes) where main wrote CRLF (21 bytes); read_names in make_game.py strips either.
  • A reader re-reading F in a loop, sharing read, write and delete, during 3 runs: 0 partial lines in 16,034 / 14,543 reads, 0 failed saves. Main also showed 0 partial lines (2,159 / 1,149 reads), so I could not show a torn read on main with a file this small.
  • A reader re-opening F in a loop without delete sharing (what Python's open() does on Windows), 3 runs: exit 0; 0 / 1 failed saves; 4.1-4.7 s / 5.4-6.9 s per run, against 1.1-1.5 s / 0.6-0.7 s on main.
  • Finding: a reader that keeps F open without delete sharing for the whole run. Main rewrites F in place: exit 0 in 0.9 s / 0.6 s and F is empty at the end. With the change every save fails (301 lines in-flight snapshot save to ... failed: Access is denied.), the run takes 67.1 s / 75.8 s, and F still holds the line it had before the run. Each failed save spends its 8 x 25 ms rename retries in write_pipeline_cache_file while write_inflight holds mu, so the workers wait behind it.
  • The same reader plus the simulated crash: on main F names the module that crashed (exit 3 after 1.2 s / 0.6 s). With the change F still names the module from before the run, not the one that crashed (exit 3 after 68.7 s / 73.9 s, 293 / 294 failed saves). Read, not run: make_game.py would then write that stale name to pipeline_crashes.txt. It deletes F before the run and reads it only after the checker has exited, so this needs a third program holding F (a viewer, a scanner).
  • ctest -R "vk_pipeline_check_cli|pipeline_cache_file|pipeline_cache_snapshot": 3/3 pass. python -I tests/test_make_game_pipelines.py: 11 tests OK.

Not checked: a real driver crash, the translated corpus, Linux and Wine.

@TreXito

TreXito commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested f674ba82 (base 16282101) on NVIDIA GeForce RTX 3060 Ti (Ampere), driver 580.173.02 (Vulkan 1.4.312), Linux (Ubuntu 26.04 container on a TrueNAS 26.0 host, ext4-backed volume): pass, with one behaviour change to be aware of. This adds a Linux data point to the Windows run in the description.

vk_pipeline_check <194 translated modules> cache.bin --jobs 6 --inflight-file F, with F pre-filled with OLD<TAB>module, a descriptor on F held open by the shell, and a poller reading F in a loop during the run:

base 16282101 this head
exit code 0 0
F at the end empty (final report) empty (final report)
lines read by the poller / malformed 1350 / 0 913 / 0
the descriptor opened before the run reads (nothing, the file was truncated in place) OLD<TAB>module (the old inode, as expected with rename)
F.tmp.* staging files left 0 0

The behaviour change: a writable F in a folder that is not writable (chmod a-w on the folder only).

  • On main, F was rewritten in place and ended empty.
  • With this PR, staging can't be created there. in-flight snapshot save to .../inflight.txt failed: Permission denied is logged twice, the run still exits 0, and F keeps OLD<TAB>module from before the run.

That matches the description ("the last full report remains available"). make_game.py deletes pipeline_inflight.txt before each run and writes pipeline_cache.bin to the same folder, so it can't reach this case. Someone pointing --inflight-file into a read-only folder by hand would now see a stale entry instead of the final empty report. That seems acceptable to me as long as the log line stays.

AI-assisted (Claude Code). Synthetic test shaders only, no game files.

@iurysf

iurysf commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested f674ba82 on RTX 4070 (NVIDIA 621.01), Windows 11 (10.0.26300), MSVC 14.44, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, RelWithDebInfo: pass.

  • Full ctest -C RelWithDebInfo --output-on-failure: 121 passed, 0 failed, 8 skipped and gameinput disabled, identical to base ec8ec4c9 (no game files, no LEONIDA_VK_VALIDATION, no RGB9E5 render targets here, no SDL3). vk_pipeline_check_cli, pipeline_cache_file and pipeline_cache_snapshot pass; no new build warnings.
  • Reproduction with one synthetic compute module (an empty OpEntryPoint GLCompute, assembled with spirv-as, no game data), --inflight-file preloaded with PREVIOUS_REPORT<TAB>module, and a reader holding the file open with FileShare.ReadWrite (no delete share): base ec8ec4c9 leaves the report at 0 bytes; this head keeps the 23 previous bytes, logs in-flight snapshot save ... failed: Access is denied., still compiles the pipeline (1 ok, 0 failed) and leaves no staging file. Without the reader, both publish the same final empty report.

Not tested: a driver crash during publication, real game shaders, other GPUs, clang-cl. Tested with AI assistance (Claude).

@crastinator

Copy link
Copy Markdown
Contributor

Tested f674ba8 merged into main f847748c (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • Whole run_gpu_tests.py: 185/199 native, 185/199 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 41/41.

No game files. AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 272ff05 into ItsNotRexed:main Nov 22, 2026
2 of 4 checks passed
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.

10 participants