Skip to content

docs: keep fxceless builds aligned with mimalloc path (DOCS-D3D12-MIMALLOC-BUILD) - #2755

Open
j-weiner wants to merge 1 commit into
ProjectLeonida:mainfrom
j-weiner:docs/d3d12-mimalloc-build
Open

j-weiner wants to merge 1 commit into
ProjectLeonida:mainfrom
j-weiner:docs/d3d12-mimalloc-build

Conversation

@j-weiner

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: DOCS-D3D12-MIMALLOC-BUILD

Depends on: none

Fixes: none

What and why

The fxceless runtime guide documented release and diagnostic builds without mimalloc, while the maintained NVIDIA build script enables it. The commands now include the feature, and the guide explains the parity/performance reason so users do not accidentally choose the slower system allocator for cold shader translation.

Tested

  • git diff --check — passed.
  • python -I scripts/check_no_game_data.py d3d12/docs/README-fxceless.md — passed.
  • Documentation-only change; no game files or GPU workload used.

GPUs tested: n/a.

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports.
  • No translator rule.

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent Windows-target build check for the Mimalloc commands

MEASURED. I checked 69855ca6 merged onto main 1cce3c89 (tree 6f9d5f24). On CachyOS I built both documented feature combinations for x86_64-pc-windows-msvc using Rust 1.98.1, the local Windows SDK, clang-cl for C dependencies and lld-link. The verification added --locked --offline.

  • --release -p leonida --features mimalloc produced a Windows x64 executable. Its linked Rust allocation entry point jumps directly to mi_malloc_aligned.
  • --profile diag -p leonida --features diagnostics,mimalloc also produced a Windows x64 executable. Its allocation entry point goes through copystat::Counting::alloc, which calls mi_malloc_aligned.
  • leonida.exe --help exited 0 under Wine 11.22 for both builds. The diagnostic executable includes the replay command. The earlier guide's feature combinations kept Mimalloc out of the corresponding Cargo dependency trees.

A second agent independently checked the linked binaries, PDBs and feature graphs and reran the Wine smoke checks. CPU-only build and CLI smoke test using no game files. AI-assisted with OpenAI Codex.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commands are valid — mimalloc is a real opt-in feature (d3d12/apps/leonida/Cargo.toml:26-39, with default: [] in cargo metadata), so this is not a renamed-option bug and both edited commands run against existing features and profiles.

The reason is wrong, though, and that is the part that will be quoted:

  • The only measurement in the tree is per-frame on the submitting thread — "a quarter of the submitting thread's running time was in the heap … the same view took 95 ms a frame against 78 with it" (d3d12/scripts/build-nvidia.ps1:14-15) — not "the system-heap cost on every cold shader translation" (line 237). A repo-wide search for cold shader finds only your new line. Quote the measurement, or drop the mechanism; AGENTS.md:67-72 asks exactly that of a D3D12 frame-rate claim.
  • The page says "Everything below this line is upstream VIctory's own README, unchanged" (:158-159), and both of your edits are below that line. Either update that sentence or move the commands above it.
  • "Parity with build-nvidia.ps1" is allocator-only: that script builds --profile diag --features diagnostics[,dlss],mimalloc (:16, :19, :25), while d3d12/Cargo.toml:81/:88 and d3d12/docs/replay.md:11 still say diagnostics alone, and d3d12/README.md:403-404 describes the same script without mimalloc. Say "the same allocator", or align those three places too (and note the script also passes --locked, which the edited commands do not).
  • "fxceless builds" in the title is shorthand for this page, not a build type — there is no fxceless feature or target in any Cargo.toml. Fine as prose, but not as a build instruction.

Also: the branch is 262 commits behind main, so the "Based on current main" box is not true today; merge main in before this lands. Links and paths all resolve; the only style wart is that the new d3d12/scripts/... path is repo-root-relative in a page whose other links are doc-relative.

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --features mimalloc / --features diagnostics,mimalloc build commands themselves are valid, but requesting changes on two factual inaccuracies flagged by @KelboLive:

  1. Unmeasured performance rationale (d3d12/docs/README-fxceless.md:235-237): The added text cites "avoid paying the system-heap cost on every cold shader translation", whereas the actual measured reason in d3d12/scripts/build-nvidia.ps1:14-15 is per-frame heap overhead on the submitting thread ("a quarter of the submitting thread's running time was in the heap (profile of 2026-11-27), and the same view took 95 ms a frame against 78 with it"). Per AGENTS.md, please quote the measured basis rather than inventing an unmeasured mechanism.
  2. Contradicts upstream-unchanged header (d3d12/docs/README-fxceless.md:158-159): Both edits fall below the line stating "Everything below this line is upstream VIctory's own README, unchanged". Please either update that notice or document the mimalloc build commands above it.

(AI-assisted review.)

@imShangLi

Copy link
Copy Markdown
Contributor

VERIFY-2755 — Linux, Fedora 45, Rust 1.98.1, no GPU device, no game files

Verdict: PASS. Every factual claim in the new text checks out against the code — the feature exists, the build script uses it, and it does change the allocator. One phrase in the rationale attributes the cost to something other than what the repository's own measurement says.

Head 3e74b0d7, base the current main 88a9f133, merge base 3e74b0d7, 1 commit, 1 file, +5/−3: d3d12/docs/README-fxceless.md.

1. The change

Two build commands in the archived upstream README gain --features mimalloc:

cargo build --release -p leonida --features mimalloc
cargo build --profile diag -p leonida --features diagnostics,mimalloc

and the text above them says the feature "selects the process allocator used by the NVIDIA build path; keep it enabled for parity with d3d12/scripts/build-nvidia.ps1".

2. The feature exists, and it reaches the allocator

The chain from the command line to the #[global_allocator] is complete:

apps/leonida/Cargo.toml      mimalloc = ["leonida-hle/mimalloc"]        # off by default: the system allocator
crates/leonida-hle/Cargo.toml mimalloc = ["leonida-gpu/mimalloc"]
crates/leonida-gpu/Cargo.toml mimalloc = ["dep:mimalloc"]
crates/leonida-gpu/src/lib.rs:18-22
// With `mimalloc` the process allocates through mimalloc. On Windows with
// diagnostics, copystat's counting allocator wraps the same backend instead.
#[cfg(all(feature = "mimalloc", not(all(windows, feature = "diagnostics"))))]
#[global_allocator]
static HEAP: mimalloc::MiMalloc = mimalloc::MiMalloc;

One thing worth checking, because the cfg above looks at first glance like it would skip the allocator on the NVIDIA path: on Windows with diagnostics the #[global_allocator] is not installed, but copystat's counting allocator is, and it wraps mimalloc:

// crates/leonida-gpu/src/copystat.rs:392-395
#[cfg(feature = "mimalloc")]
const INNER: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[cfg(not(feature = "mimalloc"))]
const INNER: std::alloc::System = std::alloc::System;

So both build lines in the pull request do put mimalloc behind the process's allocations: the release build uses it directly, the diag build uses it through the counter.

3. The parity claim holds

d3d12/scripts/build-nvidia.ps1 builds with exactly these features:

$features = 'diagnostics,mimalloc'
$features = 'diagnostics,dlss,mimalloc'   # with the DLSS SDK
try { cargo build --locked --profile diag -p leonida --features $features } …

and the diag profile exists ([profile.diag] inherits = "release" in d3d12/Cargo.toml:83), so the second command line in the pull request is a valid one.

4. The repository's own measurement of the same thing

build-nvidia.ps1 carries the note the pull request is paraphrasing:

mimalloc is the process allocator: with the system heap a quarter of the submitting thread's running time was in the heap (profile of 2026-11-27), and the same view took 95 ms a frame against 78 with it.

5. One phrase to reconsider

The new text says the feature is worth having "to avoid paying the system-heap cost on every cold shader translation". The repository's own measurement does not say that: it attributes the heap cost to the submitting thread's running time and to a frame (95 ms against 78 ms) — not to the shader translation. The translation is not something the measurement isolates.

The direction of the claim is right (the system heap is expensive here, and mimalloc is what the NVIDIA build uses), but the place the cost is attributed to is narrower than, and different from, what the repository measured. I would either say "on the submitting thread" as the script does, or leave the reason to the script's comment.

6. The document tests are green

The repository has a documentation check suite, and this pull request changes a document:

$ python3 -I -m unittest discover -s tests -p "test_docs_*.py"
Ran 57 tests in 106.013s
OK

7. What I did not check

  • The build itself. apps/leonida depends on leonida-gpu, leonida-hle and leonida-loader, which do not build on Linux for reasons that predate this pull request (upstream: "The crates are Windows-only today … Linux follows Linux: build leonida.exe and run it under Proton or Wine #2577"), so I did not run cargo build --release -p leonida --features mimalloc. I checked the feature graph and the #[global_allocator] instead, which is what decides whether the command line has the effect the document claims.
  • The performance numbers (the quarter of the submitting thread, 95 ms against 78 ms) — those are the repository's own measurements on another PC; I did not re-measure them, and the pull request does not claim to.
  • The fxceless/victory-fork README's own caveat — it opens by saying it is kept "for its description of upstream, the commands and the debugging switches" and that "what it says of speed and state is of that fork and another PC". The two commands the pull request touches are among those commands, so keeping them aligned is the document's stated purpose. I did not check the rest of that document for other stale commands.

AI-assisted: MiniMax M3.1 Flash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants