perf(gpu): opt-in best-fit texture pool placement to reduce fragmentation #543

Open
github-bot wants to merge 1 commit from github-bot/gh-543 into main AGit
Owner

@⁠fladit123 on GitHub · 2026-11-28 00:36 UTC · original
fladit123:perf/texture-pool-best-fit → main · +168 −30 · 1 files · 1 commits · open

Summary

Adds an experimental, opt-in best-fit placement policy for the texture pool, intended to preserve larger contiguous free ranges and reduce heap growth under fragmentation.

First-fit remains the default.

Enable the experimental policy with:

$env:VICTORY_POOL_BEST_FIT = "1"

Implementation

  • Selects the smallest suitable free range across eligible ripe texture blocks.
  • Stops searching when an exact fit is found.
  • Skips ranges that cannot improve the current best candidate before calculating alignment.
  • Preserves deterministic tie-breaking, alignment padding, quarantine, ripe-block priority and the existing unripe fallback.
  • Leaves staging allocation and the existing heap reclamation policy unchanged.
  • Adds four focused unit tests.

Experimental results

The comparative campaign covered 70 deterministic CPU workload scenarios and physical D3D12 validation on NVIDIA RTX 4060 (8 GiB) and Microsoft WARP.

Compared with the same candidate with best-fit disabled:

Metric Result
Median peak heap capacity −64 MiB
Median active-window mean heap capacity −78.22 MiB
Scenarios with lower peak capacity 64/70
Scenarios with lower active-window mean capacity 70/70
Allocation p99 −26.6%
Median full-trace mean heap capacity +48.76 MiB

Best-fit increased full-trace heap capacity in 44 of 70 scenarios. This is an important trade-off: preserving contiguous ranges does not necessarily make entire heaps easier to reclaim.

Synthetic mutex contention benchmarks also showed higher allocation costs than first-fit. The pruning optimization reduced execution time by approximately 10–14% relative to the earlier unpruned best-fit implementation, without changing placement decisions in 10,000 deterministic equivalence cases.

The comparative campaign also measured a median paired throughput reduction of approximately 5% with eight threads when the feature was disabled, relative to clean upstream. This result warrants further investigation.

Relationship to #399

This proposal is distinct from the fullest-block-first policy and VRAM growth gate introduced in #399.

Two controlled physical scenarios demonstrated complementary strengths on both RTX 4060 and WARP:

Scenario Best-fit Fullest-block-first
Fragmentation-driven heap growth 128 MiB 192 MiB
Heap reclamation 128 MiB 64 MiB

Best-fit can preserve larger contiguous ranges, while fullest-block-first can concentrate allocations and facilitate whole-heap reclamation.

The policies should not be considered universally superior to one another. Coordination with #399's VRAM gate may be useful.

Validation

  • 10,000 deterministic exact-versus-pruned equivalence cases.
  • 11,932 byte-exact readbacks across 161 successful D3D12 processes in the final comparative campaign.
  • Zero D3D12 debug-layer errors or device removals in those successful runs.
  • Physical validation with small placement enabled and disabled.
  • Effective ahead counts of 2 and 12.
  • Single-threaded and concurrent texture creation.
  • Final focused pool tests on 64d4931: 11 passed with best-fit disabled and 11 passed with best-fit enabled.

The comparative full-library suites reproduced the same three failures on clean upstream and both candidate settings. No additional test failures were observed in the candidate.

The comparative performance measurements remain tied to their pinned test base. Initial fixture failures and corrected reruns were retained in the experimental evidence.

Limitations

  • No in-game FPS or frametime improvements have been demonstrated.
  • Reduced heap capacity in a controlled workload does not imply equivalent savings in total process VRAM.
  • The policy can increase allocation cost and delay whole-heap reclamation in some workloads.
  • AMD hardware has not been tested.
  • The feature remains disabled by default.

Disclosure

AI-assisted implementation, benchmarking and analysis. Tests were executed on local hardware. No proprietary game data or assets were used in this investigation.

**@⁠fladit123** on GitHub · 2026-11-28 00:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/543) `fladit123:perf/texture-pool-best-fit` → `main` · +168 −30 · 1 files · 1 commits · open ## Summary Adds an experimental, opt-in best-fit placement policy for the texture pool, intended to preserve larger contiguous free ranges and reduce heap growth under fragmentation. First-fit remains the default. Enable the experimental policy with: ```powershell $env:VICTORY_POOL_BEST_FIT = "1" ``` ## Implementation - Selects the smallest suitable free range across eligible ripe texture blocks. - Stops searching when an exact fit is found. - Skips ranges that cannot improve the current best candidate before calculating alignment. - Preserves deterministic tie-breaking, alignment padding, quarantine, ripe-block priority and the existing unripe fallback. - Leaves staging allocation and the existing heap reclamation policy unchanged. - Adds four focused unit tests. ## Experimental results The comparative campaign covered 70 deterministic CPU workload scenarios and physical D3D12 validation on NVIDIA RTX 4060 (8 GiB) and Microsoft WARP. Compared with the same candidate with best-fit disabled: | Metric | Result | |---|---:| | Median peak heap capacity | −64 MiB | | Median active-window mean heap capacity | −78.22 MiB | | Scenarios with lower peak capacity | 64/70 | | Scenarios with lower active-window mean capacity | 70/70 | | Allocation p99 | −26.6% | | Median full-trace mean heap capacity | +48.76 MiB | Best-fit increased full-trace heap capacity in 44 of 70 scenarios. This is an important trade-off: preserving contiguous ranges does not necessarily make entire heaps easier to reclaim. Synthetic mutex contention benchmarks also showed higher allocation costs than first-fit. The pruning optimization reduced execution time by approximately 10–14% relative to the earlier unpruned best-fit implementation, without changing placement decisions in 10,000 deterministic equivalence cases. The comparative campaign also measured a median paired throughput reduction of approximately 5% with eight threads when the feature was disabled, relative to clean upstream. This result warrants further investigation. ## Relationship to #399 This proposal is distinct from the fullest-block-first policy and VRAM growth gate introduced in #399. Two controlled physical scenarios demonstrated complementary strengths on both RTX 4060 and WARP: | Scenario | Best-fit | Fullest-block-first | |---|---:|---:| | Fragmentation-driven heap growth | 128 MiB | 192 MiB | | Heap reclamation | 128 MiB | 64 MiB | Best-fit can preserve larger contiguous ranges, while fullest-block-first can concentrate allocations and facilitate whole-heap reclamation. The policies should not be considered universally superior to one another. Coordination with #399's VRAM gate may be useful. ## Validation - 10,000 deterministic exact-versus-pruned equivalence cases. - 11,932 byte-exact readbacks across 161 successful D3D12 processes in the final comparative campaign. - Zero D3D12 debug-layer errors or device removals in those successful runs. - Physical validation with small placement enabled and disabled. - Effective ahead counts of 2 and 12. - Single-threaded and concurrent texture creation. - Final focused pool tests on `64d4931`: 11 passed with best-fit disabled and 11 passed with best-fit enabled. The comparative full-library suites reproduced the same three failures on clean upstream and both candidate settings. No additional test failures were observed in the candidate. The comparative performance measurements remain tied to their pinned test base. Initial fixture failures and corrected reruns were retained in the experimental evidence. ## Limitations - No in-game FPS or frametime improvements have been demonstrated. - Reduced heap capacity in a controlled workload does not imply equivalent savings in total process VRAM. - The policy can increase allocation cost and delay whole-heap reclamation in some workloads. - AMD hardware has not been tested. - The feature remains disabled by default. ## Disclosure AI-assisted implementation, benchmarking and analysis. Tests were executed on local hardware. No proprietary game data or assets were used in this investigation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 00:41:05 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/543/head:github-bot/gh-543'
git switch 'github-bot/gh-543'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-543'
git switch 'github-bot/gh-543'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-543'
git switch 'github-bot/gh-543'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-543'
git switch 'main'
git merge --squash 'github-bot/gh-543'
git switch 'main'
git merge --ff-only 'github-bot/gh-543'
git switch 'main'
git merge 'github-bot/gh-543'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.