Retry incomplete pipeline book writes and flush on orderly exit #63

Manually merged
github merged 2 commits from github-bot/gh-63 into main 2026-11-26 08:21:46 +00:00 AGit
Owner

@⁠Yoshi-233 on GitHub · 2026-11-26 01:14 UTC · original
Yoshi-233:fix/pipeline-book-flush-retry → main · +199 −21 · 7 files · 2 commits · merged 2026-11-26 08:17 UTC

Fixes #41.

On 0a43566, I forced either cache file to fail to open, removed the obstruction, and submitted the same pipeline again followed by a second one. The book remembered both keys, but only the second pipeline made it to disk. When the pipeline file was blocked, the first shader had already been appended.

The writer now tracks the bytes each file actually accepted. A failed flush puts the unwritten suffix ahead of records noted during I/O. The timer and final save serialize their appends, and the title can continue recording pipelines while the disk is busy. The existing on-disk format and deduplication keys are preserved.

The last batch is also flushed when the title's main thread returns, before CRT teardown stops the other threads, and through the existing lifecycle save. The CRT hook runs under the existing shutdown watchdog. For fatal GPU errors, the runtime writes its crash report first, then wakes the existing book writer and waits up to 250 ms for the attempt before calling TerminateProcess. The failing thread never acquires the book or writer lock. A stalled write or an external process kill can still lose the last batch. Thanks to sharan104 for suggesting the device-loss case in #88.

Verification

  • Repeated both file-open failures on Linux in a CPU-only harness using the production recording, flush and readback functions with synthetic shader data. Before the change both runs read back pipeline IDs [2]. With the change both read back [1, 2] and exactly two shader records, matching the no-failure control.

  • Exercised a short write and retry. Also blocked a 2 MiB shader append on a Linux pipe, noted another pipeline while that write was pending, then failed the pipeline-file open. Both records were readable in order after retry. The two regression tests included in this PR and the extra pipe check passed in the harness.

  • Rust 1.98.1: cargo check --target x86_64-pc-windows-gnu --locked --tests -p victory-gpu -p victory-loader -p victory passed. The native Linux GPU and loader test binaries still hit the same Windows-only symbol errors as on the base commit. Windows shutdown and an actual game run remain untested here.

  • For the fatal-path follow-up (33439c8), I ran a Linux subprocess harness using the production book and writer with synthetic shaders. After the flush request the child exited immediately. A second process recovered both pipeline IDs and shader hashes in 20/20 healthy runs and 8/8 runs after a transient pipeline-file open failure. With a blocked file write (5 runs) or the book lock held by the caller (5 runs), the new hook returned in 250.1–250.3 ms. I also checked the regular two-second timer and the disabled and uninitialized cases.

  • The Windows GNU target passed cargo check --locked --tests for the affected crates in default and diagnostics builds. Actual Windows device removal has not been exercised.

AI-assisted implementation and testing with Codex.

**@⁠Yoshi-233** on GitHub · 2026-11-26 01:14 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/63) `Yoshi-233:fix/pipeline-book-flush-retry` → `main` · +199 −21 · 7 files · 2 commits · merged 2026-11-26 08:17 UTC Fixes #41. On `0a43566`, I forced either cache file to fail to open, removed the obstruction, and submitted the same pipeline again followed by a second one. The book remembered both keys, but only the second pipeline made it to disk. When the pipeline file was blocked, the first shader had already been appended. The writer now tracks the bytes each file actually accepted. A failed flush puts the unwritten suffix ahead of records noted during I/O. The timer and final save serialize their appends, and the title can continue recording pipelines while the disk is busy. The existing on-disk format and deduplication keys are preserved. The last batch is also flushed when the title's main thread returns, before CRT teardown stops the other threads, and through the existing lifecycle save. The CRT hook runs under the existing shutdown watchdog. For fatal GPU errors, the runtime writes its crash report first, then wakes the existing book writer and waits up to 250 ms for the attempt before calling `TerminateProcess`. The failing thread never acquires the book or writer lock. A stalled write or an external process kill can still lose the last batch. Thanks to sharan104 for suggesting the device-loss case in #88. **Verification** - Repeated both file-open failures on Linux in a CPU-only harness using the production recording, flush and readback functions with synthetic shader data. Before the change both runs read back pipeline IDs `[2]`. With the change both read back `[1, 2]` and exactly two shader records, matching the no-failure control. - Exercised a short write and retry. Also blocked a 2 MiB shader append on a Linux pipe, noted another pipeline while that write was pending, then failed the pipeline-file open. Both records were readable in order after retry. The two regression tests included in this PR and the extra pipe check passed in the harness. - Rust 1.98.1: `cargo check --target x86_64-pc-windows-gnu --locked --tests -p victory-gpu -p victory-loader -p victory` passed. The native Linux GPU and loader test binaries still hit the same Windows-only symbol errors as on the base commit. Windows shutdown and an actual game run remain untested here. - For the fatal-path follow-up (`33439c8`), I ran a Linux subprocess harness using the production book and writer with synthetic shaders. After the flush request the child exited immediately. A second process recovered both pipeline IDs and shader hashes in 20/20 healthy runs and 8/8 runs after a transient pipeline-file open failure. With a blocked file write (5 runs) or the book lock held by the caller (5 runs), the new hook returned in 250.1–250.3 ms. I also checked the regular two-second timer and the disabled and uninitialized cases. - The Windows GNU target passed `cargo check --locked --tests` for the affected crates in default and diagnostics builds. Actual Windows device removal has not been exercised. AI-assisted implementation and testing with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:31:40 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:55 UTC · original

Merged into main in the next push (tests pass); thanks.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:55 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/63#issuecomment-7185990798) Merged into main in the next push (tests pass); thanks.
github manually merged commit 15f1a48e85 into main 2026-11-26 08:21:46 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.