Use mimalloc for host allocations #1487

Merged
FIocker merged 1 commit from upstream-pr/1487 into main 2026-11-30 14:12:04 +00:00
FIocker commented 2026-11-28 20:44:00 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by FIocker on 2026-11-28T20:44:00Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5544398998 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487). Originally posted by [FIocker](https://github.com/FIocker) on 2026-11-28T20:44:00Z. --- 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.
POMXARK commented 2026-11-28 21:47:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by POMXARK on 2026-11-28T21:47:49Z.


@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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7246279495 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7246279495). Originally posted by [POMXARK](https://github.com/POMXARK) on 2026-11-28T21:47:49Z. --- @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.
amazedturnip commented 2026-11-29 05:38:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by amazedturnip on 2026-11-29T05:38:28Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7251373146 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7251373146). Originally posted by [amazedturnip](https://github.com/amazedturnip) on 2026-11-29T05:38:28Z. --- 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.
JSa25 commented 2026-11-30 10:12:25 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by JSa25 on 2026-11-30T10:12:25Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7275274035 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1487#issuecomment-7275274035). Originally posted by [JSa25](https://github.com/JSa25) on 2026-11-30T10:12:25Z. --- 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.
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
trustno1-coder/VIctory-NVIDIA!1487
No description provided.