Pipeline cache: verify content when accepting a racing publication #2828

Open
github-bot wants to merge 3 commits from github-bot/gh-2828 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 21:35 UTC · original
andrewpozdnakov7-jpg:codex1/concurrent-cache-publication → main · +106 −18 · 1 files · 3 commits · open

#1324 landed as a73d59e and covers the case where another writer publishes the correct cache entry before Windows rejects the rename. This branch keeps that behavior and checks that the existing file contains the converted bytes before accepting it.

The comparison uses bounded chunks on the failure path. An unreadable entry, a different length, or different content leaves the original publishing error available to the caller. The upstream handling of staging write failures is preserved.

  • Same Windows fixture on f3578e3: the identical entry is reused, then an existing XYZ file is incorrectly accepted for output ABC.
  • On 2dacec0: the identical file is reused, and the same-length and longer mismatches return an error. The recorded file is unchanged and staging files are cleaned up.
  • Six paired runs. All eight pipeline tests, crate formatting, strict Clippy, and asset policy passed.

Coordination claim · Windows file sharing rules

Please retain my Git author if moving the follow-up. If you fold the comparison or test extension into another commit, please add the following trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex. Synthetic Windows file test.

Review follow-up

The same Windows fixture on 2dacec0 fails because a second lookup returns the existing XYZ. With b80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes ABC after the reader closes. The next lookup hits ABC; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts.

Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 21:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828) `andrewpozdnakov7-jpg:codex1/concurrent-cache-publication` → `main` · +106 −18 · 1 files · 3 commits · open [#1324](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1324) landed as `a73d59e` and covers the case where another writer publishes the correct cache entry before Windows rejects the rename. This branch keeps that behavior and checks that the existing file contains the converted bytes before accepting it. The comparison uses bounded chunks on the failure path. An unreadable entry, a different length, or different content leaves the original publishing error available to the caller. The upstream handling of staging write failures is preserved. - Same Windows fixture on `f3578e3`: the identical entry is reused, then an existing `XYZ` file is incorrectly accepted for output `ABC`. - On `2dacec0`: the identical file is reused, and the same-length and longer mismatches return an error. The recorded file is unchanged and staging files are cleaned up. - Six paired runs. All eight pipeline tests, crate formatting, strict Clippy, and asset policy passed. [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) · [Windows file sharing rules](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew) Please retain my Git author if moving the follow-up. If you fold the comparison or test extension into another commit, please add the following trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex. Synthetic Windows file test. ## Review follow-up The same Windows fixture on `2dacec0` fails because a second lookup returns the existing `XYZ`. With `b80763c198d6b13ca97e7aa0ee354a6721cf43b0`, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes `ABC` after the reader closes. The next lookup hits `ABC`; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts. Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:16 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:48 UTC · original

Verified f8302c39 on Windows 11:

  • cargo xtask policy: 184 files ok; cargo clippy --locked -p victory-pipeline --all-targets -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-pipeline: 8/8 passed (including an_open_concurrent_cache_entry_wins_only_if_identical).
  • Streaming 8 KiB chunk + length + EOF comparison in same_output cleanly handles concurrent publication without full-file copies and removes &tmp on collision. Clean git merge-tree against origin/main and #2797 (complementary across victory-pipeline and victory-loader).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7175565954) Verified `f8302c39` on Windows 11: - `cargo xtask policy`: 184 files ok; `cargo clippy --locked -p victory-pipeline --all-targets -- -D warnings`: 0 warnings. - `cargo test --locked -p victory-pipeline`: 8/8 passed (including `an_open_concurrent_cache_entry_wins_only_if_identical`). - Streaming 8 KiB chunk + length + EOF comparison in `same_output` cleanly handles concurrent publication without full-file copies and removes `&tmp` on collision. Clean `git merge-tree` against `origin/main` and #2797 (complementary across `victory-pipeline` and `victory-loader`).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 22:23 UTC · original

I resolved the conflict after #1324 landed. 2dacec0 keeps the upstream staging-write behavior and adds the byte check on rename failure.

The same synthetic test on main f3578e3 accepts XYZ where ABC was converted. The update reuses the identical file and rejects both mismatch controls. Six paired runs, eight pipeline tests, strict Clippy, formatting, and asset policy passed. The prior verified commit stays in the branch history.

Please preserve Git authorship if moving the comparison or test extension. If squashing it into another commit, please add this trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 22:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7176293057) I resolved the conflict after #1324 landed. [2dacec0](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/2dacec0bf9f6358fda302af5315f36d4fff1fbc6) keeps the upstream staging-write behavior and adds the byte check on rename failure. The same synthetic test on main `f3578e3` accepts `XYZ` where `ABC` was converted. The update reuses the identical file and rejects both mismatch controls. Six paired runs, eight pipeline tests, strict Clippy, formatting, and asset policy passed. The prior verified commit stays in the branch history. Please preserve Git authorship if moving the comparison or test extension. If squashing it into another commit, please add this trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 23:15 UTC · original

Follow-up to the retry review in b80763c.

The same Windows fixture on 2dacec0 fails because a second lookup returns the existing XYZ. With b80763c198d6b13ca97e7aa0ee354a6721cf43b0, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes ABC after the reader closes. The next lookup hits ABC; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts.

Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy.

Please preserve the Git author if cherry-picking the fix or test. If folding either into another commit, please include Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 23:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7177321029) [Follow-up to the retry review](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2828) in [b80763c](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b80763c198d6b13ca97e7aa0ee354a6721cf43b0). The same Windows fixture on `2dacec0` fails because a second lookup returns the existing `XYZ`. With `b80763c198d6b13ca97e7aa0ee354a6721cf43b0`, a separately opened cache declines both mismatches while the reader blocks replacement, then publishes `ABC` after the reader closes. The next lookup hits `ABC`; the identical-output control still hits without conversion. An empty companion marker adds a file-presence check to hits. Byte comparison is confined to failed rename attempts. Six successful runs, all eight pipeline tests and four GPU shader-cache tests passed, plus formatting, strict pipeline Clippy, and policy. Please preserve the Git author if cherry-picking the fix or test. If folding either into another commit, please include `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:23 UTC · original · edited 2026-11-26 03:23 UTC

Automated triage for the maintainers.

Verdict: proposed close (was needs work). Thanks for checking the production caller and for the candid answer. As you found, the shader cache keys entries by translator source, encoding, loop limit and container bytes, and on a publication error it already returns the in-memory translation (#2055). There is no known case where two writers publish different bytes for the same key, so the byte comparison and the .invalid marker in Cache::get_or_convert (crates/victory-pipeline/src/cache.rs) guard a case that does not occur, at the cost of an extra try_exists() on every hit. #1324's behaviour in main stays as is, which matches your own suggestion to defer.

This will be closed in 48 hours unless you push a change (for example, with a real case where the contents differ) or a maintainer removes the label.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7180753076) · edited 2026-11-26 03:23 UTC <!-- victory-triage v1 head=b80763c198d6b13ca97e7aa0ee354a6721cf43b0 verdict=proposed-close at=2026-11-26T03:23:55Z --> Automated triage for the maintainers. **Verdict: proposed close** (was needs work). Thanks for checking the production caller and for the candid answer. As you found, the shader cache keys entries by translator source, encoding, loop limit and container bytes, and on a publication error it already returns the in-memory translation (#2055). There is no known case where two writers publish different bytes for the same key, so the byte comparison and the `.invalid` marker in `Cache::get_or_convert` (`crates/victory-pipeline/src/cache.rs`) guard a case that does not occur, at the cost of an extra `try_exists()` on every hit. #1324's behaviour in `main` stays as is, which matches your own suggestion to defer. This will be closed in 48 hours unless you push a change (for example, with a real case where the contents differ) or a maintainer removes the label. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:29 UTC · original

Thanks for flagging the hot-path cost. I checked the production caller on 63bcca4: the shader cache keys entries by the translator source, encoding, loop limit, and container bytes. On a publication error it already returns the in-memory translation. The Windows test creates a mismatched entry deliberately while a reader holds it open. I have no production case where two conversions with that same key produce different bytes.

The two reviews identify a trade-off. The failure-only comparison in 2dacec0 has no extra I/O on hits, but the same test then returns the mismatched file on a second lookup. b80763c covers that retry at the cost of the marker check on each hit. With no observed production case, I'd leave #1324 as the current behavior and defer this follow-up until there's evidence that the retry case matters.

If you use the comparison or the Windows fixture later, please retain the original Git author. For a combined commit, please use:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 02:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2828#issuecomment-7180850949) Thanks for flagging the hot-path cost. I checked the production caller on `63bcca4`: the shader cache keys entries by the translator source, encoding, loop limit, and container bytes. On a publication error it already returns the in-memory translation. The Windows test creates a mismatched entry deliberately while a reader holds it open. I have no production case where two conversions with that same key produce different bytes. The two reviews identify a trade-off. The failure-only comparison in `2dacec0` has no extra I/O on hits, but the same test then returns the mismatched file on a second lookup. `b80763c` covers that retry at the cost of the marker check on each hit. With no observed production case, I'd leave #1324 as the current behavior and defer this follow-up until there's evidence that the retry case matters. If you use the comparison or the Windows fixture later, please retain the original Git author. For a combined commit, please use: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2828/head:github-bot/gh-2828'
git switch 'github-bot/gh-2828'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2828'
git switch 'github-bot/gh-2828'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2828'
git switch 'github-bot/gh-2828'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2828'
git switch 'main'
git merge --squash 'github-bot/gh-2828'
git switch 'main'
git merge --ff-only 'github-bot/gh-2828'
git switch 'main'
git merge 'github-bot/gh-2828'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2828
No description provided.