d3d12: a landing pool asks its limit once a batch, and parks no thread without LEONIDA_AB (D3D12-LAND-POOL-LIMIT-ONCE) #2692
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2692"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T03:51:26Z.
Claimed in the coordination issue as: D3D12-LAND-POOL-LIMIT-ONCE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7267873614)
What and why
Since
ff1874c6f("helper counts by turns"), the two landing pools inland.rshave a limit function. The views pool runs 8 threads with 4 at work, and the records pool runs 10 threads with 6 at work. The records pool's batches are what the submitting thread waits for at the end of a submission. The views pool's batches are the heap pass's "looking at slots".On
main:Pool::helpcalls the limit function before every number it takes and after every wake, while it holds the pool's state mutex.wide(), which runsstd::env::varfor its_WIDEswitch on every call.Pool::eachusesnotify_all. Every batch therefore also wakes the 3 or 4 parked helpers that cannot work. They read the environment under the lock and go back to sleep.This change:
State::limit); helpers compare with that value;LEONIDA_ABdoes not name the_WIDEswitch, as beforeff1874c6f, so no thread is parked;LEONIDA_AB: the wide count is made, and how many take part follows the switch.LEONIDA_VIEW_THREADS,LEONIDA_VIEW_THREADS_WIDEandLEONIDA_RECORD_THREADS_WIDEmean what they meant before.Tested
On Windows 11, from
d3d12\:land::tests::a_pools_limit_is_asked_once_a_batch: a pool with a counting limit runs three batches of 256 items, and the limit must be asked once per batch. Onmainit fails, with the limit asked 4 times in the first batch; with the change it passes.cargo test -p leonida-gpu --locked: 553 passed, 49 ignored.rustfmtwithd3d12/rustfmt.tomlreports nothing in the changed lines.git diff --checkandcheck_no_game_data.pyare clean.build-nvidia.ps1, featuresdiagnostics,dlss,mimalloc) built.land.rs, #2682 and #2569 (git merge-tree).mainthen this branch, twice. Each run went from the menus to the world, then 150 s of a scripted cutscene in the Series S preset. Frame times come from PresentMon 2.6, processor time from the process counters, and the waits from the per-second frame lines (means over the cutscene):How to read it:
mainrun was the session's first start and had an 11 s hitch, so I compare against the second one.GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300.
AI-assisted: yes
Checklist
mainand merges cleanly (also with #2569 and #2682, which touchland.rs).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T03:56:41Z.
Independent native Windows landing-pool verification. I tested
f19b5750fon1d22590b9(clean merge treedf8eb2d84), Windows 11 with MSVC and Rust 1.98.1. The exactcargo test --locked -p leonida-gpu --lib land::testsfilter passed 8 tests, with the benchmark ignored.I also ran a local synthetic probe on
Pool::with_limit. The first callback in each 257-item batch changes the requested limit for the next batch. Across 12 batches alternating limits of 1, 2, and 4, each batch used exactly its starting limit, read the limit once, and called all 257 items exactly once. This passed in 10 fresh processes (30,840 callbacks). The probe exercises the changing-limit worker path directly, without changing process-level A/B configuration.CPU scheduling checks only. No game inputs, GPU dispatch or gameplay timing. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T03:59:32Z.
A note for reviewers: with
LEONIDA_VIEW_THREADSset, nothing changes.Some(threads)arm ofeach_viewis untouched. It still buildsPool::new(name, threads.clamp(1, 16)).Pool::newgives the pool the limitall_threads, which returnsusize::MAX. SoState::limitisusize::MAXfor every batch, and every helper takes part, as before.Pool::eachstill wakes helpers one at a time, as before, becauselimit < self.threadsis false.The only difference on that path: the limit function is called once per batch instead of once per item, and that function is a constant. The existing
landpool tests cover this path.a_pools_limit_is_asked_once_a_batchcovers the pool with a limit.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T07:13:49Z.
Independent check on Windows 11 (Rust toolchain from
d3d12/rust-toolchain.toml, CPU only, no game run). Headf19b5750fmerged (no commit) intomainbbd45f5cc:cargo test -p leonida-gpu --lib --locked:main559 passed, 50 ignored; with this PR 560 passed, 0 failed.land.rsfrommain, tests from this PR:land::tests::a_pools_limit_is_asked_once_a_batchfails (559 passed, 1 failed). The new test catches the old behaviour.cargo clippy -p leonida-gpu --locked -- -D warnings: 9 findings onmain, the same 9 with this PR.mainand does not force a rebase of #2566.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T07:19:20Z.
The
semantic-testsfailure here is not from this change, which only touches Rust files underd3d12/. The same test,test_interp_computed_ij_fallback(ComputedIJDerivativeFallbackTests), also fails in CI onmain(run 46365003804). The other checks pass.Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T10:24:27Z.
Independent
each_viewphase and worker-count check. Testedf19b5750fmerged onto454df8e95(tree46a8ed4a3). A standalone Rust harness compiled the unchanged pool,each_viewand A/B selection code from each tree, with stubs for platform priority and tracing. It counted real OS helper threads through/proc/self/taskand used barriers to flip the A/B bits after every wide worker had taken its first job.main_WIDEvalues set, views / records helpersNaming just
LEONIDA_VIEW_THREADS_WIDEinLEONIDA_ABkept a wide-capable views pool and only five record helpers with the PR. Naming an unrelated switch kept both pools narrow.LEONIDA_VIEW_THREADS=1and=3still took precedence. All 28 process cases passed across both revisions and both diagnostics configurations, with 20 rounds per pool and an exactly-once check for every job. Three extracted stock pool tests passed with the PR. Only the new limit-count assertion failed withmain’s implementation.CachyOS, Rust 1.97.1. Synthetic CPU scheduling check. AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T11:36:11Z.
RUN - in-game gate (Verified by OreoFR), PROVISIONAL - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.
e1fe82f63; B = main + this PR atf19b5750f(git merge --no-ff), diag build ofleonida.exe.play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, standing in the world, warm pipeline cache, 600 s per run. Runs interleaved with main.Result: PASS - 0 device loss, 0 panics, every run alive at the end (653-668 s of world frames).
This run was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T11:47:17Z.
@TheGeogeo the in-game gate on an RTX 4070 (OreoFR, above) passes on this head, and the only red check is
semantic-tests, which comes from the older base (fixed onmainby #2566). Could you merge currentmaininto this branch (a merge, no rebase or force-push) so CI runs again? Merging needs a fully green CI.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T12:08:08Z.
Closing and reopening so that CI runs against current
main: the only red check here (semantic-tests) comes from the older base. The head does not change, so the verdicts above still stand. @TheGeogeo no need to update the branch if this is enough.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T13:42:48Z.
Verified by MoonEyes on head
ba3ea1e06(a merge ofmainon top off19b5750f; the pull request's own change is the same), onmainf9f3ec4c6. Windows 11, Rust toolchain ofd3d12/rust-toolchain.toml.cargo test -p leonida-gpu --lib --locked:main563 passed, 52 ignored; with this pull request 564 passed, 0 failed. Red:land.rsofmainwith this pull request's tests failsa_pools_limit_is_asked_once_a_batch, 1 of 564.-SeriesS -FrameGen 2, standing, 600 s,main+ #2692 + #2693 + #2701 in one build: no device loss, no unhandled exception, median 17.8 fps in the world. One run, the three together, so it says nothing of this one's gain; the picture was not looked at.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T13:43:27Z.
Merging. Head
ba3ea1e06merges cleanly withmainf9f3ec4c6and does not force a rebase of #2566. Verdict with red/green and a 600 s in-game run on this head above; OreoFR's gate on an RTX 4070 and merzleckeier's, ecox982745's checks were on the head before main was merged in. Its CI is green. main's Runtime workflow is red for a known reason (macos, ps_exp_f32_denorm_rt); merging green pull requests meanwhile is agreed with aslan2142. Merged by MoonEyes.AI-assisted (Claude Code).