Repository navigation
gpu: the split list ahead's textures half runs on one kept thread (D3D12-AHEAD-SPLIT-KEPT-THREAD) - #2828
Conversation
… the run (LEONIDA_AHEAD_KEPT_THREAD, on) With LEONIDA_AHEAD_SPLIT, record_ahead_split 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 and logged a line, all on the path of the line's thread, which waits for that half (14,271 such lines in about 2.5 minutes of play on an RTX 4070 Laptop / Core Ultra 7 155H). One thread is now kept for it (queue::beside::Kept, made at the first split, pinned once); each frame's half is handed to it and waited for, with the same panic and fallback behaviour. LEONIDA_AHEAD_KEPT_THREAD=0 brings back the per-frame thread, and LEONIDA_AB can switch it. Measured with LEONIDA_AB every 10 s on that machine (18 steady phases a side): the line's thread stood 2.5 ms a frame for the list ahead with it, 5.2 ms without; the frame median moved 55.6 -> 54.4 ms, within its spread. switches.md regenerated (it also picks up two rows main had stale). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thread # Conflicts: # d3d12/docs/switches.md
KelboLive
left a comment
There was a problem hiding this comment.
Verified on this box: cargo test -p leonida-gpu --lib is 591 passed / 0 failed / 53 ignored, queue:: 11/0, test_d3d12_switches.py 19 OK and d3d12_switches.py --check clean. (One note: the branch base precedes #2825, so the full lib run needs an empty untracked indirect/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_BUDGET is set and cleared inside the part, and ordering is still buffers.chain(textures) (queue.rs:606). A dead worker cannot hang the caller: send fails to None, or recv returns Err and 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 the catch_unwind fails with RecvError rather than hanging.
What is missing is coverage of the thing that changed at the call site: nothing tests record_ahead_split itself — the ordering, the fallback path, or that the two halves are the same lists as with LEONIDA_AHEAD_KEPT_THREAD=0. The new test covers Kept alone, so a later edit that recorded textures before buffers, or kept a list across jobs, would pass. An integration test needs a seam for ahead_of_frame_part (or a fake HostList).
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.
|
RUN (in-game A/B only, RTX 3090; #2828 head 169c990 built as it is,
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40. |
…thread # Conflicts: # d3d12/docs/switches.md
Claimed in the coordination issue as:
D3D12-AHEAD-SPLIT-KEPT-THREAD(#2570 (comment)). 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 gpu: drop the 'asbench' module declaration whose file was never committed #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