d3d12: cap default warm and translate worker counts by host RAM #3071

Open
lixonik wants to merge 2 commits from upstream-pr/3071 into main
lixonik commented 2026-12-02 08:58:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T08:58:35Z.


Claimed in the coordination issue as: D3D12-PRECOMPILE-RAM-CAP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7339992426)

Fixes #3041

What and why

While in-game pipeline compilation (d3d12/crates/leonida-gpu/src/pipeline/make.rs) already caps workers at 8 on <= 32 GiB RAM hosts (residency::limited_host_ram()) and 16 otherwise, the CLI precompile/translation paths scaled purely with logical core count and had no upper bound or RAM check:

  • d3d12/apps/leonida/src/warm.rs (warm::run and warm::store_these) defaulted to cores * 2 / 3 child processes / in-process compilation threads (21 separate D3D12 processes on a 16C/32T CPU, 42 on 64T).
  • d3d12/apps/leonida/src/translate.rs (translate::run and translate::precompile) defaulted to 100% of available_parallelism() (32 threads on 16C/32T), and with --pipelines each worker creates its own ID3D12Device and driver compiler.

Measured on a 16C/32T Ryzen 9 5950X (64 GiB RAM): leonida translate --jobs 32 used 1,865.7 MB peak private bytes vs 887.8 MB at --jobs 8 (2.10x), and --pipelines reached 3,495 MB within 35 s.

This change:

  • Exposes leonida_gpu::limited_host_ram() (d3d12/crates/leonida-gpu/src/lib.rs, delegating to residency::limited_host_ram() on Windows and false on non-Windows).
  • Adds default_jobs in warm.rs ((processors * 2 / 3).clamp(1, 8) on <= 32 GiB RAM, .clamp(1, 16) otherwise) and uses it in both warm::run and warm::store_these.
  • Adds default_jobs in translate.rs (preserving full logical core usage on smaller CPUs while capping at 8 / 16 for CPU translation and 4 / 8 when --pipelines is enabled), using saturating_mul and clamping explicit --jobs 0 to 1.
  • Updates the --jobs CLI help text in d3d12/apps/leonida/src/main.rs.

Tested

  • New unit tests warm::tests::default_jobs_caps_by_cpu_and_host_ram and translate::tests::default_jobs_caps_by_cpu_and_host_ram (covering 32T, 64T, usize::MAX, small CPUs, 0/1, --pipelines, limited_ram on/off, and explicit --jobs override including 0): PASS.
    • Red/green: against the old uncapped formulas (cores * 2 / 3 and cores), the 32T/64T assertions (8/16 and 4/8) fail; with this change they pass.
  • cargo test -p leonida --locked: 45 unit + 5 integration tests PASS.
  • cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws: 749 passed, 0 failed.
  • cargo clippy -p leonida -p leonida-gpu --locked --all-targets: 0 warnings in changed files.
  • cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc: PASS.
  • python -I scripts/check_no_game_data.py on all 4 changed files, python -I tools/d3d12_switches.py --check d3d12/docs/switches.md, and git diff --check: clean.
  • Independent read-only review (separate Pro reviewer agent) caught usize multiplication overflow on processors * 2 / 3 and small-CPU throughput drop in translate.rs; both fixed and re-approved.

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 621.40), Windows 10 Pro 22H2 (build 19045), Ryzen 9 5950X 16C/32T, 64 GiB RAM.

AI-assisted: yes (Antigravity).

Checklist

  • Based on current main (a917c54d6) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (check_no_game_data.py clean).
  • No translator rule changed; nothing to add to the contract table.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5603149528 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T08:58:35Z. --- Claimed in the coordination issue as: D3D12-PRECOMPILE-RAM-CAP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7339992426) Fixes #3041 ### What and why While in-game pipeline compilation (`d3d12/crates/leonida-gpu/src/pipeline/make.rs`) already caps workers at `8` on `<= 32 GiB` RAM hosts (`residency::limited_host_ram()`) and `16` otherwise, the CLI precompile/translation paths scaled purely with logical core count and had no upper bound or RAM check: - `d3d12/apps/leonida/src/warm.rs` (`warm::run` and `warm::store_these`) defaulted to `cores * 2 / 3` child processes / in-process compilation threads (21 separate D3D12 processes on a 16C/32T CPU, 42 on 64T). - `d3d12/apps/leonida/src/translate.rs` (`translate::run` and `translate::precompile`) defaulted to 100% of `available_parallelism()` (32 threads on 16C/32T), and with `--pipelines` each worker creates its own `ID3D12Device` and driver compiler. Measured on a 16C/32T Ryzen 9 5950X (64 GiB RAM): `leonida translate --jobs 32` used `1,865.7 MB` peak private bytes vs `887.8 MB` at `--jobs 8` (2.10x), and `--pipelines` reached `3,495 MB` within 35 s. This change: - Exposes `leonida_gpu::limited_host_ram()` (`d3d12/crates/leonida-gpu/src/lib.rs`, delegating to `residency::limited_host_ram()` on Windows and `false` on non-Windows). - Adds `default_jobs` in `warm.rs` (`(processors * 2 / 3).clamp(1, 8)` on `<= 32 GiB` RAM, `.clamp(1, 16)` otherwise) and uses it in both `warm::run` and `warm::store_these`. - Adds `default_jobs` in `translate.rs` (preserving full logical core usage on smaller CPUs while capping at `8` / `16` for CPU translation and `4` / `8` when `--pipelines` is enabled), using `saturating_mul` and clamping explicit `--jobs 0` to `1`. - Updates the `--jobs` CLI help text in `d3d12/apps/leonida/src/main.rs`. ### Tested - New unit tests `warm::tests::default_jobs_caps_by_cpu_and_host_ram` and `translate::tests::default_jobs_caps_by_cpu_and_host_ram` (covering 32T, 64T, `usize::MAX`, small CPUs, `0`/`1`, `--pipelines`, `limited_ram` on/off, and explicit `--jobs` override including `0`): PASS. - Red/green: against the old uncapped formulas (`cores * 2 / 3` and `cores`), the 32T/64T assertions (`8`/`16` and `4`/`8`) fail; with this change they pass. - `cargo test -p leonida --locked`: 45 unit + 5 integration tests PASS. - `cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws`: 749 passed, 0 failed. - `cargo clippy -p leonida -p leonida-gpu --locked --all-targets`: 0 warnings in changed files. - `cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc`: PASS. - `python -I scripts/check_no_game_data.py` on all 4 changed files, `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`, and `git diff --check`: clean. - Independent read-only review (separate Pro reviewer agent) caught `usize` multiplication overflow on `processors * 2 / 3` and small-CPU throughput drop in `translate.rs`; both fixed and re-approved. GPUs tested: NVIDIA GeForce RTX 5070 12 GB (driver 621.40), Windows 10 Pro 22H2 (build 19045), Ryzen 9 5950X 16C/32T, 64 GiB RAM. AI-assisted: yes (Antigravity). ### Checklist - [x] Based on current `main` (`a917c54d6`) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (`check_no_game_data.py` clean). - [x] No translator rule changed; nothing to add to the contract table.
ecox982745 commented 2026-12-02 09:49:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-12-02T09:49:19Z.


CPU-only review at 83156f75. The default worker caps reach both warm phases, but an explicit warm --jobs 1 still only controls the initial child processes. On a 32-logical-core machine with at most 32 GiB, the default-on library phase can still launch 8 in-process compiler workers. store_in_library (warm.rs:226) calls child without the selected count, the child command (warm.rs:356–358) passes no --jobs, and store_these (warm.rs:306) always supplies None to default_jobs. An explicit warm --these … --store --jobs 1 is also ignored at the early dispatch on line 32.

This is inherited for the public warm command, and it matters when the cap is being lowered to avoid a memory failure. The new helper test for Some(1) would pass even when the library path never reaches it. Consider threading the selected count through the store subprocess, or stating in help that the override covers the first phase only. AI-assisted source review. No compiler jobs or GPU use.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7341540666 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7341540666). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-12-02T09:49:19Z. --- CPU-only review at `83156f75`. The default worker caps reach both warm phases, but an explicit `warm --jobs 1` still only controls the initial child processes. On a 32-logical-core machine with at most 32 GiB, the default-on library phase can still launch 8 in-process compiler workers. `store_in_library` (warm.rs:226) calls `child` without the selected count, the child command (warm.rs:356–358) passes no `--jobs`, and `store_these` (warm.rs:306) always supplies `None` to `default_jobs`. An explicit `warm --these … --store --jobs 1` is also ignored at the early dispatch on line 32. This is inherited for the public warm command, and it matters when the cap is being lowered to avoid a memory failure. The new helper test for `Some(1)` would pass even when the library path never reaches it. Consider threading the selected count through the store subprocess, or stating in help that the override covers the first phase only. AI-assisted source review. No compiler jobs or GPU use.
lixonik commented 2026-12-02 10:14:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T10:14:28Z.


Good catch, thank you @ecox982745 -- fixed in c2065b540:

  • Threaded the resolved jobs count from warm::run through store_in_library into the --store subprocess via warm::child_args (--jobs <N>, clamped to >= 1), leaving non-store --these children unchanged.
  • Forwarded jobs into store_these both from the --store subprocess and from direct leonida warm --these ... --store --jobs N invocations, replacing the hardcoded None passed to default_jobs.
  • Updated Command::Warm's --jobs help text and added unit tests covering warm::child_args forwarding and CLI round-trip parsing (cargo test -p leonida --locked: 47 unit + 5 integration passed; cargo clippy -p leonida --locked --all-targets and scripts/check_no_game_data.py clean).

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7342174267 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7342174267). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T10:14:28Z. --- Good catch, thank you @ecox982745 -- fixed in `c2065b540`: - Threaded the resolved `jobs` count from `warm::run` through `store_in_library` into the `--store` subprocess via `warm::child_args` (`--jobs <N>`, clamped to `>= 1`), leaving non-store `--these` children unchanged. - Forwarded `jobs` into `store_these` both from the `--store` subprocess and from direct `leonida warm --these ... --store --jobs N` invocations, replacing the hardcoded `None` passed to `default_jobs`. - Updated `Command::Warm`'s `--jobs` help text and added unit tests covering `warm::child_args` forwarding and CLI round-trip parsing (`cargo test -p leonida --locked`: 47 unit + 5 integration passed; `cargo clippy -p leonida --locked --all-targets` and `scripts/check_no_game_data.py` clean). AI-assisted: yes (Antigravity).
MoonEyes commented 2026-12-02 12:40:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:40:29Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345699912 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7345699912). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:40:29Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
lixonik commented 2026-12-02 13:58:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T13:58:58Z.


RUN (in game): head c2065b540 merged cleanly (git merge --no-ff) onto main bf7886746, built with cargo build --locked --profile diag -p leonida --features diagnostics,dlss,mimalloc, plus a matched main bf7886746 baseline run on the same save snapshot.

  • System: Windows 10 22H2, NVIDIA GeForce RTX 5070 12 GB, driver 621.40 (Series S profile, -NoFrameGen -NoPrecompile, standing in-world).
  • In-world duration (1,000+ draws/frame):
    • PR #3071 (c2065b540 on bf7886746): 321.6 s (64 world frame lines)
    • main (bf7886746) baseline: 319.2 s (62 world frame lines)
  • Stability:
    • Device lost: 0 (both runs)
    • Crashes / unhandled exceptions / panics / ERROR lines: 0 (both runs)
  • Rendered FPS (tools/d3d12_run_fps.py):
Build World duration Median FPS (ms/frame) 3,000-4,999 draws FPS Preparing / copies / copy-back (ms) Median draws Device lost / crashes / errors
main (bf7886746) 319.2 s 26.6 fps (37.7 ms) 26.6 fps (n=56) 29.1 / 11.8 / 8.3 4,428 0 / 0 / 0
PR #3071 (c2065b540) 321.6 s 26.1 fps (38.2 ms) 26.2 fps (n=57) 29.8 / 12.5 / 8.5 4,386 0 / 0 / 0

Result: PASS.

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7347786719 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7347786719). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T13:58:58Z. --- RUN (in game): head `c2065b540` merged cleanly (`git merge --no-ff`) onto `main` `bf7886746`, built with `cargo build --locked --profile diag -p leonida --features diagnostics,dlss,mimalloc`, plus a matched `main` `bf7886746` baseline run on the same save snapshot. - **System:** Windows 10 22H2, NVIDIA GeForce RTX 5070 12 GB, driver `621.40` (Series S profile, `-NoFrameGen -NoPrecompile`, standing in-world). - **In-world duration (1,000+ draws/frame):** - PR `#3071` (`c2065b540` on `bf7886746`): **321.6 s** (64 world frame lines) - `main` (`bf7886746`) baseline: **319.2 s** (62 world frame lines) - **Stability:** - Device lost: **0** (both runs) - Crashes / unhandled exceptions / panics / `ERROR` lines: **0** (both runs) - **Rendered FPS (`tools/d3d12_run_fps.py`):** | Build | World duration | Median FPS (ms/frame) | 3,000-4,999 draws FPS | Preparing / copies / copy-back (ms) | Median draws | Device lost / crashes / errors | |---|---|---|---|---|---|---| | `main` (`bf7886746`) | 319.2 s | 26.6 fps (37.7 ms) | 26.6 fps (n=56) | 29.1 / 11.8 / 8.3 | 4,428 | 0 / 0 / 0 | | PR `#3071` (`c2065b540`) | 321.6 s | 26.1 fps (38.2 ms) | 26.2 fps (n=57) | 29.8 / 12.5 / 8.5 | 4,386 | 0 / 0 / 0 | Result: **PASS**. AI-assisted: yes (Antigravity).
Kal0s-design commented 2026-12-02 16:56:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T16:56:07Z.


Ran natively on Windows 11, head c2065b540 merged into current main (3c106eb2f, clean merge). CPU-only tests, no game data.

Suites (measured)

Command Result
cargo test -p leonida --locked 47 unit + 5 integration passed
cargo test -p leonida-gpu --lib --locked 696 passed, 59 ignored
cargo clippy -p leonida --locked --all-targets only the existing unused_mut in leonida-gpu host.rs

Default counts over a grid (measured, throwaway test calling both default_jobs directly)

RAM only enters as one boolean (ullTotalPhys <= 32 GiB), so the 4, 8, 12, 16, 24 and 32 GiB inputs give identical rows, as do 48, 64 and 128 GiB. The "main" row is main's expression (cores * 2 / 3, or all cores for translate/shaders) copied into the test.

logical cores 2 4 6 8 12 16 20 24 32 48 64
warm, ≤ 32 GiB 1 2 4 5 8 8 8 8 8 8 8
warm, > 32 GiB 1 2 4 5 8 10 13 16 16 16 16
warm, main 1 2 4 5 8 10 13 16 21 32 42
translate/shaders, ≤ 32 GiB 2 4 6 8 8 8 8 8 8 8 8
translate/shaders, > 32 GiB 2 4 6 8 12 16 16 16 16 16 16
translate --pipelines, ≤ 32 GiB 1 2 3 4 4 4 4 4 4 4 4
translate --pipelines, > 32 GiB 1 2 4 5 8 8 8 8 8 8 8
translate (both), main 2 4 6 8 12 16 20 24 32 48 64
  • I found no monotonicity violations for 0 to 1025 cores in either RAM class, and more RAM never gives fewer workers.
  • warm is unchanged from main up to 12 cores with ≤ 32 GiB, and up to 24 cores with more than 32 GiB.
  • translate --pipelines is more than a cap. It is below main at every core count from 2 upward in both RAM classes, at half of main (≤ 32 GiB) or two thirds (> 32 GiB) before the cap. The PR description and help text say "capped", so anyone who relied on all cores for --pipelines gets fewer even on small machines.
  • On this machine, warm and the --store child get the same count as main. translate/shaders and translate --pipelines get fewer than main.
  • Edge cases: 0 cores gives 1 and usize::MAX cores gives the cap, with no overflow. On main, store_these computed 1 * 2 / 3 = 0 on a 1-core host, but known::store already floors at 1, so that was harmless.

Reading (not run, needs game-derived pipeline files)

  • An explicit --jobs has no upper bound on any path (Some(n) => n.max(1); I measured Some(usize::MAX) returning usize::MAX). With this head, the value now reaches known::store through --store --jobs N. known::store spawns threads.max(1) scoped threads regardless of how many pipelines there are (pipeline/known.rs, the for _ in 0..threads.max(1) loop). By contrast, LEONIDA_PIPELINE_WORKERS is clamped to 1..64 in pipeline::make::worker_count_for. A .clamp(1, 64) on the explicit value would match it. The process loop in warm::run and the translate loops are bounded by the work count (jobs.min(chunks.len()), threads.min(jobs.len())), so only the store path is open-ended.
  • The doc comment says the caps match pipeline::make. The caps (8/16) do, but the ratio does not. The runtime uses 3/4 with a floor of 2 on ≤ 32 GiB, while warm uses 2/3 with a floor of 1. For example, 8 cores at ≤ 32 GiB gives a runtime of 6 against warm's 5, and 2 cores gives 2 against 1.
  • The launcher (play-nvidia.ps1) calls leonida warm without --jobs, so players get the defaults in the table.

Conflicts with other open PRs editing warm.rs (measured, git merge-tree on main + other PR, then this head)

Other PR Result
#3143 (b6023d1dc) conflict in warm.rs: child signature (#3143 splits it over lines, #3071 adds jobs) and the test module's use line
#3150 (968b05d40) conflict in warm.rs: the child(rest, None, …) call, store_in_library signature/return type, and the store child(…) call

#3150 is more than a textual conflict. It already threads jobs into the store child on its own (child(todo, Some((&listed, jobs)), …) plus --store --jobs N, and store_these(…, jobs)), but its store_these default is still the uncapped cores * 2 / 3. Whichever of the two lands second has to keep one forwarding mechanism (child_args here or the tuple in #3150) and keep this PR's capped default in store_these.

Not checked: wall-clock effect of the lower counts on warm, translate or shaders throughput (needs game-derived data); in-game run (already posted above); behaviour on a host near the 32 GiB boundary.

GPUs tested: n/a (CPU-only tests).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352665709 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7352665709). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T16:56:07Z. --- Ran natively on Windows 11, head `c2065b540` merged into current `main` (`3c106eb2f`, clean merge). CPU-only tests, no game data. **Suites (measured)** | Command | Result | |---|---| | `cargo test -p leonida --locked` | 47 unit + 5 integration passed | | `cargo test -p leonida-gpu --lib --locked` | 696 passed, 59 ignored | | `cargo clippy -p leonida --locked --all-targets` | only the existing `unused_mut` in `leonida-gpu` host.rs | **Default counts over a grid (measured, throwaway test calling both `default_jobs` directly)** RAM only enters as one boolean (`ullTotalPhys <= 32 GiB`), so the 4, 8, 12, 16, 24 and 32 GiB inputs give identical rows, as do 48, 64 and 128 GiB. The "main" row is main's expression (`cores * 2 / 3`, or all cores for `translate`/`shaders`) copied into the test. | logical cores | 2 | 4 | 6 | 8 | 12 | 16 | 20 | 24 | 32 | 48 | 64 | |---|---|---|---|---|---|---|---|---|---|---|---| | `warm`, ≤ 32 GiB | 1 | 2 | 4 | 5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | `warm`, > 32 GiB | 1 | 2 | 4 | 5 | 8 | 10 | 13 | 16 | 16 | 16 | 16 | | `warm`, main | 1 | 2 | 4 | 5 | 8 | 10 | 13 | 16 | 21 | 32 | 42 | | `translate`/`shaders`, ≤ 32 GiB | 2 | 4 | 6 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | `translate`/`shaders`, > 32 GiB | 2 | 4 | 6 | 8 | 12 | 16 | 16 | 16 | 16 | 16 | 16 | | `translate --pipelines`, ≤ 32 GiB | 1 | 2 | 3 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 | | `translate --pipelines`, > 32 GiB | 1 | 2 | 4 | 5 | 8 | 8 | 8 | 8 | 8 | 8 | 8 | | `translate` (both), main | 2 | 4 | 6 | 8 | 12 | 16 | 20 | 24 | 32 | 48 | 64 | - I found no monotonicity violations for 0 to 1025 cores in either RAM class, and more RAM never gives fewer workers. - `warm` is unchanged from main up to 12 cores with ≤ 32 GiB, and up to 24 cores with more than 32 GiB. - `translate --pipelines` is more than a cap. It is below main at every core count from 2 upward in both RAM classes, at half of main (≤ 32 GiB) or two thirds (> 32 GiB) before the cap. The PR description and help text say "capped", so anyone who relied on all cores for `--pipelines` gets fewer even on small machines. - On this machine, `warm` and the `--store` child get the same count as main. `translate`/`shaders` and `translate --pipelines` get fewer than main. - Edge cases: 0 cores gives 1 and `usize::MAX` cores gives the cap, with no overflow. On main, `store_these` computed `1 * 2 / 3 = 0` on a 1-core host, but `known::store` already floors at 1, so that was harmless. **Reading (not run, needs game-derived pipeline files)** - An explicit `--jobs` has no upper bound on any path (`Some(n) => n.max(1)`; I measured `Some(usize::MAX)` returning `usize::MAX`). With this head, the value now reaches `known::store` through `--store --jobs N`. `known::store` spawns `threads.max(1)` scoped threads regardless of how many pipelines there are (pipeline/known.rs, the `for _ in 0..threads.max(1)` loop). By contrast, `LEONIDA_PIPELINE_WORKERS` is clamped to 1..64 in `pipeline::make::worker_count_for`. A `.clamp(1, 64)` on the explicit value would match it. The process loop in `warm::run` and the `translate` loops are bounded by the work count (`jobs.min(chunks.len())`, `threads.min(jobs.len())`), so only the store path is open-ended. - The doc comment says the caps match `pipeline::make`. The caps (8/16) do, but the ratio does not. The runtime uses `3/4` with a floor of 2 on ≤ 32 GiB, while warm uses `2/3` with a floor of 1. For example, 8 cores at ≤ 32 GiB gives a runtime of 6 against warm's 5, and 2 cores gives 2 against 1. - The launcher (`play-nvidia.ps1`) calls `leonida warm` without `--jobs`, so players get the defaults in the table. **Conflicts with other open PRs editing `warm.rs` (measured, `git merge-tree` on `main` + other PR, then this head)** | Other PR | Result | |---|---| | #3143 (`b6023d1dc`) | conflict in `warm.rs`: `child` signature (#3143 splits it over lines, #3071 adds `jobs`) and the test module's `use` line | | #3150 (`968b05d40`) | conflict in `warm.rs`: the `child(rest, None, …)` call, `store_in_library` signature/return type, and the store `child(…)` call | #3150 is more than a textual conflict. It already threads `jobs` into the store child on its own (`child(todo, Some((&listed, jobs)), …)` plus `--store --jobs N`, and `store_these(…, jobs)`), but its `store_these` default is still the uncapped `cores * 2 / 3`. Whichever of the two lands second has to keep one forwarding mechanism (`child_args` here or the tuple in #3150) and keep this PR's capped default in `store_these`. Not checked: wall-clock effect of the lower counts on `warm`, `translate` or `shaders` throughput (needs game-derived data); in-game run (already posted above); behaviour on a host near the 32 GiB boundary. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
lixonik commented 2026-12-02 16:57:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T16:57:29Z.


Thanks @Kal0s-design for the thorough Windows 11 verification and core/RAM grid check!

Quick notes on the three points you raised:

  • translate --pipelines ratio (1/2 / 2/3 before the 4/8 cap): intentional, because translating full pipelines keeps noticeably more state live per worker than standalone shader translation; happy to clarify the wording if needed.
  • Explicit --jobs upper bound: preserved main's existing n.max(1) behavior for explicit overrides (and #3150 separately bounds known::store workers by available work).
  • Doc comment vs pipeline::make: fair catch -- the 8 / 16 RAM caps match pipeline::make, while warm keeps its existing 2/3 (floor 1) ratio rather than 3/4 (floor 2).

Leaving c2065b540 untouched for now so the posted 321.6 s in-world gate run on this head remains valid; happy to clamp explicit --jobs / tighten the comment or resolve the warm.rs merge if #3143 or #3150 lands first.

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352697965 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7352697965). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T16:57:29Z. --- Thanks @Kal0s-design for the thorough Windows 11 verification and core/RAM grid check! Quick notes on the three points you raised: - **`translate --pipelines` ratio (`1/2` / `2/3` before the 4/8 cap):** intentional, because translating full pipelines keeps noticeably more state live per worker than standalone shader translation; happy to clarify the wording if needed. - **Explicit `--jobs` upper bound:** preserved `main`'s existing `n.max(1)` behavior for explicit overrides (and #3150 separately bounds `known::store` workers by available work). - **Doc comment vs `pipeline::make`:** fair catch -- the 8 / 16 RAM caps match `pipeline::make`, while `warm` keeps its existing `2/3` (floor 1) ratio rather than `3/4` (floor 2). Leaving `c2065b540` untouched for now so the posted 321.6 s in-world gate run on this head remains valid; happy to clamp explicit `--jobs` / tighten the comment or resolve the `warm.rs` merge if #3143 or #3150 lands first. AI-assisted: yes (Antigravity).
MoonEyes commented 2026-12-02 17:06:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:06:44Z.


RUN (in game, batch of eleven render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3071 c2065b540, #2982 65155eceb, #2964 00a068106, #3107 79333e26b, #2833 823087ec3, #2947 b07f64346, #2919 33e2e4c13, #2962 a4a26ec63, #2847 c8b950cb4, #3114 c4ebe52de, #2664 0e2b6287c. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 16.2, mean 16.1
Rendered fps, last 120 s median 15.1

For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352913992 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7352913992). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:06:44Z. --- RUN (in game, batch of eleven render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3071 `c2065b540`, #2982 `65155eceb`, #2964 `00a068106`, #3107 `79333e26b`, #2833 `823087ec3`, #2947 `b07f64346`, #2919 `33e2e4c13`, #2962 `a4a26ec63`, #2847 `c8b950cb4`, #3114 `c4ebe52de`, #2664 `0e2b6287c`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 16.2, mean 16.1 | | Rendered fps, last 120 s | median 15.1 | For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean). AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:14:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:14:11Z.


Short check, since three verifications already cover this head: still clean on current main, and the docs and switch checks pass. Not built here (Windows-only).

head      c2065b540 (unchanged since lixonik's in-game run, 13:58; Kal0s-design's Windows run, 16:56; MoonEyes' batch run, 17:06)
base      origin/main 45dc41f95, merge base a917c54d6, merged locally without conflict
CI        6 check runs on the head, all green
Command (on the merge, Linux) Result
python -I tests/test_d3d12_switches.py 20 tests, OK
python -I scripts/check_no_game_data.py on the 4 files exit 0

The render-path gate is met on this exact head: MoonEyes' batch of eleven (RTX 4060 8 GB, 610.88, Series S, 330 s in the world) includes #3071 c2065b540. lixonik answered Kal0s-design's three points in the thread, and nothing has been pushed since.

Verdict: ready.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354184581 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7354184581). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:14:11Z. --- **Short check, since three verifications already cover this head: still clean on current `main`, and the docs and switch checks pass. Not built here (Windows-only).** ``` head c2065b540 (unchanged since lixonik's in-game run, 13:58; Kal0s-design's Windows run, 16:56; MoonEyes' batch run, 17:06) base origin/main 45dc41f95, merge base a917c54d6, merged locally without conflict CI 6 check runs on the head, all green ``` | Command (on the merge, Linux) | Result | |---|---| | `python -I tests/test_d3d12_switches.py` | 20 tests, OK | | `python -I scripts/check_no_game_data.py` on the 4 files | exit 0 | The render-path gate is met on this exact head: MoonEyes' batch of eleven (RTX 4060 8 GB, 610.88, Series S, 330 s in the world) includes `#3071 c2065b540`. lixonik answered Kal0s-design's three points in the thread, and nothing has been pushed since. **Verdict: ready.** AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
fiestorra commented 2026-12-02 23:45:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:45:04Z.


VERIFY-3071 — Windows nativo: red then green en el paso de --jobs al hijo

Own commit c2065b540 — apps/leonida/src/main.rs (+24), warm.rs (+54)

Ran at the head

cargo test -p leonida child_args
  warm::tests::child_args_forwards_jobs_only_for_store ... ok
  tests::warm_store_child_args_round_trip_jobs_through_cli ... ok
cargo test -p leonida default_jobs
  warm::tests::default_jobs_caps_by_cpu_and_host_ram ... ok
  translate::tests::default_jobs_caps_by_cpu_and_host_ram ... ok

Negative control (synthetic): I made child_args forward --jobs even without --store (if store || jobs.is_some()), rebuilt and ran:

FAILED: child_args_forwards_jobs_only_for_store
assertion `left == right` failed

It bites, and it is the right thing to bite on: the argument list is a contract between two processes, and "only for the store" is the part a careless edit breaks.

What the change is: --jobs is threaded into the warm library store subprocess (warm --these <list> --store --jobs N), and default_jobs is derived from the CPU count and the host RAM. The round-trip test parses the child's arguments back through the CLI, which is the half that unit-testing child_args alone would miss — one side can spell --jobs=4 and the other can only read --jobs 4.

What I could not test

  • A real warm store run with -j: it drives the shader pipeline child against the title's toolchain; the tests build the argument list and round-trip it.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362379919 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3071#issuecomment-7362379919). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:45:04Z. --- ## VERIFY-3071 — Windows nativo: `red then green` en el paso de `--jobs` al hijo | | | |---|---| | Own commit | `c2065b540` — `apps/leonida/src/main.rs` (+24), `warm.rs` (+54) | **Ran at the head** ``` cargo test -p leonida child_args warm::tests::child_args_forwards_jobs_only_for_store ... ok tests::warm_store_child_args_round_trip_jobs_through_cli ... ok cargo test -p leonida default_jobs warm::tests::default_jobs_caps_by_cpu_and_host_ram ... ok translate::tests::default_jobs_caps_by_cpu_and_host_ram ... ok ``` **Negative control (synthetic)**: I made `child_args` forward `--jobs` even without `--store` (`if store || jobs.is_some()`), rebuilt and ran: ``` FAILED: child_args_forwards_jobs_only_for_store assertion `left == right` failed ``` **It bites**, and it is the right thing to bite on: the argument list is a **contract between two processes**, and "only for the store" is the part a careless edit breaks. **What the change is**: `--jobs` is **threaded into the warm library store subprocess** (`warm --these <list> --store --jobs N`), and `default_jobs` is **derived from the CPU count and the host RAM**. The round-trip test parses the child's arguments back through the CLI, which is the half that unit-testing `child_args` alone would miss — **one side can spell `--jobs=4` and the other can only read `--jobs 4`.** ## What I could not test - **A real warm store run with `-j`**: it drives the shader pipeline child against the title's toolchain; the tests build the argument list and round-trip it. Written with an AI assistant.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3071:upstream-pr/3071'
git switch 'upstream-pr/3071'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3071'
git switch 'upstream-pr/3071'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3071'
git switch 'upstream-pr/3071'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3071'
git switch 'main'
git merge --squash 'upstream-pr/3071'
git switch 'main'
git merge --ff-only 'upstream-pr/3071'
git switch 'main'
git merge 'upstream-pr/3071'
git push origin 'main'
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
ProjectLeonida/mandy!3071
No description provided.