Avoid per-block allocations in GPU landing order #4006

Open
Rosynb666 wants to merge 1 commit from upstream-pr/4006 into main
Rosynb666 commented 2026-11-30 14:20:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Rosynb666 on 2026-11-30T14:20:03Z.


What it changes

land::ordered previously allocated and copied a temporary index vector for
each block containing multiple pieces from a single copy. This patch sorts
the existing index slice in place and emits singleton blocks directly.
Stable sorting preserves the first source index for equal addresses.
Mixed-copy blocks retain their input order.

How it was tested

Baseline: 41adb551. Synthetic CPU benchmark on macOS ARM64, Rust 1.98.1.
Times are medians per call. Allocation counts were measured separately.

Workload Allocations before → after Time before → after
256 blocks × 4 same-copy pieces 259 → 3 26.42 → 16.03 µs
96 blocks × 16 same-copy pieces 99 → 3 30.80 → 26.71 µs
1,024 singleton blocks 3 → 3 12.76 → 12.76 µs
256 blocks × 4 mixed-copy pieces 3 → 3 12.77 → 13.12 µs

Two isolated Rust unit tests passed, including the new regression test.
10,003 differential cases matched the original output and overlap counter.
cargo check passed for victory-gpu on the Windows x64 MSVC target,
using blake3/pure for the cross-check.

Full native Windows test suite and in-game frame-time measurements are pending.

Checked for overlap

Related open PRs include #2881 and #3626. This patch focuses on the
per-block index allocation inside land::ordered.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5567093583 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4006). Originally posted by [Rosynb666](https://github.com/Rosynb666) on 2026-11-30T14:20:03Z. --- ## What it changes `land::ordered` previously allocated and copied a temporary index vector for each block containing multiple pieces from a single copy. This patch sorts the existing index slice in place and emits singleton blocks directly. Stable sorting preserves the first source index for equal addresses. Mixed-copy blocks retain their input order. ## How it was tested Baseline: 41adb551. Synthetic CPU benchmark on macOS ARM64, Rust 1.98.1. Times are medians per call. Allocation counts were measured separately. | Workload | Allocations before → after | Time before → after | | --- | --- | --- | | 256 blocks × 4 same-copy pieces | 259 → 3 | 26.42 → 16.03 µs | | 96 blocks × 16 same-copy pieces | 99 → 3 | 30.80 → 26.71 µs | | 1,024 singleton blocks | 3 → 3 | 12.76 → 12.76 µs | | 256 blocks × 4 mixed-copy pieces | 3 → 3 | 12.77 → 13.12 µs | Two isolated Rust unit tests passed, including the new regression test. 10,003 differential cases matched the original output and overlap counter. `cargo check` passed for `victory-gpu` on the Windows x64 MSVC target, using `blake3/pure` for the cross-check. Full native Windows test suite and in-game frame-time measurements are pending. ## Checked for overlap Related open PRs include #2881 and #3626. This patch focuses on the per-block index allocation inside `land::ordered`.
dyshay commented 2026-11-30 14:53:35 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T14:53:35Z.


Merged for testing into our integration branch dyshay/VIctory-NVIDIA janus-prs. Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282095258 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4006#issuecomment-7282095258). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-30T14:53:35Z. --- Merged for testing into our integration branch [dyshay/VIctory-NVIDIA `janus-prs`](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs). Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.
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/4006:upstream-pr/4006'
git switch 'upstream-pr/4006'

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/4006'
git switch 'upstream-pr/4006'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4006'
git switch 'upstream-pr/4006'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4006'
git switch 'main'
git merge --squash 'upstream-pr/4006'
git switch 'main'
git merge --ff-only 'upstream-pr/4006'
git switch 'main'
git merge 'upstream-pr/4006'
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
trustno1-coder/VIctory-NVIDIA!4006
No description provided.