Use mimalloc for host allocations #1487

Manually merged
github merged 1 commit from github-bot/gh-1487 into main 2026-11-30 14:14:51 +00:00 AGit
Owner

@⁠FIocker on GitHub · 2026-11-28 20:44 UTC · original
FIocker:contrib/mimalloc → main · +35 −6 · 4 files · 1 commits · merged 2026-11-30 14:12 UTC

Uses mimalloc for the host allocator and keeps allocation counters in diagnostics builds. This is an independent port of the allocator change from HotScarlett, with attribution in the commit.

In an earlier matched local build, the allocator-only comparison moved the median from 34.9 to 34.1 ms in the 6,500–8,500 draw window on one machine. This is a component result. The rebased branch awaits CI and gameplay validation.

**@⁠FIocker** on GitHub · 2026-11-28 20:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487) `FIocker:contrib/mimalloc` → `main` · +35 −6 · 4 files · 1 commits · merged 2026-11-30 14:12 UTC Uses mimalloc for the host allocator and keeps allocation counters in diagnostics builds. This is an independent port of the allocator change from HotScarlett, with attribution in the commit. In an earlier matched local build, the allocator-only comparison moved the median from 34.9 to 34.1 ms in the 6,500–8,500 draw window on one machine. This is a component result. The rebased branch awaits CI and gameplay validation.
Our threads make and free many small blocks a frame (lists, steps,
tables). mimalloc 0.1.52 (MIT; checksums as in HotScarlett's lock) is the
global allocator in release builds; diagnostics builds count every block
over it. After HotScarlett (GPL-3.0). Run m1b against pr1 (same code,
Windows heap), matched views: 6500-8500 draws median 34.9 -> 34.1 ms, mean
50.0 -> 34.1 (spikes gone); 8500-12000 draws 44.6 (u2w) -> 41.5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 20:45:58 +00:00
Author
Owner

@⁠POMXARK on GitHub · 2026-11-28 21:47 UTC · original

@⁠FIocker — here is a full 20-minute gameplay A/B on Windows 11 (RTX 5080 16 GB, Ryzen 7 5700X 8C/16T, 32 GB RAM, Series X 1440p, DLSS Quality + MFG 4x, release build, matched save & switches):

20-minute A/B (mimalloc 0.1.52 vs Windows system heap)

Metric Baseline (system heap) PR #1487 (mimalloc) Delta
Errors / Refused shaders 0 / 2 0 / 2 clean
1k–4k draws p50 16.05 FPS (prep 48.8 ms) 17.25 FPS (prep 44.5 ms) +7.5% (-4.3 ms)
4k–7k draws p50 14.80 FPS (prep 51.5 ms) 12.30 FPS (prep 59.9 ms) -16.9% (+8.4 ms)
7k–10k draws p50 11.50 FPS (prep 64.9 ms) 10.80 FPS (prep 68.5 ms) -6.1% (+3.6 ms)
ALL 3D p50 14.80 FPS (67.4 ms) 14.20 FPS (70.5 ms) -4.1%
Submitting thread med 59.3 ms (steps 28.3 ms) 66.0 ms (steps 32.6 ms) +6.7 ms
Frame p95 / >100ms (5s bins) 117.3 ms / 31 118.3 ms / 32 flat
Peak Working Set / Peak Commit 20,950 MB / 30,932 MB 21,737 MB / 32,056 MB +787 MB WS / +1,124 MB Commit

Takeaway

  • In lighter scenes (1k–4k draws, before memory pressure), mimalloc gave a clean +7.5% FPS / -4.3 ms prep win with 0 errors and clean visuals.
  • On a 32 GB RAM system, however, mimalloc's default per-thread segment retention added +1,124 MB peak commit (30.9 -> 32.1 GB) and +787 MB WS, pushing heavier 4k–7k / 7k–10k scenes deeper into commit/paging pressure and causing a net regression overall (14.80 -> 14.20 FPS).
  • Suggestion: It may be worth exposing/tuning aggressive page purging (e.g., MIMALLOC_PURGE_DELAY=10 / mi_option_set(mi_option_purge_delay, 10) or calling mi_collect(false) under host memory pressure) so 16–32 GB systems keep the fast-path mimalloc speedup without the ~1.1 GB extra commit footprint.
**@⁠POMXARK** on GitHub · 2026-11-28 21:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7246279495) @⁠FIocker — here is a full 20-minute gameplay A/B on Windows 11 (RTX 5080 16 GB, Ryzen 7 5700X 8C/16T, 32 GB RAM, Series X 1440p, DLSS Quality + MFG 4x, release build, matched save & switches): ### 20-minute A/B (`mimalloc 0.1.52` vs Windows system heap) | Metric | Baseline (system heap) | PR #1487 (`mimalloc`) | Delta | |---|---:|---:|---:| | Errors / Refused shaders | 0 / 2 | 0 / 2 | clean | | **1k–4k draws p50** | 16.05 FPS (`prep 48.8 ms`) | **17.25 FPS** (`prep 44.5 ms`) | **+7.5% (`-4.3 ms`)** | | **4k–7k draws p50** | **14.80 FPS** (`prep 51.5 ms`) | 12.30 FPS (`prep 59.9 ms`) | -16.9% (`+8.4 ms`) | | **7k–10k draws p50** | **11.50 FPS** (`prep 64.9 ms`) | 10.80 FPS (`prep 68.5 ms`) | -6.1% (`+3.6 ms`) | | **ALL 3D p50** | **14.80 FPS** (`67.4 ms`) | 14.20 FPS (`70.5 ms`) | -4.1% | | Submitting thread med | **59.3 ms** (`steps 28.3 ms`) | 66.0 ms (`steps 32.6 ms`) | +6.7 ms | | Frame p95 / `>100ms` (5s bins) | 117.3 ms / 31 | 118.3 ms / 32 | flat | | Peak Working Set / **Peak Commit** | 20,950 MB / **30,932 MB** | 21,737 MB / **32,056 MB** | **+787 MB WS / +1,124 MB Commit** | ### Takeaway - In lighter scenes (`1k–4k` draws, before memory pressure), `mimalloc` gave a clean **+7.5% FPS / -4.3 ms prep** win with 0 errors and clean visuals. - On a **32 GB RAM** system, however, `mimalloc`'s default per-thread segment retention added **+1,124 MB peak commit** (`30.9 -> 32.1 GB`) and **+787 MB WS**, pushing heavier `4k–7k` / `7k–10k` scenes deeper into commit/paging pressure and causing a net regression overall (`14.80 -> 14.20 FPS`). - **Suggestion:** It may be worth exposing/tuning aggressive page purging (e.g., `MIMALLOC_PURGE_DELAY=10` / `mi_option_set(mi_option_purge_delay, 10)` or calling `mi_collect(false)` under host memory pressure) so 16–32 GB systems keep the fast-path `mimalloc` speedup without the ~1.1 GB extra commit footprint.
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-29 05:38 UTC · original

Running mimalloc as default allocator on 9800X3D + RTX 5070 Ti 16 GB (32 GB RAM, Windows 11) across several gameplay sessions and full shader pretranslations. Clean build, zero allocator crashes or regressions.

**@⁠amazedturnip** on GitHub · 2026-11-29 05:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7251373146) Running mimalloc as default allocator on 9800X3D + RTX 5070 Ti 16 GB (32 GB RAM, Windows 11) across several gameplay sessions and full shader pretranslations. Clean build, zero allocator crashes or regressions.
Author
Owner

@⁠JSa25 on GitHub · 2026-11-30 10:12 UTC · original

An independent measurement of mimalloc as the global allocator, in case it helps this along. Hardware and profile: RTX 5090, Ryzen 9 9950X3D, Series X profile, 2560x1440 with DLSS Quality, frame generation off, ray tracing off.

Method:

  • The opening cell route, run unattended (scripts/bench.ps1, the camera turning between the window and the room).
  • A diagnostics build, the same switches in every run.
  • The two builds interleaved: 4 runs with the Windows heap, 3 with mimalloc.
over the walking window Windows heap (4 runs) mimalloc (3 runs)
median fps 34.6-36.9 (median 36.2) 42.2-42.8
frame time 27.4 ms 23.5 ms
99th percentile frame 47-48 ms 41 ms
1% low 21 fps 24 fps
victory-submit preparing 19.4-20.6 ms 18.0-18.3 ms
copies 10.6-11.8 ms 8.3-8.6 ms
GPU busy 63% 76%

Why it helps here: before the change, a VICTORY_PROFILE sample of 60 s of that route put about a fifth of victory-submit's time in the Windows heap (20-23% at the top of its list). With mimalloc, allocation was gone from the top of the list.

Our version:

  • mimalloc as the #[global_allocator] behind a cargo feature (mimalloc, off by default), forwarded from the app to victory-hle and victory-gpu.
  • Diagnostics builds hand their counting allocator's calls to it.
  • The unit tests gave the same results with and without it.
  • It has been in our daily release build since.

Caveats: one PC, a CPU-bound scene, and a diagnostics build. Where the GPU is the limit the gain should be smaller.

**@⁠JSa25** on GitHub · 2026-11-30 10:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7275274035) An independent measurement of mimalloc as the global allocator, in case it helps this along. Hardware and profile: RTX 5090, Ryzen 9 9950X3D, Series X profile, 2560x1440 with DLSS Quality, frame generation off, ray tracing off. **Method:** - The opening cell route, run unattended (`scripts/bench.ps1`, the camera turning between the window and the room). - A diagnostics build, the same switches in every run. - The two builds interleaved: 4 runs with the Windows heap, 3 with mimalloc. | over the walking window | Windows heap (4 runs) | mimalloc (3 runs) | |---|---|---| | median fps | 34.6-36.9 (median 36.2) | 42.2-42.8 | | frame time | 27.4 ms | 23.5 ms | | 99th percentile frame | 47-48 ms | 41 ms | | 1% low | 21 fps | 24 fps | | victory-submit preparing | 19.4-20.6 ms | 18.0-18.3 ms | | copies | 10.6-11.8 ms | 8.3-8.6 ms | | GPU busy | 63% | 76% | **Why it helps here:** before the change, a `VICTORY_PROFILE` sample of 60 s of that route put about a fifth of victory-submit's time in the Windows heap (20-23% at the top of its list). With mimalloc, allocation was gone from the top of the list. **Our version:** - `mimalloc` as the `#[global_allocator]` behind a cargo feature (`mimalloc`, off by default), forwarded from the app to victory-hle and victory-gpu. - Diagnostics builds hand their counting allocator's calls to it. - The unit tests gave the same results with and without it. - It has been in our daily release build since. **Caveats:** one PC, a CPU-bound scene, and a diagnostics build. Where the GPU is the limit the gain should be smaller.
github manually merged commit 93091c9f0f into main 2026-11-30 14:14:51 +00:00
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!1487
No description provided.