Reuse changed-byte runs across shadow pages #924

Open
alpz1000 wants to merge 3 commits from upstream-pr/925 into main
alpz1000 commented 2026-11-25 13:01:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by alpz1000 on 2026-11-25T13:01:36Z.


Shadow::merge_under_writes builds a new vector of changed-byte runs for every stale page. The optional gap pass can allocate a second vector, and the diagnostic counters take two atomic updates for every run.

This patch reuses one run vector across pages, joins optional gaps in place, and updates the run and byte counters once per page. It preserves both upstream scan implementations, including the newer SIMD path. The default gap of zero still sends the exact changed bytes. The per-submission run cap is checked before modifying the card-backed page.

Validation on Windows with an i5-8400

  • Merged upstream 9c184b3 and ran cargo test --profile diag --locked -p victory-gpu --features diagnostics --lib merge_tests. All seven matching tests passed, including upstream’s byte-by-byte reference test for the SIMD scan and the test that reuses one scratch buffer across joined, exact, and unchanged pages.
  • A synthetic scan-only comparison against upstream’s SIMD scan checked identical output on 1,024 generated 4 KiB pages per pattern. At -C opt-level=2, medians of 17 alternating batches went from 368 to 322 ns per unchanged page, 414 to 365 ns per sparse page, 1,412 to 1,156 ns per fragmented page, and 548 to 475 ns per dense page. Gap was zero. The benchmark covers scanning and allocation.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6605074954 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/925). Originally posted by [alpz1000](https://github.com/alpz1000) on 2026-11-25T13:01:36Z. --- `Shadow::merge_under_writes` builds a new vector of changed-byte runs for every stale page. The optional gap pass can allocate a second vector, and the diagnostic counters take two atomic updates for every run. This patch reuses one run vector across pages, joins optional gaps in place, and updates the run and byte counters once per page. It preserves both upstream scan implementations, including the newer SIMD path. The default gap of zero still sends the exact changed bytes. The per-submission run cap is checked before modifying the card-backed page. Validation on Windows with an i5-8400 - Merged upstream `9c184b3` and ran `cargo test --profile diag --locked -p victory-gpu --features diagnostics --lib merge_tests`. All seven matching tests passed, including upstream’s byte-by-byte reference test for the SIMD scan and the test that reuses one scratch buffer across joined, exact, and unchanged pages. - A synthetic scan-only comparison against upstream’s SIMD scan checked identical output on 1,024 generated 4 KiB pages per pattern. At `-C opt-level=2`, medians of 17 alternating batches went from 368 to 322 ns per unchanged page, 414 to 365 ns per sparse page, 1,412 to 1,156 ns per fragmented page, and 548 to 475 ns per dense page. Gap was zero. The benchmark covers scanning and allocation. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/925:upstream-pr/925'
git switch 'upstream-pr/925'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/925'
git switch 'upstream-pr/925'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/925'
git switch 'upstream-pr/925'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/925'
git switch 'main'
git merge --squash 'upstream-pr/925'
git switch 'main'
git merge --ff-only 'upstream-pr/925'
git switch 'main'
git merge 'upstream-pr/925'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!924
No description provided.