perf(gpu): opt in to global best-fit texture placement #3711

Closed
github-bot wants to merge 1 commit from github-bot/gh-3711 into main AGit
Owner

@⁠fladit123 on GitHub · 2026-11-30 04:26 UTC · original
fladit123:perf/texture-pool-best-fit-v2-global → main · +115 −8 · 1 files · 1 commits · closed without merging

Supersedes #543 on 41adb55167fa778fcaa5dc36fa18a1fa8dacd657.

Enable VICTORY_POOL_BEST_FIT=1 to use global best-fit in the standard and small-alignment texture pools. Among ripe heaps, it selects the smallest suitable range, using alignment padding, block slot and offset to break ties. The existing oldest-first fallback still handles requests that cannot use a ripe heap. Fullest-block-first remains the default. With best-fit disabled, VICTORY_POOL_FULLEST=0 still selects first-fit.

The texture path uses the existing accounting, quarantine, submission marks, growth and reclaim operations. D3D12 heap creation stays outside the mutex. Staging and CPU-visible pools continue through the upstream selector.

Capacity and reclaim

  • In 70 paired synthetic workloads, global best-fit reduced peak heap capacity in 54 cases and matched the default in the other 16. Median peak capacity fell by 64 MiB, median active-window mean capacity by 30.93 MiB and median full-run mean capacity by 22.48 MiB. Full-run mean capacity increased in 20 of the 70 scenarios. Placement refusals decreased in ten scenarios.
  • On an RTX 4060 (driver 610.88) and Microsoft WARP, the constructed growth case used 128 MiB with global best-fit and 192 MiB with fullest-block-first or the experimental hybrid. In the complementary reclaim case, fullest-block-first reclaimed down to 64 MiB while global best-fit retained 128 MiB.

Contention

In the isolated 30-run confirmation on the dense 64-block contention fixture, enabling global best-fit reduced median paired throughput by 17.42% at two threads, 17.48% at four threads and 14.98% at eight threads. These are allocator measurements from a synthetic fixture.

With best-fit disabled, the paired capacity replay matched clean main in all 210 comparisons. The timing runs did not establish a consistent disabled-path regression above the observed variability. At eight threads, the median difference was +1.16% in the first isolated run and −3.31% in the confirmation. The confirmation's interquartile range was −10.15% to +5.15%, and repeated executions of the same clean binary showed variation of similar magnitude.

Experimental campaign and final-candidate validation

  • Four-policy experimental build. The build used to compare first-fit, fullest-block-first, global best-fit and hybrid best-fit passed 64 physical test processes with 2,356 byte-exact readbacks and two expected negative controls.
  • Final production patch. The narrowed patch passed 36 physical test processes with 1,468 byte-exact readbacks and two expected negative controls. The production global selector also agreed with the placement oracle on 100,000 deterministic states.

Both physical suites ran on the RTX 4060 and WARP. They cover synthetic upload and readback, fence completion, quarantine, concurrent placement, small alignment, ahead heaps and committed fallback. Release and diagnostics builds, targeted tests and the staged asset-policy check passed. Strict workspace Clippy and the full-tree asset policy reproduced existing failures on clean main.

#1337 and #1562 explore related hybrid strategies that prioritize block occupancy and use best-fit within a block. This patch compares suitable ranges across ripe heaps and keeps the existing heap size, streaming, eviction and spare policies.

The campaign provides no gameplay, FPS or frametime results.

AI assistance was used to develop and review the patch, write the test harnesses and prepare the evidence and this description.

**@⁠fladit123** on GitHub · 2026-11-30 04:26 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711) `fladit123:perf/texture-pool-best-fit-v2-global` → `main` · +115 −8 · 1 files · 1 commits · closed without merging Supersedes #543 on `41adb55167fa778fcaa5dc36fa18a1fa8dacd657`. Enable `VICTORY_POOL_BEST_FIT=1` to use global best-fit in the standard and small-alignment texture pools. Among ripe heaps, it selects the smallest suitable range, using alignment padding, block slot and offset to break ties. The existing oldest-first fallback still handles requests that cannot use a ripe heap. Fullest-block-first remains the default. With best-fit disabled, `VICTORY_POOL_FULLEST=0` still selects first-fit. The texture path uses the existing accounting, quarantine, submission marks, growth and reclaim operations. D3D12 heap creation stays outside the mutex. Staging and CPU-visible pools continue through the upstream selector. ## Capacity and reclaim - In 70 paired synthetic workloads, global best-fit reduced peak heap capacity in 54 cases and matched the default in the other 16. Median peak capacity fell by 64 MiB, median active-window mean capacity by 30.93 MiB and median full-run mean capacity by 22.48 MiB. Full-run mean capacity increased in 20 of the 70 scenarios. Placement refusals decreased in ten scenarios. - On an RTX 4060 (driver 610.88) and Microsoft WARP, the constructed growth case used 128 MiB with global best-fit and 192 MiB with fullest-block-first or the experimental hybrid. In the complementary reclaim case, fullest-block-first reclaimed down to 64 MiB while global best-fit retained 128 MiB. ## Contention In the isolated 30-run confirmation on the dense 64-block contention fixture, enabling global best-fit reduced median paired throughput by 17.42% at two threads, 17.48% at four threads and 14.98% at eight threads. These are allocator measurements from a synthetic fixture. With best-fit disabled, the paired capacity replay matched clean main in all 210 comparisons. The timing runs did not establish a consistent disabled-path regression above the observed variability. At eight threads, the median difference was +1.16% in the first isolated run and −3.31% in the confirmation. The confirmation's interquartile range was −10.15% to +5.15%, and repeated executions of the same clean binary showed variation of similar magnitude. ## Experimental campaign and final-candidate validation - **Four-policy experimental build.** The build used to compare first-fit, fullest-block-first, global best-fit and hybrid best-fit passed 64 physical test processes with 2,356 byte-exact readbacks and two expected negative controls. - **Final production patch.** The narrowed patch passed 36 physical test processes with 1,468 byte-exact readbacks and two expected negative controls. The production global selector also agreed with the placement oracle on 100,000 deterministic states. Both physical suites ran on the RTX 4060 and WARP. They cover synthetic upload and readback, fence completion, quarantine, concurrent placement, small alignment, ahead heaps and committed fallback. Release and diagnostics builds, targeted tests and the staged asset-policy check passed. Strict workspace Clippy and the full-tree asset policy reproduced existing failures on clean main. ## Related work and scope #1337 and #1562 explore related hybrid strategies that prioritize block occupancy and use best-fit within a block. This patch compares suitable ranges across ripe heaps and keeps the existing heap size, streaming, eviction and spare policies. The campaign provides no gameplay, FPS or frametime results. AI assistance was used to develop and review the patch, write the test harnesses and prepare the evidence and this description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 04:28:30 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 05:49 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 05:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711#issuecomment-7270047705) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 08:44 UTC · original

I tested removing the sorts from the shared placement paths while keeping the selected block and offset. Follow-up commit 316593c is based on 020f78a. The default selects the fullest fitting ripe block in one pass. The fallback selects the oldest fitting unripe block in one pass. Both keep slot order for equal ranks and use the existing range split. Global best-fit's ripe-range selection stays as in this PR.

I compared 250,000 placement decisions before/after with deterministic allocation and return traces across fullest-first, first-fit and opt-in best-fit. Every slot/offset or miss matched, including with 4 KiB, 64 KiB and 4 MiB alignment. The diagnostics pool test filter returned 31 passed and 3 ignored. The staged asset-policy check passed.

Synthetic Windows CPU timings on a Ryzen 7 5800X, with 64 slots (56 live blocks), fragmented ranges and identical requests per pair. The single-thread p99 is the median of seven repetitions of 16,000 cuts per arm. For contention, one shared mutex with four threads, 12,000 attempts each and seven paired runs.

Placement case p99 before → after Median throughput after/before, four threads
Default, mixed ripeness 3.2 → 1.1 µs 2.94×
Default, all unripe 2.4 → 1.0 µs 3.41×
Global best-fit, mixed ripeness 2.3 → 1.0 µs 1.94×

The throughput ratios compare each policy with itself. The mixed best-fit fixture includes requests that fall back or miss. Timing covers the CPU allocator, with synthetic ranges and no title data. Review assisted by Claude Opus 5.5.

**@⁠tyr0nsur** on GitHub · 2026-11-30 08:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711#issuecomment-7273282575) I tested removing the sorts from the shared placement paths while keeping the selected block and offset. [Follow-up commit `316593c`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/316593cb3993333748dedc360f0807e917a00a4a) is based on `020f78a`. The default selects the fullest fitting ripe block in one pass. The fallback selects the oldest fitting unripe block in one pass. Both keep slot order for equal ranks and use the existing range split. Global best-fit's ripe-range selection stays as in this PR. I compared 250,000 placement decisions before/after with deterministic allocation and return traces across fullest-first, first-fit and opt-in best-fit. Every slot/offset or miss matched, including with 4 KiB, 64 KiB and 4 MiB alignment. The diagnostics pool test filter returned 31 passed and 3 ignored. The staged asset-policy check passed. Synthetic Windows CPU timings on a Ryzen 7 5800X, with 64 slots (56 live blocks), fragmented ranges and identical requests per pair. The single-thread p99 is the median of seven repetitions of 16,000 cuts per arm. For contention, one shared mutex with four threads, 12,000 attempts each and seven paired runs. | Placement case | p99 before → after | Median throughput after/before, four threads | | --- | ---: | ---: | | Default, mixed ripeness | 3.2 → 1.1 µs | 2.94× | | Default, all unripe | 2.4 → 1.0 µs | 3.41× | | Global best-fit, mixed ripeness | 2.3 → 1.0 µs | 1.94× | The throughput ratios compare each policy with itself. The mixed best-fit fixture includes requests that fall back or miss. Timing covers the CPU allocator, with synthetic ranges and no title data. Review assisted by Claude Opus 5.5.
Author
Owner

@⁠fladit123 on GitHub · 2026-11-30 13:29 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

Thanks for the independent review and validation! I'm looking forward to the RTX 4090 results, particularly the frame times and memory behavior. I appreciate your help testing this on different hardware.

**@⁠fladit123** on GitHub · 2026-11-30 13:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711#issuecomment-7279910778) > Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here. Thanks for the independent review and validation! I'm looking forward to the RTX 4090 results, particularly the frame times and memory behavior. I appreciate your help testing this on different hardware.
Author
Owner

@⁠fladit123 on GitHub · 2026-11-30 13:29 UTC · original

I tested removing the sorts from the shared placement paths while keeping the selected block and offset. Follow-up commit 316593c is based on 020f78a. The default selects the fullest fitting ripe block in one pass. The fallback selects the oldest fitting unripe block in one pass. Both keep slot order for equal ranks and use the existing range split. Global best-fit's ripe-range selection stays as in this PR.

I compared 250,000 placement decisions before/after with deterministic allocation and return traces across fullest-first, first-fit and opt-in best-fit. Every slot/offset or miss matched, including with 4 KiB, 64 KiB and 4 MiB alignment. The diagnostics pool test filter returned 31 passed and 3 ignored. The staged asset-policy check passed.

Synthetic Windows CPU timings on a Ryzen 7 5800X, with 64 slots (56 live blocks), fragmented ranges and identical requests per pair. The single-thread p99 is the median of seven repetitions of 16,000 cuts per arm. For contention, one shared mutex with four threads, 12,000 attempts each and seven paired runs.
Placement case p99 before → after Median throughput after/before, four threads
Default, mixed ripeness 3.2 → 1.1 µs 2.94×
Default, all unripe 2.4 → 1.0 µs 3.41×
Global best-fit, mixed ripeness 2.3 → 1.0 µs 1.94×

The throughput ratios compare each policy with itself. The mixed best-fit fixture includes requests that fall back or miss. Timing covers the CPU allocator, with synthetic ranges and no title data. Review assisted by Claude Opus 5.5.

Excellent follow-up, thank you! Removing the sorts under the lock while preserving placement decisions is particularly interesting given the contention costs measured in my original campaign.

I'll independently validate your commit on my RTX 4060 and compare it against both clean main and the original best-fit implementation, including allocation throughput, capacity, reclaim behavior, and GPU correctness.

Thanks for building on this contribution!

**@⁠fladit123** on GitHub · 2026-11-30 13:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711#issuecomment-7279916814) > I tested removing the sorts from the shared placement paths while keeping the selected block and offset. [Follow-up commit `316593c`](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/316593cb3993333748dedc360f0807e917a00a4a) is based on `020f78a`. The default selects the fullest fitting ripe block in one pass. The fallback selects the oldest fitting unripe block in one pass. Both keep slot order for equal ranks and use the existing range split. Global best-fit's ripe-range selection stays as in this PR. > > I compared 250,000 placement decisions before/after with deterministic allocation and return traces across fullest-first, first-fit and opt-in best-fit. Every slot/offset or miss matched, including with 4 KiB, 64 KiB and 4 MiB alignment. The diagnostics pool test filter returned 31 passed and 3 ignored. The staged asset-policy check passed. > > Synthetic Windows CPU timings on a Ryzen 7 5800X, with 64 slots (56 live blocks), fragmented ranges and identical requests per pair. The single-thread p99 is the median of seven repetitions of 16,000 cuts per arm. For contention, one shared mutex with four threads, 12,000 attempts each and seven paired runs. > Placement case p99 before → after Median throughput after/before, four threads > Default, mixed ripeness 3.2 → 1.1 µs 2.94× > Default, all unripe 2.4 → 1.0 µs 3.41× > Global best-fit, mixed ripeness 2.3 → 1.0 µs 1.94× > > The throughput ratios compare each policy with itself. The mixed best-fit fixture includes requests that fall back or miss. Timing covers the CPU allocator, with synthetic ranges and no title data. Review assisted by Claude Opus 5.5. Excellent follow-up, thank you! Removing the sorts under the lock while preserving placement decisions is particularly interesting given the contention costs measured in my original campaign. I'll independently validate your commit on my RTX 4060 and compare it against both clean main and the original best-fit implementation, including allocation throughput, capacity, reclaim behavior, and GPU correctness. Thanks for building on this contribution!
github-bot closed this pull request 2026-12-01 18:51:28 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:49 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3711#issuecomment-7321619927) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3711
No description provided.