Skip to content

d3d12-docs: record LEONIDA_CONSTANTS_ONCE measurements in findings.md - #2888

Open
lixonik wants to merge 3 commits into
ProjectLeonida:mainfrom
lixonik:docs/constants-once-findings-switches
Open

lixonik wants to merge 3 commits into
ProjectLeonida:mainfrom
lixonik:docs/constants-once-findings-switches

Conversation

@lixonik

@lixonik lixonik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-CONSTANTS-ONCE-DOCS (#2570 (comment))

What and why

Follow-up requested when closing #2850 (whose code landed in 357c71023):

  • Adds the Table constant buffers filled once per list (2026-12-01) measurements from leonida-gpu: a list fills the same constant buffer bytes once (D3D12-CONSTANTS-ONCE) #2850 (RTX 3080 10 GB) and the independent RTX 5070 12 GB (621.40) LEONIDA_AB=20,LEONIDA_CONSTANTS_ONCE check to d3d12/docs/findings.md.
  • Regenerates d3d12/docs/switches.md via python -I tools/d3d12_switches.py --out d3d12/docs/switches.md so the F ("named in findings.md") column on LEONIDA_CONSTANTS_ONCE updates to yes (while the LEONIDA_CONSTANTS_ONCE row itself was already present on main).

Tested

  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: passed
  • python -m unittest discover -s tests -p "test_docs_*.py" -v: 57 passed, 0 failed
  • python -I scripts/check_no_game_data.py: clean

GPUs tested: n/a (documentation-only; references measured results from #2850 on RTX 3080 10 GB driver 32.0.16.2140 and RTX 5070 12 GB driver 621.40 / Windows 10 22H2)

AI-assisted: Antigravity (plus separate read-only reviewer subagent)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mechanism and figures check out: LEONIDA_CONSTANTS_ONCE is the toggled! at host.rs:9636, reuse is keyed on (src, len) and re-points via add_slot (host.rs:9629-9664), invalidation is title_written (host.rs:3624-3631), and FillTo::Slots really does re-point every slot at one place (card_steps.rs:645-647, :1185-1189) — bytes read once, no barrier change claimed or made. The 3080/5070 deltas match #2850 and its 5070 comment, and the merged tree's switches.md regenerates clean.

One arithmetic nit: 3,327 / 11,578 = 28.7 %, not 28.8 %. If 28.8 % is the median of per-frame ratios, say so; and note 1.6 MB is 27.6 % of 5.8 MB, so the parenthetical is a count share, not a byte share — as written it invites the wrong comparison.

Four small completeness fixes for a measurement record:

  • state the sign convention ("on minus off"), and give −0.85 its unit;
  • include the 5070's dropped pairs (4 of 9 valid, 5 dropped for draw jumps);
  • add the 3080's OS (the 5070 line says Windows 10 22H2; #2850 says the 3080 is Windows 11);
  • the 3080 paragraph omits the measured card_steps −0.16 that the 5070 paragraph includes.

Minor: −0.77 idle and 30.5 busy are per-arm means, not paired deltas — worth labelling so they aren't read as a 13-pair result.

CI: both red checks are the five Python tests main fixed in 9b7674d64 at 15:54Z, after this run started; they pass on the merged tree, so a re-run should clear them. Merge is clean, and findings.md's other open editors (#2847, #2743) do not share a hunk with this append.

@lixonik

lixonik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@KelboLive Thanks for checking every number against #2850! Addressed all items in d8de91272 and merged origin/main so CI picks up the Python test fixes:

  • Corrected 3,327 / 11,578 to 28.7 % of fills; 1.6 MB so the count share is exact and clearly distinguished from the byte share.
  • Added the sign convention (on minus off), the ms unit on -0.85 ms, the 3080 OS (Windows 11), and the 3080 card_steps delta (-0.16 ms).
  • Labeled the 3080 card idle (7.21 ms off to 6.44 ms on, -0.77 ms) and card busy (30.49 ms off vs 30.48 ms on) numbers explicitly as per-arm means (14 phases each).
  • Added the RTX 5070 dropped-pair count (4 of 9 pairs valid, 5 dropped for draw jumps).

Re-verified tools/d3d12_switches.py --check d3d12/docs/switches.md, test_d3d12_switches.py (19/19), test_docs_*.py (57/57), and scripts/check_no_game_data.py.

@imShangLi

Copy link
Copy Markdown
Contributor

VERIFY-2888 — Linux, Fedora 45, no GPU device, no game files, no title

Verdict: PASS. Records a LEONIDA_CONSTANTS_ONCE measurement in d3d12/docs/findings.md and marks the switch "named in findings" (F = yes) in the generated d3d12/docs/switches.md. Every checkable claim matches the code — including the code's own comment at host.rs:9832, which records the same measurement with the same figures — and the hand-edit to switches.md is byte-identical to what tools/d3d12_switches.py regenerates for that row. The measurements themselves are not reproducible here.

Head d8de9127, base current main (8422def7), merge base 1e3e316c, 2 files, +20/−1: d3d12/docs/findings.md (+19), d3d12/docs/switches.md (+1/−1, one cell).

1. What it changes

  • d3d12/docs/findings.md: a new ## Table constant buffers filled once per list (2026-12-01) section describing the per-draw constant-buffer-view fills (11,578 fills/frame, 3,327 first of their bytes), what LEONIDA_CONSTANTS_ONCE does about them, the measured gains on an RTX 3080 (driver 32.0.16.2140) and an independent RTX 5070 (driver 621.40) check.
  • d3d12/docs/switches.md: the LEONIDA_CONSTANTS_ONCE row's F column (named in findings.md) changes from blank to yes.

2. The claims it makes, and which ones I checked

  • LEONIDA_CONSTANTS_ONCE, on by default, 0 turns it off — checked. host.rs:9832 "With LEONIDA_CONSTANTS_ONCE (on by default; 0: one fill each, as before)"; switches.md "on, 0 turns it off".
  • HostList::constants — checked. host.rs:3753 field constants: HashMap<...>, doc "Table constant buffers [HostList::constants] filled since the list"; the constants() fn at host.rs:9834.
  • FillTo::Slots — checked. host/card_steps.rs:190 variant Slots(Vec<(usize, u32)>); fill_tos() maps each slot to a To::Slot, i.e. the card re-points every slot of a fill it takes — consistent with the doc.
  • LEONIDA_CARD_STEPS=2 — checked. host/card_steps.rs:79 reads it; :360 "LEONIDA_CARD_STEPS=2 does it on the card".
  • constants_line frame-meter count — checked. host.rs:5717 fn constants_line, "For the frame-rate line"; it prints "table constant buffers filled per frame: {:.0} ({:.0} KB), {:.0} of them the first of their bytes in their list ({:.1} %, {:.0} KB)" — matching the doc's fills/KB/first/%/KB format.
  • frame-meter line names copies_fills_ms, steps_ms, card_steps_ms — checked. These are the millisecond form of the SPLIT_NAMES entries copies_fills_ns, steps_ns, card_steps_ns (host.rs:11139, :11132, :11141), which the frame-rate A/B line prints. Consistent.
  • -NoFrameGen — checked. d3d12/scripts/play-nvidia.ps1:76 [switch]$NoFrameGen.
  • The measurement numbers agree with the code's own comment — checked. host.rs:9832 records the same measurement: "Standing in the world, 71 % of these fills repeated bytes already filled in their list (11,600 a frame, 5.8 MB; 3,300 and 1.6 MB the first of theirs; RTX 3080, 2026-12-01). Switched every 20 s in one run (13 pairs): the lists' steps on the submitting thread -0.99 ms a frame, its copies and fills -0.85, the card idle behind it -0.77, the frame's median -0.39 (+-0.14); the card's work the same." The doc gives the same figures with more precision (11,578/3,327 vs the code's rounded 11,600/3,300; 28.7 % first vs 100−71 = 29 %). No contradiction.
  • switches.md F cell — checked. tools/d3d12_switches.py sets F = yes when findings.md names the switch; regenerating the page from the PR's sources produces the exact committed LEONIDA_CONSTANTS_ONCE row (F = yes, same Named in and same words). The hand-edit matches the generator.

3. What the tests do here

  • python3 -I -m unittest discover -s tests -p "test_docs_*.py" — 57 tests, all pass (43.1 s).
  • python3 -I scripts/check_no_game_data.py d3d12/docs/findings.md d3d12/docs/switches.md — exit 0.
  • python3 -I scripts/red_green.py 2888 --no-cargo — "red not constructible: the pull request changes no test" (expected for a docs-only change).
  • git merge-tree --write-tree origin/main pr2888 — merges cleanly.

4. Anything wrong in the text

  • Nothing wrong introduced by the PR. The new ## ... (2026-12-01) heading, **bold** lead-ins and 4-space code/table blocks match findings.md's conventions; the section is appended before the end of the file (no table of contents to update); the repeated-line docs test passes (no duplicated lines).
  • One pre-existing observation, not this PR's fault: the branch is based on an older main, so its committed switches.md still names LEONIDA_RENDER_SCALE_MIN in leonida-loader/hooks.rs while current main (after a later regeneration) names it in leonida-gpu/host/menu.rs. This does not affect the PR's own edit and merges cleanly (merge-tree exit 0); it only means the branch predates that regeneration.

5. What I did not check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants