The Windows heap by a switch (VICTORY_ALLOCATOR=system; unset: mimalloc, as before) #4532

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

@⁠AS-AI-DEV on GitHub · 2026-11-30 22:00 UTC · original
AS-AI-DEV:allocator-switch → main · +113 −1 · 2 files · 1 commits · open

What it changes

Since v2026.11.30.01 (#1487) mimalloc is the allocator of the layer's Rust code on every PC. It saves heap time on the submitting thread and costs private memory. On a PC short of RAM that trade can go the wrong way, and there is no way to choose.

This adds VICTORY_ALLOCATOR=system: the layer's Rust code uses the Windows heap. Unset, mimalloc is used exactly as now.

  • New crates/victory-gpu/src/heap.rs: a GlobalAlloc that passes each call to mimalloc or to std::alloc::System. The choice is made once, at the first allocation, and never changes, so every block is released to the allocator that made it.
  • The variable is read with GetEnvironmentVariableA into a stack buffer, because the allocator cannot allocate to read its own switch. Other targets keep mimalloc.
  • crates/victory-gpu/src/lib.rs: the global allocator is that type. Diagnostics builds keep their counting allocator, untouched.
  • One unit test (a block made, grown and released).

How it was tested

  • GPU and profile: RTX 5060 Ti 16 GB, Ryzen 7 5800X, 32 GB RAM; Series X, 1080p to 1440p, DLSS performance, frame generation on, ray tracing off.
  • The number compared is the process's peak private memory, from a save standing in a house.
  • Before (mimalloc), e1251c3, 2 starts: 25.2-25.8 GB; lowest free RAM 5.5-5.6 GB.
  • After (VICTORY_ALLOCATOR=system), e1251c3, 2 starts: 24.0-24.3 GB; lowest free RAM 5.9-6.1 GB.
  • The same on c71899d, standing starts: 25.0-25.7 GB against 23.7-24.3 GB.
  • Frame rate: the standing starts on e1251c3 landed in different views, so I do not quote fps from them. My walking comparison is older: on 41adb55 with mimalloc 0.1.48 as an opt-in, a fixed walking route, 3 alternated runs a side: without mimalloc 20.3 / 17.7 / 16.4 fps at about 7,000 / 9,000 / 10,000 draws against 18.2 / 17.2 / 14.9 with it, the submitting thread 41.7 against 42.8 ms, private memory 24.9-25.9 against 26.4-26.9 GB.
  • Why it matters on this PC: the frame does not wait for the submitting thread here, so the heap time saved gives no frame, and memory is the limit. A 35-minute play session on e1251c3 went from 25.1 to 30.8 GB private and free RAM fell to 0.5 GB.
  • I am not claiming mimalloc is worse in general: #1487's numbers are from PCs where the submitting thread is the limit. This is only the way out for the others, and a way to measure both on one build.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes (victory-gpu, with the new test). cargo clippy -p victory-gpu --all-targets with and without --all-features reports nothing in the lines this adds (it stops at two lints that are on main already).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1487 (merged: mimalloc for all; a tester there measured +1.1 GB of commit).

🤖 Generated with Claude Code

**@⁠AS-AI-DEV** on GitHub · 2026-11-30 22:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4531) `AS-AI-DEV:allocator-switch` → `main` · +113 −1 · 2 files · 1 commits · open ## What it changes Since v2026.11.30.01 (#1487) mimalloc is the allocator of the layer's Rust code on every PC. It saves heap time on the submitting thread and costs private memory. On a PC short of RAM that trade can go the wrong way, and there is no way to choose. This adds `VICTORY_ALLOCATOR=system`: the layer's Rust code uses the Windows heap. Unset, mimalloc is used exactly as now. - New `crates/victory-gpu/src/heap.rs`: a `GlobalAlloc` that passes each call to mimalloc or to `std::alloc::System`. The choice is made once, at the first allocation, and never changes, so every block is released to the allocator that made it. - The variable is read with `GetEnvironmentVariableA` into a stack buffer, because the allocator cannot allocate to read its own switch. Other targets keep mimalloc. - `crates/victory-gpu/src/lib.rs`: the global allocator is that type. Diagnostics builds keep their counting allocator, untouched. - One unit test (a block made, grown and released). ## How it was tested - GPU and profile: RTX 5060 Ti 16 GB, Ryzen 7 5800X, 32 GB RAM; Series X, 1080p to 1440p, DLSS performance, frame generation on, ray tracing off. - The number compared is the process's peak private memory, from a save standing in a house. - Before (mimalloc), e1251c3, 2 starts: 25.2-25.8 GB; lowest free RAM 5.5-5.6 GB. - After (`VICTORY_ALLOCATOR=system`), e1251c3, 2 starts: 24.0-24.3 GB; lowest free RAM 5.9-6.1 GB. - The same on c71899d, standing starts: 25.0-25.7 GB against 23.7-24.3 GB. - Frame rate: the standing starts on e1251c3 landed in different views, so I do not quote fps from them. My walking comparison is older: on 41adb55 with mimalloc 0.1.48 as an opt-in, a fixed walking route, 3 alternated runs a side: without mimalloc 20.3 / 17.7 / 16.4 fps at about 7,000 / 9,000 / 10,000 draws against 18.2 / 17.2 / 14.9 with it, the submitting thread 41.7 against 42.8 ms, private memory 24.9-25.9 against 26.4-26.9 GB. - Why it matters on this PC: the frame does not wait for the submitting thread here, so the heap time saved gives no frame, and memory is the limit. A 35-minute play session on e1251c3 went from 25.1 to 30.8 GB private and free RAM fell to 0.5 GB. - I am not claiming mimalloc is worse in general: #1487's numbers are from PCs where the submitting thread is the limit. This is only the way out for the others, and a way to measure both on one build. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes (`victory-gpu`, with the new test). `cargo clippy -p victory-gpu --all-targets` with and without `--all-features` reports nothing in the lines this adds (it stops at two lints that are on main already). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1487 (merged: mimalloc for all; a tester there measured +1.1 GB of commit). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mimalloc is the allocator of the layer's Rust code for every PC since
v2026.11.30.01. It saves heap time on the submitting thread and costs
memory. The switch chooses the system heap at the first allocation, for
PCs short of RAM and for measuring; unset, nothing changes. The choice
never changes while the process runs, so every block is released to the
allocator that made it. The variable is read with
GetEnvironmentVariableA because the allocator cannot allocate to read
it; other targets keep mimalloc.

Measured on a Ryzen 7 5800X, RTX 5060 Ti 16 GB, 32 GB RAM (Series X,
1080p to 1440p, DLSS performance, frame generation on), a save standing
in a house, the process's peak private memory:
- e1251c3, 2 starts a side: 24.0-24.3 GB with the switch against
  25.2-25.8 GB without; lowest free RAM 5.9-6.1 against 5.5-5.6 GB.
- c71899d, standing starts: 23.7-24.3 GB against 25.0-25.7 GB.
- 41adb55 with mimalloc 0.1.48 as an opt-in, a walking route, 3
  alternated runs a side: 24.9-25.9 GB without mimalloc against
  26.4-26.9 GB with it; fps 20.3/17.7/16.4 against 18.2/17.2/14.9 at
  7,000/9,000/10,000 draws, the submitting thread 41.7 against 42.8 ms.
On this PC the frame does not wait for the submitting thread, so the
heap time mimalloc saves gives no frame and the 1.2 to 1.5 GB matter
more: a 35-minute play session on e1251c3 went from 25.1 to 30.8 GB
private and free RAM fell to 0.5 GB. The frame rates of the standing
starts on e1251c3 are not comparable (different views each start).

Co-Authored-By: AS-AI-DEV <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:02:46 +00:00
github-bot force-pushed github-bot/gh-4531 from 8c9e69f9fe to 79f1198585 2026-12-01 03:28:26 +00:00 Compare
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/4532/head:github-bot/gh-4531'
git switch 'github-bot/gh-4531'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4531'
git switch 'github-bot/gh-4531'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4531'
git switch 'github-bot/gh-4531'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4531'
git switch 'main'
git merge --squash 'github-bot/gh-4531'
git switch 'main'
git merge --ff-only 'github-bot/gh-4531'
git switch 'main'
git merge 'github-bot/gh-4531'
git push origin 'main'
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!4532
No description provided.