D3D12-GPU-AB-PARSE-FINITE-SECONDS: reject non-finite LEONIDA_AB phase duration #2997
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2997"
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 bobcatchris on 2026-12-01T22:53:50Z.
Addresses claim in https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7328405572.
Cause
ab::parse(d3d12/crates/leonida-gpu/src/ab.rs:19) checked*s > 1.0withouts.is_finite(), soLEONIDA_AB=inf,<switch>passed parsing (f64::INFINITY > 1.0). Inab::presented(((now - p.started).as_secs_f64() / asked.seconds) as u64), dividing by+infyields0.0, pinningLEONIDA_ABat phase0forever.Fix
s.is_finite() && *s > 1.0inab::parse.inf,-inf, andnantest cases toab::tests::switches_and_seconds_are_read_and_frames_summed_up.Verification
.is_finite()omitted,ab::tests::switches_and_seconds_are_read_and_frames_summed_upfails (RED_AB_EXIT=101); with the guard,ab::testspasses (4 passed, 0 failed).cargo test --locked -p leonida-gpu --lib -- ab::tests) compiles cleanly.python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/ab.rs: exit 0.AI-assisted
Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T22:58:29Z.
Verified
ef429f923through presented() and pick() in the diagnostics build on Windows. I used a temporary crate test and launched a fresh process per LEONIDA_AB value so the cached environment configuration was independent each time.For inf, -inf, NaN, and 1e309 (decimal overflow), presenting created no phase, emitted no change callback, and left pick(switch) at None. With 2.5 seconds the override started off. Advancing the stored phase start to simulate 3 and 6 seconds elapsed produced exactly two callbacks for the named switch, off to on and back to off. All five runs passed. This checks the timer and override behavior without a game or GPU workload. Codex-assisted.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T07:09:28Z.
VERIFY-2997 — Linux, Fedora 45, Rust 1.98.1, cross-compiled for x86_64-pc-windows-gnu, Wine 11.21, no GPU device, no game files
Verdict: PASS. The red side fails on exactly the line the pull request adds —
parse("inf,LEONIDA_A")returnsSomeon the base, becauseinf > 1.0— and the green side passes it. That is a genuine red-then-green, and it fails for the reason the title says. One thing to flag: two of the three new assertions would pass on the base too, so the whole case rests on theinfone.Head
ef429f92, base the currentmain(0ae5a266), merge base1abef08d, 1 file, +4/−1:d3d12/crates/leonida-gpu/src/ab.rs.1. What it changes
LEONIDA_AB=<seconds>,<switch>[,<switch>..]makes the diagnostics build measure switch combinations in turns: every so many seconds the next phase begins and switch n is on in the phases whose number has bit n. The pull request hardens the one thing that parses the interval a human types:and adds three assertions to the existing test
ab::tests::switches_and_seconds_are_read_and_frames_summed_up:parseis read from the environment once, throughasked(), so a non-finite value can only come from whoever setsLEONIDA_AB, never from the title.2. The new test checks the property that matters
Two things worth saying before the numbers.
The module is feature-gated.
lib.rs:124declares it#[cfg(all(windows, feature = "diagnostics"))] mod ab;, so a plaincargo test -p leonida-gpunever compiles it. My first harness run without the feature reported 703 tests,red_to_green: [], and — the giveaway — zeroab::names on either side: the test could not fail because it did not exist. Re-running the same tool with--features diagnosticsgives 786 tests, and now the discrimination shows. Anyone reviewing this should treat the plain run as having verified nothing about this pull request.Only one of the three new lines discriminates.
parseinf,LEONIDA_ASome(inf)— the buginf > 1.0is true, so it clears the filter-inf,LEONIDA_ANone-inf > 1.0is false; rejected by the base alreadynan,LEONIDA_ANonenan > 1.0is false in IEEE; rejected by the base alreadySo the pull request's fix is entirely carried by the
infcase, and the other two assertions are regression guards documenting intent rather than discriminators. Worth knowing, not a defect.The base failure, captured on the red side (merge base plus only this pull request's test hunks, with
diagnosticson):Line 253 is the
infassertion, as the table predicts. On the head the same fourab::testspass, three runs in a row.The bug is not cosmetic.
asked.secondsis a divisor,ab.rs:193:x / infis0.0for everyx, so the phase number is 0 forever, the guard returns at once, and the A/B never advances once — a run that looks like "the switches never changed" rather than a rejected setting.nancasts to0the same way. The fix returnsNone,asked()isNone, and the switch takes its own variable as the docs say. That is fixing the cause at the parse, not papering over the symptom.3. What the tests do here
ab::tests::switches_and_seconds_are_read_and_frames_summed_up. This is the pull request.watch::many_askers_tests::holes_are_known_until_the_runtime_tells,watch::many_askers_tests::no_mapping_is_lost_between_askers,watch::tests::what_is_left_alone_is_no_known_hole,timeline::report::tests::real_waits_are_recorded_with_who_ended_them.The same tool without
--features diagnosticsreports 703 on each side, 641 passing on both, and none of this pull request: theabmodule is not in the build.4. Any failure I saw, and why it is not this pull request
Four tests fail on both sides, so they predate this change.
Three of them are
watchtests, and they fail identically on the merge base — I ran the base through the same tool and got the same three. They are the address-space bookkeeping module, and they exercise mapping and decommit behaviour that Wine'sVirtualAllocemulation does not reproduce. The pull request touches none of it.The fourth,
timeline::report::tests::real_waits_are_recorded_with_who_ended_them, is timing-dependent by construction: it spawns a worker that sleeps 5 ms and then spins for 30 ms, then assertsms(work) >= 20.0on the recorded span. It relies on the wall clock behaving under Wine while 785 other tests run beside it. It is not in this pull request's file.None of them is
ab::. The oneabtest that changed is the one that went from failing to passing, and it is deterministic (a pure string parse, no device, no clock), so I did not need to repeat it many times — I did anyway, three times, and it was stable.5. What I did not check
abis diagnostics; its tests here are pure functions, so nothing GPU-shaped is exercised. That is also why this one is cheap to verify.LEONIDA_ABrun. I checked the arithmetic by reading the divisor, not by timing a run. I have not confirmed on hardware that a phase really does advance at the interval a human types, nor that the rejection is surfaced somewhere the operator can see (the change makesasked()Nonesilently; whether a warning should be logged is a design call, not a defect I can settle here).LEONIDA_ABacceptance of1e400.f64::from_str("1e400")isOk(inf), which is now rejected as!is_finite()— I reasoned that through rather than running it, and it is the same overflow path asinf. Cheap, but unverified by execution.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:16:03Z.
RUN (in game, grouped): this head
ef429f923was merged withgit merge --no-ff, together with nine other rendering pull requests, ontomainf6dd2242e(no conflicts), and the d3d12 layer was rebuilt from that tree (diag profile, with DLSS). RTX 4060 8 GB, driver 610.88, Windows 11;scripts/play-d3d12.ps1 -SeriesS -Resolution 1080 -FrameGen 2, low-memory profile, keyboard-driven entry into the world and a walking route.Heads in this run: #2854
81a6e94a9, #293668215ad0b, #2939561bbc19c, #2997ef429f923, #3043915d4d5aa, #3045cb30a595a, #30460f19a0819, #3047c33e5b48e, #30482ab0b4b9d, #3051856615ce7.AI-assisted (Claude Code, Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:20:30Z.
Merging. Head
ef429f923merges cleanly withmainbf7886746and does not force a rebase of #2566. Checked on headef429f923: all 6 CI checks green; third-party red/green by imShangLi on this head; an in-game run of at least 381 s with this head merged onto mainf6dd2242e(grouped with nine other rendering pull requests, comment above) showed no device loss, no unhandled exception and no hang; item claimed in the coordination issue; author has earlier merged pull requests; conflict-free merge against main. Merged by MoonEyes.AI-assisted (Claude Code).