fix: parallel shadow scan cuts no lower than its own start #389

Manually merged
github merged 1 commit from github-bot/gh-389 into main 2026-11-27 00:34:58 +00:00 AGit
Owner

@⁠LooperSalty on GitHub · 2026-11-26 15:25 UTC · original
LooperSalty:fix/parallel-scan-boundary → main · +34 −2 · 2 files · 2 commits · merged 2026-11-26 23:17 UTC

Bug fix taken from stellarr-studio/kelvaroq (patch 0009, at their commit 1270c42), credited as rule 10 asks (Source: and Co-authored-by: in the message, a row in THIRD_PARTY.md).

The bug

Shadow::differing splits a span into pieces that several threads scan in parallel. When the span starts in the middle of a piece (a buffer at an odd address), the first cut was rounded down below the span's own start. The first thread then scanned nothing, or the cut walked back, so the changed bytes at the start of such a buffer could be missed.

The fix

Cuts are clamped to the span's start. A new test, unaligned_parallel_scan_covers_the_first_piece, fails without the change: a span that starts mid-piece, with a change in its first bytes, must be found.

No switch: this is a bug fix.

Test plan

  • cargo test --release -p victory-gpu on the porting branch: 245 passed; only the 3 WARP tests that also fail on main fail
  • cargo xtask policy: 216 files ok
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox

**@⁠LooperSalty** on GitHub · 2026-11-26 15:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/389) `LooperSalty:fix/parallel-scan-boundary` → `main` · +34 −2 · 2 files · 2 commits · merged 2026-11-26 23:17 UTC Bug fix taken from `stellarr-studio/kelvaroq` (patch `0009`, at their commit `1270c42`), credited as rule 10 asks (`Source:` and `Co-authored-by:` in the message, a row in `THIRD_PARTY.md`). ## The bug `Shadow::differing` splits a span into pieces that several threads scan in parallel. When the span starts in the middle of a piece (a buffer at an odd address), the first cut was rounded down below the span's own start. The first thread then scanned nothing, or the cut walked back, so the changed bytes at the start of such a buffer could be missed. ## The fix Cuts are clamped to the span's start. A new test, `unaligned_parallel_scan_covers_the_first_piece`, fails without the change: a span that starts mid-piece, with a change in its first bytes, must be found. No switch: this is a bug fix. ## Test plan - [x] `cargo test --release -p victory-gpu` on the porting branch: 245 passed; only the 3 WARP tests that also fail on `main` fail - [x] `cargo xtask policy`: 216 files ok - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
Shadow::differing cut a span on 64 KiB piece boundaries with
`at - (start + at) % PIECE`, which runs below the span's start (and wraps)
when the span begins inside a piece, e.g. a buffer at an odd address:
the first thread then scanned nothing. Cut with scan_boundary, which
stops at the span's start. Test covers unaligned starts and spans.

Source: stellarr-studio/kelvaroq 0009-shadow-compare (1270c42)
Co-authored-by: Stellarr Studio <[email protected]>

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
(cherry picked from commit 4d8a57c3bad98a2f41c33d1e69e20becf398aee1)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:26:27 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 15:25 UTC · original

Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T15:25:17.215027Z
We couldn’t complete this review. Comment @codex review to try again.
8d91ca9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 15:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/389#issuecomment-7196243103) <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8d91ca933f2f69d6ab405825955e275c42bf2af6","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ❌ Failed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ❌ **Failed** <relative-time datetime="2026-11-26T15:25:17.215027Z">2026-11-26T15:25:17.215027Z</relative-time><br/>We couldn’t complete this review. Comment `@codex review` to try again. | `8d91ca9` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 15:25 UTC · original

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 15:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/389#issuecomment-7196244667) You have reached your Codex usage limits for code reviews. You can see your limits in the [Codex usage dashboard](https://chatgpt.com/codex/cloud/settings/usage). To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your [settings](https://chatgpt.com/settings/code-review).
Author
Owner

@⁠Lewandox on GitHub · 2026-11-26 16:40 UTC · original · approved these changes

Reviewed scan_boundary, its caller in Shadow::differing, the new unaligned_parallel_scan_covers_the_first_piece test, and the THIRD_PARTY.md attribution:

  • at.saturating_sub((start + at) % PIECE).max(from) eliminates the underflow/wrap that occurred when from < (start + from) % PIECE (e.g. from == 0 on an unaligned buffer), where at - (start + at) % PIECE wrapped in release builds and caused the first thread to see a > b and skip the opening piece.
  • For i > 0, at >= from + PER_THREAD (16 MiB >> PIECE), so every interior cut lands on a piece boundary >= from, and cuts stays strictly monotonic with cuts[0] == from and cuts[threads] == to.
  • THIRD_PARTY.md credits stellarr-studio/kelvaroq (1270c42) cleanly and CI is 4/4 green.

Looks good to merge!

**@⁠Lewandox** on GitHub · 2026-11-26 16:40 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/389#pullrequestreview-6077701694) · **approved these changes** Reviewed `scan_boundary`, its caller in `Shadow::differing`, the new `unaligned_parallel_scan_covers_the_first_piece` test, and the `THIRD_PARTY.md` attribution: - `at.saturating_sub((start + at) % PIECE).max(from)` eliminates the underflow/wrap that occurred when `from < (start + from) % PIECE` (e.g. `from == 0` on an unaligned buffer), where `at - (start + at) % PIECE` wrapped in release builds and caused the first thread to see `a > b` and skip the opening piece. - For `i > 0`, `at >= from + PER_THREAD` (`16 MiB >> PIECE`), so every interior cut lands on a piece boundary `>= from`, and `cuts` stays strictly monotonic with `cuts[0] == from` and `cuts[threads] == to`. - `THIRD_PARTY.md` credits `stellarr-studio/kelvaroq` (`1270c42`) cleanly and CI is 4/4 green. Looks good to merge!
github manually merged commit b39dd67ca1 into main 2026-11-27 00:34:58 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.