Lay out a submission's sends in one pass #286

Manually merged
github merged 1 commit from github-bot/gh-286 into gh-pr/286/base 2026-11-27 14:02:12 +00:00 AGit
Owner

@⁠PetrSeifert on GitHub · 2026-11-27 13:37 UTC · original
PetrSeifert:perf/send-take-one-pass → main · +144 −26 · 2 files · 1 commits · merged 2026-11-27 13:57 UTC

Two small changes on the path that sends changed bytes of host copies up to the card. Neither changes what is sent or where.

send::take in one pass. For each copy, take went over the ranges three times before the upload memory was made: once for the runs that are copied, once to count the words that go as pairs, and once more, piece of work by piece of work (4,096 ranges each), to count them again. laid_out gives the runs their places, counts the pairs and cuts the pieces of work in a single pass; the pairs' places are fixed up once their start is known. The places are the same as before.

shadow::joined returns sorted, separate ranges as they are. One stretch of ranges that is already in order with nothing touching comes back without the sort and the joining pass. Ranges that touch, overlap or are out of order take the old path.

Tests

  • host::send::tests::one_pass_lays_out_what_three_did keeps the three-pass layout as a reference and compares runs, pair places and counts, the pieces of work and the end offset for random copies of 0, 1, 7, 4,095, 4,096, 4,097 and 12,293 ranges, including a piece of work that holds no pair, laid out one behind the other in the memory.
  • ranges_join_where_they_touch gains the cases in order and apart, in order and touching, in order and overlapping, and out of order.

Run on this branch at a9b4904 (base cfcf180), Windows 11, RTX 4070 12 GB, Ryzen 5 7600, 63 GB RAM:

Command Result
cargo xtask policy --staged, git diff --check 2 files ok, clean
cargo clippy --locked -p victory-gpu --all-targets -- -D warnings clean
cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings clean
cargo test --locked -p victory-gpu --lib -- --test-threads=1 482 passed, 0 failed, 43 ignored
cargo test --locked -p victory-gpu --lib --features diagnostics -- --test-threads=1 542 passed, 0 failed, 43 ignored

cargo test --locked -p victory-gpu --lib with the default parallel test threads fails here at host::refresh_tests::raw_title_copy_keeps_write_watch_and_resends_equal_bytes in 2 of 2 runs on this branch. It fails the same way on unmodified main on this PC (6 of 6 runs at 231b6a9, 2 of 3 at cfcf180; CI's default job passes there) and passes on this branch one at a time.

Measured

Synthetic, single thread, cargo test --release, on the Ryzen 5 7600; the timing tests were temporary and are not part of the branch. Median of 301 alternating iterations, three runs of each:

Before After
Layout of one copy with 80,000 ranges (1 in 16 a long run, the rest 4 to 192 bytes) 479 to 544 µs 326 to 449 µs
joined, 80,000 ranges in order and apart 100 to 106 µs 23 µs
joined, 2,000 ranges in order and apart 3.9 to 4.8 µs 0.7 µs

"Before" for the layout is the test's three-pass reference, for joined the old body (sort, then join). The layout figures spread widely between runs; I read them as "somewhat less", not as a ratio.

Not done

No gameplay run and no frame-time comparison: I have not measured what share of a frame these two functions are on this PC, so I claim no frame-rate change. take itself (the memory, the copies and the pair stores) is not covered by a test on the card; only its layout is. No image comparison was recorded; the bytes sent and their places are unchanged, which the layout test checks.

#251 changes the caller of joined in card_dirty, not joined itself; no open pull request touches send.rs.

**@⁠PetrSeifert** on GitHub · 2026-11-27 13:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/286) `PetrSeifert:perf/send-take-one-pass` → `main` · +144 −26 · 2 files · 1 commits · merged 2026-11-27 13:57 UTC Two small changes on the path that sends changed bytes of host copies up to the card. Neither changes what is sent or where. **`send::take` in one pass.** For each copy, `take` went over the ranges three times before the upload memory was made: once for the runs that are copied, once to count the words that go as pairs, and once more, piece of work by piece of work (4,096 ranges each), to count them again. `laid_out` gives the runs their places, counts the pairs and cuts the pieces of work in a single pass; the pairs' places are fixed up once their start is known. The places are the same as before. **`shadow::joined` returns sorted, separate ranges as they are.** One stretch of ranges that is already in order with nothing touching comes back without the sort and the joining pass. Ranges that touch, overlap or are out of order take the old path. ## Tests - `host::send::tests::one_pass_lays_out_what_three_did` keeps the three-pass layout as a reference and compares runs, pair places and counts, the pieces of work and the end offset for random copies of 0, 1, 7, 4,095, 4,096, 4,097 and 12,293 ranges, including a piece of work that holds no pair, laid out one behind the other in the memory. - `ranges_join_where_they_touch` gains the cases in order and apart, in order and touching, in order and overlapping, and out of order. Run on this branch at `a9b4904` (base `cfcf180`), Windows 11, RTX 4070 12 GB, Ryzen 5 7600, 63 GB RAM: | Command | Result | |---|---| | `cargo xtask policy --staged`, `git diff --check` | 2 files ok, clean | | `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` | clean | | `cargo clippy --locked -p victory-gpu --all-targets --features diagnostics -- -D warnings` | clean | | `cargo test --locked -p victory-gpu --lib -- --test-threads=1` | 482 passed, 0 failed, 43 ignored | | `cargo test --locked -p victory-gpu --lib --features diagnostics -- --test-threads=1` | 542 passed, 0 failed, 43 ignored | `cargo test --locked -p victory-gpu --lib` with the default parallel test threads fails here at `host::refresh_tests::raw_title_copy_keeps_write_watch_and_resends_equal_bytes` in 2 of 2 runs on this branch. It fails the same way on unmodified `main` on this PC (6 of 6 runs at `231b6a9`, 2 of 3 at `cfcf180`; CI's default job passes there) and passes on this branch one at a time. ## Measured Synthetic, single thread, `cargo test --release`, on the Ryzen 5 7600; the timing tests were temporary and are not part of the branch. Median of 301 alternating iterations, three runs of each: | | Before | After | |---|---:|---:| | Layout of one copy with 80,000 ranges (1 in 16 a long run, the rest 4 to 192 bytes) | 479 to 544 µs | 326 to 449 µs | | `joined`, 80,000 ranges in order and apart | 100 to 106 µs | 23 µs | | `joined`, 2,000 ranges in order and apart | 3.9 to 4.8 µs | 0.7 µs | "Before" for the layout is the test's three-pass reference, for `joined` the old body (sort, then join). The layout figures spread widely between runs; I read them as "somewhat less", not as a ratio. ## Not done No gameplay run and no frame-time comparison: I have not measured what share of a frame these two functions are on this PC, so I claim no frame-rate change. `take` itself (the memory, the copies and the pair stores) is not covered by a test on the card; only its layout is. No image comparison was recorded; the bytes sent and their places are unchanged, which the layout test checks. #251 changes the caller of `joined` in `card_dirty`, not `joined` itself; no open pull request touches `send.rs`.
`send::take` went over each copy's ranges three times before the memory
was made (the runs copied, the words that go as pairs, and the words
again piece of work by piece of work). `laid_out` gives the runs their
places, counts the pairs and cuts the pieces of work in one pass; the
places are the same, and a test lays random copies out both ways.

`shadow::joined` returns ranges that are in order and apart already as
they are, without the sort and the pass that joins them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:47:52 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 13:43 UTC · original

@⁠PetrSeifert The three-pass reference is a good oracle for this change. The 4,095/4,096/4,097 boundaries and a piece with no pair are the cases I care about. I’ll check that the layout and range order match on the current base.

**@⁠TaynanGT** on GitHub · 2026-11-27 13:43 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/286#issuecomment-7219866116) @⁠PetrSeifert The three-pass reference is a good oracle for this change. The 4,095/4,096/4,097 boundaries and a piece with no pair are the cases I care about. I’ll check that the layout and range order match on the current base.
github-bot changed target branch from main to gh-pr/286/base 2026-11-27 14:02:09 +00:00
github manually merged commit a9b49046a2 into gh-pr/286/base 2026-11-27 14:02:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.