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

Merged
PetrSeifert merged 1 commit from upstream-pr/286 into main 2026-11-27 13:57:55 +00:00
PetrSeifert commented 2026-11-27 13:37:45 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by PetrSeifert on 2026-11-27T13:37:45Z.


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.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5527571382 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/286). Originally posted by [PetrSeifert](https://github.com/PetrSeifert) on 2026-11-27T13:37:45Z. --- 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`.
TaynanGT commented 2026-11-27 13:43:30 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T13:43:30Z.


@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.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7219866116 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/286#issuecomment-7219866116). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T13:43:30Z. --- @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.
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
TaynanGT/Vice-Tay!286
No description provided.