perf: compact merged write intervals in place #1229

Closed
spk-c wants to merge 2 commits from upstream-pr/1232 into main
spk-c commented 2026-11-26 00:59:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by spk-c on 2026-11-26T00:59:54Z.


Summary

Sort and compact the write interval vector in place instead of allocating an output vector. Preserve the reference implementation's merged interval semantics. Includes deterministic randomized parity regression. Does not include the superseded write-index experiment.

Validation

All CI steps passed for this isolated change against the corrected test baseline in the fork: https://github.com/spk-c/victory-fork/actions/runs/45731813852.

This submission is a single commit rebased onto upstream a183ea2; exact-revision upstream CI is pending. Upstream's pre-existing CI failures are addressed separately in #1228. Draft pending baseline and upstream review. AI-assisted.

Independent validation

Yoshi-233's report tested exact head 9a04be5 and two reference revisions in a standalone Linux CPU harness: 1,679,616 interval-union cases per revision matched the reference, including a separate usize::MAX boundary case. Repeated covered-range updates caused zero allocations on the PR vs 10,000 on each reference. Trade-off: a collapsed large set retained capacity 4,097 vs 1 on references. No gameplay or process-memory measurement.

Refresh against upstream 52ac4ec

New head 783abdd1a3fa9c3f1553a5a57d0be36aec8694cf; in-place interval compaction matched the allocating reference in the focused regression. Clean isolated workspace Cargo Check and strict all-feature Clippy passed. Original commits are preserved. PR-only diff check passed. Full upstream CI approval and source-size policy fix #1357 remain pending.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5501965909 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1232). Originally posted by [spk-c](https://github.com/spk-c) on 2026-11-26T00:59:54Z. --- ## Summary Sort and compact the write interval vector in place instead of allocating an output vector. Preserve the reference implementation's merged interval semantics. Includes deterministic randomized parity regression. Does not include the superseded write-index experiment. ## Validation All CI steps passed for this isolated change against the corrected test baseline in the fork: https://github.com/spk-c/victory-fork/actions/runs/45731813852. This submission is a single commit rebased onto upstream a183ea2; exact-revision upstream CI is pending. Upstream's pre-existing CI failures are addressed separately in #1228. Draft pending baseline and upstream review. AI-assisted. ## Independent validation [Yoshi-233's report](https://github.com/fxceless/victory-fork/pull/1232#issuecomment-7179692367) tested exact head `9a04be5` and two reference revisions in a standalone Linux CPU harness: 1,679,616 interval-union cases per revision matched the reference, including a separate usize::MAX boundary case. Repeated covered-range updates caused zero allocations on the PR vs 10,000 on each reference. Trade-off: a collapsed large set retained capacity 4,097 vs 1 on references. No gameplay or process-memory measurement. ## Refresh against upstream 52ac4ec New head `783abdd1a3fa9c3f1553a5a57d0be36aec8694cf`; in-place interval compaction matched the allocating reference in the focused regression. Clean isolated workspace Cargo Check and strict all-feature Clippy passed. Original commits are preserved. PR-only diff check passed. Full upstream CI approval and source-size policy fix #1357 remain pending.
Yoshi-233 commented 2026-11-26 02:08:42 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Yoshi-233 on 2026-11-26T01:21:25Z.


I independently tested join_ranges from the parent (a183ea2), current main (c9092ec) and the PR (9a04be5) on x86-64 Linux with Rust 1.98.1. I compiled the function body from each revision into the same CPU harness.

  • For every starting occupancy mask over eight slots, I added every ordered pair of intervals with endpoints 0 through 8, including empty and reversed intervals. All 1,679,616 results per revision matched an independent bitmap union converted back to canonical half-open intervals. A separate case with overlapping and touching ranges ending at usize::MAX also passed.
  • With room already reserved, I repeatedly inserted the covered interval [1, 3) into [(0, 4), (8, 10)]. A counting allocator saw 10,000 allocation/reallocation calls across 10,000 updates on both the parent and main, and zero on the PR.
  • The other side of that reuse is retained capacity. Starting with capacity 4,097 and 4,096 disjoint ranges, I merged them into one with a covering interval, then issued an empty update. The parent and main ended with capacity 1; the PR retained 4,097 slots. The resulting interval was identical in each case.

These are allocator counts and correctness checks on synthetic inputs. I did not measure in-game frame time or process memory.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7179692367 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1232#issuecomment-7179692367). Originally posted by [Yoshi-233](https://github.com/Yoshi-233) on 2026-11-26T01:21:25Z. --- I independently tested `join_ranges` from the parent (`a183ea2`), current main (`c9092ec`) and the PR (`9a04be5`) on x86-64 Linux with Rust 1.98.1. I compiled the function body from each revision into the same CPU harness. - For every starting occupancy mask over eight slots, I added every ordered pair of intervals with endpoints 0 through 8, including empty and reversed intervals. All 1,679,616 results per revision matched an independent bitmap union converted back to canonical half-open intervals. A separate case with overlapping and touching ranges ending at `usize::MAX` also passed. - With room already reserved, I repeatedly inserted the covered interval `[1, 3)` into `[(0, 4), (8, 10)]`. A counting allocator saw 10,000 allocation/reallocation calls across 10,000 updates on both the parent and main, and zero on the PR. - The other side of that reuse is retained capacity. Starting with capacity 4,097 and 4,096 disjoint ranges, I merged them into one with a covering interval, then issued an empty update. The parent and main ended with capacity 1; the PR retained 4,097 slots. The resulting interval was identical in each case. These are allocator counts and correctness checks on synthetic inputs. I did not measure in-game frame time or process memory.

Pull request closed

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!1229
No description provided.