gpu: the split list ahead's textures half runs on one kept thread (D3D12-AHEAD-SPLIT-KEPT-THREAD) #2828
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2828"
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 OreoFR on 2026-12-01T04:02:26Z.
Claimed in the coordination issue as:
D3D12-AHEAD-SPLIT-KEPT-THREAD(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7299620961). enlighted-agent, who owns the reaper/scratch work, confirmed on the agents' bridge that this one was free.What and why
With
LEONIDA_AHEAD_SPLIT(set by the launcher),record_ahead_split(queue.rs) made a new OS thread with an 8 MiB stack every frame for the textures' half of the list ahead, chose the fast cores for it (cores::keep_on_fast_cores, a CPU-set call and an info line in the log) and joined it. The line's thread waits for that half, so the spawn, the CPU-set call and the log line were on its path. On an RTX 4070 Laptop / Core Ultra 7 155H the log had 14,271 of those lines in about 2.5 minutes of play.Now one thread is kept for it (
queue::beside::Kept): made at the first split, pinned once, handed each frame's textures half through a channel and waited for, with the same panic handling and the same fallback (no thread → both halves here, one after the other).LEONIDA_AHEAD_KEPT_THREAD(on;0brings back the thread made each frame), readable byLEONIDA_ABfor an A/B in one binary.d3d12/docs/switches.mdregenerated withtools/d3d12_switches.py(--checkpasses).Measured (one binary,
LEONIDA_AB=10,LEONIDA_AHEAD_KEPT_THREAD)RTX 4070 Laptop 8 GB, NVIDIA 621.40, Core Ultra 7 155H, Windows 11 Pro;
-SeriesS -NoDlss -NoFrameGen, standing, 600 s in the world, the steady phases only (18 a side):queueline)The wait for the list ahead halves; the frame time moved by less than its spread, so no frame-rate claim.
d3d12_ab_compare.py phases(24 pairs, draw jumps left out): "no clear difference" on the median frame. 0 ERROR lines and no device loss in the run.Tested
queue::beside::tests::pieces_run_on_one_thread_made_once_and_a_panic_stays_in_its_piece: 200 pieces run on one thread (not the caller's), its start runs once, a piece that panics returnsErrand the same thread runs the next.Kept::startspawning a thread per piece (the old behaviour), the test fails at "one thread for all the pieces".cargo test --locked -p leonida-gpu: 591 passed, 0 failed on this branch merged withmain9d231d373;-p leonida-hle242/0. Note:main9d231d373does not build itsleonida-gputests (mod asbench;without its file, fixed by #2825), so that run used a local, untracked emptyindirect/asbench.rs, removed afterwards. On the base90c514437: 590 passed (589 + the new test).cargo clippy -p leonida-gpu --all-targets --features diagnostics: no warning in the changed lines.scripts/check_no_game_data.pyon the changed files: clean.GitHub CI will show
main's current reds (tools/make_amplify_dxil.py, fixed by #2827) until those land.AI-assisted: yes (Claude Code, Claude Opus 5.5, agent
oreofr-agentfor OreoFR). GPU: RTX 4070 Laptop 8 GB, driver 621.40.🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T05:01:41Z.
Review: COMMENTED
Verified on this box:
cargo test -p leonida-gpu --libis 591 passed / 0 failed / 53 ignored,queue::11/0,test_d3d12_switches.py19 OK andd3d12_switches.py --checkclean. (One note: the branch base precedes #2825, so the full lib run needs an empty untrackedindirect/asbench.rs; harmless, but a rebase will remove it.)The kept thread holds only the job channel, the once-run pin and
no_drain_here— no list, epoch or buffer crosses a frame: each job takes a fresh list from the global idle pool, records, closes and hands it back,PASS_BUDGETis set and cleared inside the part, and ordering is stillbuffers.chain(textures)(queue.rs:606). A dead worker cannot hang the caller:sendfails toNone, orrecvreturnsErrand the textures half is recorded on the line's thread after the buffers half. Mutation confirms both: spawning a thread per piece fails the new test ("one thread for all the pieces") and removing thecatch_unwindfails withRecvErrorrather than hanging.What is missing is coverage of the thing that changed at the call site: nothing tests
record_ahead_splititself — the ordering, the fallback path, or that the two halves are the same lists as withLEONIDA_AHEAD_KEPT_THREAD=0. The new test coversKeptalone, so a later edit that recorded textures before buffers, or kept a list across jobs, would pass. An integration test needs a seam forahead_of_frame_part(or a fakeHostList).Minor: once the worker dies, every frame silently pays the textures half on the line's thread; a one-time
warn!would explain the lost pinning.Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-01T08:10:39Z.
RUN (in-game A/B only, RTX 3090; #2828 head
169c99060built as it is,d3d12/scripts/build-nvidia.ps1 -NoDlss, diag profile; not merged with a newermain. No out-of-game checks here: no red/green, tests or clippy.)scripts/play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGenat the launcher's defaults, the same save restored, standing still,LEONIDA_NO_WATCHDOG=1,LEONIDA_AB=10,LEONIDA_AHEAD_KEPT_THREAD(switch by turns every 10 s, the first 4 s of each phase left out); warm-up and a throwaway run first; 601 s measured, nothing else running on the PC.Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.