tools: frame rate of a D3D12-runtime run by draws a frame, and two runs side by side (TOOLS-D3D12-RUN-FPS) #2594
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2594"
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 owenjbendon-creator on 2026-11-28T22:51:33Z.
Claimed in the coordination issue as: TOOLS-D3D12-RUN-FPS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7246804950)
What and why
A game-run test compares two runs (#2464, part A), and two runs of the game never show the same scenes for the same time. Their plain medians then mislead: the run that spent its time in a busy street reads slower than the one that stood in a room, whatever was changed.
tools/d3d12_run_fps.pyreads the frame line the D3D12 runtime logs every few seconds (d3d12/crates/leonida-gpu/src/host.rs: fps, ms a frame, preparing, copies, waiting on the GPU, copying back, draws a frame) from the launcher's log, and prints numbers only:--compare <log B>puts a second run beside the first, bucket by bucket, and gives the change only for buckets with enough samples in both runs (--min-samples, 5 by default).--jsonprints the same numbers as JSON.It never prints a log line, a program name, an address or the path of a log (not in an error message either), so its output can go in a
RUNblock or a pull request while the log stays on the machine that made it. Standard library only, run withpython -I. It reads UTF-8 and UTF-16 logs (a PowerShell redirection writes UTF-16), strips terminal colour codes and skips a truncated last line. The pattern takes only what the runtime's format string writes (bounded lengths, nothing in front of the first number), so no other text in a log reads as a frame line.This adds a tool and five lines to the Reporting section of
docs/running.md. No runtime or translator code is touched.An example of why the buckets matter (numbers only)
Two real runs of one save on one machine, with different builds of the layer:
The plain medians say "the same". By bucket B is 51%, 29%, 5% and 21% faster: it had spent its time in busier scenes.
Tested
python -I tests/test_d3d12_run_fps.py: 16 tests on synthetic lines written in the shape of the runtime's format string (the frame line read field by field, other lines and colour codes ignored, a line cut short just before its end, a UTF-16 log, text that only looks like a frame line refused, menus left out, bucket edges, tenths by nearest rank, the whole text of one run, the comparison where plain medians mislead, the samples a bucket needs, a run at 0 fps not divided by, text and JSON agreeing, no log text and no path printed, bad options refused). No game files, no GPU.mainthe test file fails at import: the tool does not exist there.python -I tests/test_text_write_line_endings.py: passes (the tool writes no file).python -I scripts/check_no_game_data.py tools/d3d12_run_fps.py tests/test_d3d12_run_fps.py docs/running.md: clean.Not tested: a log from a current
mainbuild ofleonida.exeon this machine. The example logs are from builds of the same lineage with the same frame line; the regular expression follows the format string onmainas ofadfb3821a.GPUs tested: none needed (no GPU code). The example runs were made on an NVIDIA GeForce RTX 3090, driver 610.88, Windows 10 Pro 22H2 (19045), Ryzen 7 9800X3D.
AI-assisted: yes (Claude Code, Claude Fable 5.2). A second, fresh session reviewed the diff before this was opened; what it found (thin assertions on the printed text, a typed path echoed in an error, an unbounded pattern, an option that could mislabel a bucket) is fixed in this one commit.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:06:24Z.
#2594 | head
9f7587e193(merged cleanly with mainadfb3821a2) |python -I tests/test_d3d12_run_fps.py -v+ live Windows PowerShellOut-File -Encoding unicode(UTF-16LE BOM + CRLF)--compareCLI probe +python -I tests/test_docs_cli_flags.py| red on main:ModuleNotFoundError: No module named 'd3d12_run_fps'(tools/d3d12_run_fps.pyabsent onmain) | green on PR+main:16 ran, OK(test_d3d12_run_fps.py), live PowerShell UTF-16LE BOM + CRLF--compareexited0(+25%bucket delta,0log-line or file-path leaks),4 ran, OK(test_docs_cli_flags.py),17 ran, OK(test_docs_links.py), and5 ran, OK(test_docs_repo_paths.py) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited
9f7587e193(tools/d3d12_run_fps.py,tests/test_d3d12_run_fps.py, anddocs/running.md) on Windows 11 — first execution of this PR — confirmingFRAME_LINEmatches thetracing::info!format string ind3d12/crates/leonida-gpu/src/host.rsfield-for-field, strips ANSI colour sequences, handles both UTF-8 and Windows PowerShell UTF-16LE BOM + CRLF logs, redacts input paths onOSError, and never echoes raw log text. Also verifiedtests/test_ci_registration.py,tests/test_text_write_line_endings.py,tests/test_docs_encoding.py, andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:41:36Z.
Tested
9f7587e19merged (no commit) withmainaa918e5d9: Python 3.12.4, Rust 1.98.1, Windows 11 10.0.26300, CPU only (no game run).check_no_game_data.pyis clean.Blocker: the branch carries much more than this PR's topic.
git log aa918e5d9..9f7587e19lists 16 commits. Only the last one (9f7587e19,tools/d3d12_run_fps.py) is the TOOLS-D3D12-RUN-FPS item. The others are:merges of #625, #1256, #1205, #1022 and #1001, plus
bvh_index(BUILD-1533),check.py/build.py(TEST-CHECK-UNSUPPORTED-SKIP, TEST-CHECK-F16-FALLBACK) and anx64_recomptest fix;three runtime changes in
d3d12/crates/leonida-gpu, which the description does not mention:bd06eb904: every host present is held to 0.9 of the recent mean interval. This is on by default (LEONIDA_PRESENT_SMOOTHunset gives 0.9), so it changes frame pacing for everyone.c7fcf49a7: Reflex sleeps and markers under frame generation (LEONIDA_FG_MARKERS).eaecc6ac1: A/B jitter lines.LEONIDA_PRESENT_SMOOTHandLEONIDA_FG_MARKERSare not documented in any.mdat this head.Merging this as is would land all of the above, including #625 and #1256 under another PR's name. Suggest rebasing it to the
d3d12_run_fpscommit alone, with the pacing changes as their own pull request.What I measured on the merge, for the record:
test_progress_dashboard.py, whose one README failure (test_default_repo_is_the_one_the_readme_clones) is the same on plainmain. With the tools back tomain, all 8 fail (fortest_d3d12_run_fps.py, the module does not exist).cargo test -p leonida-gpu --lib --lockedgives 517 passed and 0 failed on the merge, against 515 and 0 onmain. The 2 new tests pass (fg::reflex_frame_tests::reflex_frames_follow_the_titles_events,smooth::tests::presents_are_held_to_a_fraction_of_the_running_mean). Warnings are unchanged (10). The pacing itself is not checked in the title.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by owenjbendon-creator on 2026-11-28T23:45:06Z.
Thanks for testing this. The branch is one commit on top of
main, though; nothing else comes with it.adfb3821a.git rev-list --count origin/main..9f7587e19gives 1.aa918e5d9is an oldermain: it is an ancestor ofadfb3821a, 24 commits back (git rev-list --count aa918e5d9..adfb3821a). Sogit log aa918e5d9..9f7587e19also lists whatmaingained in between. The merges of #625, #1256, #1205, #1022 and #1001, and the threeleonida-gpucommits (bd06eb904,c7fcf49a7,eaecc6ac1), are already onmain(git merge-base --is-ancestor <commit> origin/mainholds for each). They are not part of this pull request and merging it does not land them again.Merging this adds only
tools/d3d12_run_fps.py,tests/test_d3d12_run_fps.pyand the paragraph indocs/running.md. No rebase is needed: it merges cleanly withmainas ofa9e247cd6.AI-assisted (Claude Code, Claude Fable 5.2).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:06:44Z.
Review: COMMENTED
Static audit of
9f7587e19against main48bae6cad. Please fix argument-error redaction before merge. At tools/d3d12_run_fps.py:174, omitting --compare between two log arguments makes argparse echo the second path to stderr. Invalid --min-samples values are echoed too.At tools/d3d12_run_fps.py:65, anchor the match to the start of a bare frame line or the host INFO message. At line 45, an EOF cut after the draw count still produces a sample. Add coverage for both cases. At line 131, include the texture and copy-back MB medians in text so it matches JSON.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by owenjbendon-creator on 2026-11-29T01:15:43Z.
Thanks, all four were right. Fixed in
016554bef(a second commit, so the first review's head stays as it was):--comparenow reads1 argument not understood: one log, and a second after --compare; unknown arguments are counted, not quoted.--min-sampleshas its own type, whose error is fixed text (a whole number, 1 or more), and options cannot be abbreviated. The only argparse messages left are its own fixed ones (expected one argumentand the like).INFOmessage (leonida_gpu::host, andvictory_gpu::hostof the forks this runtime came from). The same words inside another message, after other text, at another level or under another target are not read., dropped), so the same cut with a line end is refused too.Tested:
python -I tests/test_d3d12_run_fps.py, 19 tests (three new: a frame line counts only where the logger wrote it; a last line without its end is skipped; no error gives back what was typed).test_text_write_line_endings.py,test_docs_cli_flags.pyandcheck_no_game_data.pyon the changed files pass. Each of the new rules, broken on purpose in a copy, fails a test.AI-assisted (Claude Code, Claude Fable 5.2).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T02:12:48Z.
#2594 | head
016554bef3(merged cleanly onto origin/main791899f652) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesIndependent Verification (Windows 11)
016554bef3acrossdocs/running.md,tools/d3d12_run_fps.py, andtests/test_d3d12_run_fps.py, and verifiedFRAME_LINEmatchesd3d12/crates/leonida-gpu/src/host.rs'stracing::info!frame summary format string ({fps:.1} fps, {ms:.1} ms/frame ({cpu:.1} preparing: copies {copy_ms:.1} ms {copy_mb:.1} MB, textures {texture_ms:.1} ms {texture_mb:.1} MB; {gpu:.1} on the GPU; {back_ms:.1} copying back {back_mb:.1} MB), {draws:.0} draws/frame, ...).python -I scripts/check_no_game_data.py docs/running.md tools/d3d12_run_fps.py tests/test_d3d12_run_fps.pypassed (rc=0).#2594 + origin/main791899f652):python -I tests/test_d3d12_run_fps.py -v->19/19passed (0skipped,OK,0.208s), covering UTF-8 and UTF-16 BOM PowerShell log decoding, ANSI escape stripping, truncated last-line handling, bucketed--comparelike-for-like FPS comparisons,allow_abbrev=False, and strict path/log-text suppression in both stdout and error diagnostics.python -I tests/test_ci_registration.py->18/18passed (OK)test_docs_table_rows.py(2/2),test_docs_repo_paths.py(5/5),test_docs_encoding.py(1/1),test_docs_env_vars.py(5/5) -> allOK.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T02:21:09Z.
I ran all 19 synthetic tests on Windows 10, CPython 3.12.1, for head
016554bef3697bcb705f9ea3360fabeb9a4841b5merged intomain04f484006e. All passed. One argument-redaction case remains.python -I tools/d3d12_run_fps.py baseline.log --json=synthetic-private-nameexits 2 and printsargument --json: ignored explicit argument 'synthetic-private-name'to stderr.--help=synthetic-private-namedoes the same. No input file is needed. These are recognized flags, so argparse reports the error beforeparse_known_argscan return an unknown-argument list.Please redact the argument text for malformed no-value flags too, and cover
--json=<marker>and--help=<marker>alongside the existing malformed numeric options.AI-assisted. Codex (GPT-6).
Imported from ubiquitarianism/leonida. Originally posted by owenjbendon-creator on 2026-11-29T02:25:34Z.
Thanks, that was a real gap: argparse raises that error for a known flag before
parse_known_argsreturns, so counting the unknown arguments could not catch it. Fixed inbefe3aa13, and closed for the whole class rather than for the two flags:error()rewrites every message argparse raises from a short list of fixed texts, with the option's own name where it names one:takes no value,needs a value, the three texts of the tool's own argument types,a log is needed, andnot understoodfor anything the list does not know (another Python's wording, a check argparse gains later). The tool's own errors go through a separatefail(), unchanged.python -I tools/d3d12_run_fps.py baseline.log --json=synthetic-private-namenow printsargument --json: takes no value, and--help=synthetic-private-nameprintsargument -h/--help: takes no value.Tested:
python -I tests/test_d3d12_run_fps.py, 22 tests. New:--json=<marker>,--help=<marker>, bad--edgesand--min-samplesvalues, an unknown flag and a missing log, each with a plain marker, one with quotes in it and one with a space; a message the list does not know, named and unnamed; and the fixed texts checked against what the argument types raise. Letting argparse's messages through in a copy fails those tests.test_text_write_line_endings.py,test_docs_cli_flags.pyandcheck_no_game_data.pyon the changed files pass.AI-assisted (Claude Code, Claude Fable 5.2).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-29T02:47:15Z.
Rechecked
befe3aa137c7e0f729906a1438b99dfacb8f669amerged intomainc8bf0e7b65on Windows 10 and CPython 3.12.1. All 22 tests passed. The new malformed-flag test failed with the previous parser and passed with this update. Both--json=<marker>and--help=<marker>now report the flag error without the supplied value.AI-assisted. Codex (GPT-6).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T15:29:05Z.
Re-verified by OreoFR at head
befe3aa13on main91bab934d: READY — red 1 fail → green 22 OK; ctest/link n/a (Python tool only); head unchanged since the earlier verification https://github.com/ProjectLeonida/mandy/pull/2594#issuecomment-7249646753 (lixonik; no earlier OreoFR run on this PR). Windows 11, RTX 4070 Laptop 8 GB, NVIDIA 621.40. AI-assisted (Claude Code, Claude Opus 5.5).tests/test_d3d12_run_fps.py):python -I -m unittest discover -s tests -p test_d3d12_run_fps.pyerrors on import,d3d12_run_fpsis not in main.git merge --no-ff, no conflict): 22 tests OK.Ready to merge per the maintainers' plan.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-29T17:18:17Z.
Verification of this one on current
main, since it is a new tool and nobody has said whether it still applies.I cherry-picked all three commits of the branch (
9f7587e19..befe3aa13) ontoorigin/main4364a4fa6:The branch is 536 commits behind, so it wants a rebase before it goes in, but the change itself still applies to today's tree and its tests hold, including
docs/running.md, whichmainhas touched twice since the branch was cut.One correction of my own that is worth writing down, because it nearly turned into a false report: my first attempt cherry-picked only the tip commit
(
befe3aa13) and git answered with a delete/update conflict, which reads like the branch fightsmain. It does not - the tool is created by the first ofthe three commits, so cherry-picking the tip alone asks git to modify a file that is not there. For a pull request with several commits the range is what has
to be applied, not the head.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T05:39:35Z.
Independent verification on this machine (Windows 11, Python 3.13.14). New tool plus its tests, and the claims in the commits hold up under a smoke run.
1. It applies.
merge-treeclean; the three commits cherry-pick ontomain1d22590b9without a conflict. Three files,675 insertions(+):tools/d3d12_run_fps.py(new),tests/test_d3d12_run_fps.py(new) anddocs/running.md.2. Its tests pass:
3. The behaviour the last two commits describe is observable directly, which is why I ran the tool rather than only its tests:
--framesis not an option of this tool, so this is the fixed-text path: the message does not repeatabc, which is what016554bef("no argument comes back in an error") andbefe3aa13("an error of argparse's own is rewritten from fixed text") claim.What the negative control cannot do: both the tool and its test are new files, so there is no
mainversion to revert - the same shape as #2651 and #2645, where a test that only exists with its feature cannot demonstrate the absence of that feature. What compensates here is the smoke run above, which exercises the real entry point.What I did not test: the measurement itself - frame rate from a real D3D12-runtime log with
--compare,--edgesand--min-samples. That needs a log from aleonida.exerun, which this machine cannot produce (nocargo).Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T10:04:28Z.
Merging. Head
befe3aa13merges cleanly withmain6dec36053and does not force a rebase of #2566. New tool, so no red is possible; fiestorra's check is above. On Windows 11 on main + this PR its 22 tests and the 13 docs test files pass, I read the tool, and it reads the log of a real 600 s run of mine. The branch's red CI jobs come from its old base as far as I read them (files it does not touch, several of which pass here on current main). Merged by MoonEyes.AI-assisted (Claude Code).