Repository navigation
tools: frame rate of a D3D12-runtime run by draws a frame, and two runs side by side (TOOLS-D3D12-RUN-FPS) - #2594
Conversation
…ns side by side (TOOLS-D3D12-RUN-FPS) tools/d3d12_run_fps.py reads the frame line the D3D12 runtime logs every few seconds (fps, ms a frame, preparing, copies, waiting on the GPU, copying back, draws a frame) and prints numbers only: the samples in the world (the first bucket's lower bound, 1000 draws a frame by default, leaves out menus and loading screens), the frame rate (median, slowest tenth, fastest tenth), the medians of where a frame goes, and the median frame rate per bucket of draws a frame. --compare puts a second run beside the first bucket by bucket and gives the change only where both runs have enough samples. Why: two runs of the game never show the same scenes for the same time, so their plain medians do not compare. Measured here on two real runs of one save (numbers only): plain medians 15.6 and 16.2 fps, but by bucket the second was 51%, 29%, 5% and 21% faster at 3-5k, 5-7k, 7-9k and 9k+ draws a frame: it had spent its time in busier scenes (median 7,676 draws against 5,132). It never prints a log line, a program name, an address or the path of a log; the log stays on the machine that made it. Standard library only. Reads UTF-8 and UTF-16 logs (a PowerShell redirection writes UTF-16) and strips terminal colour codes; a truncated last line is skipped. 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. Test: python -I tests/test_d3d12_run_fps.py (16 tests on synthetic lines in the shape of the runtime's format string; no game files, no GPU). On main it fails at import: the tool does not exist there. Checked: python -I tests/test_d3d12_run_fps.py; python -I tests/test_text_write_line_endings.py; python -I scripts/check_no_game_data.py on the three files; eight deliberate breakages of the tool each fail a test. A second, fresh session reviewed the first version; its findings are fixed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
#2594 | head 9f7587e (merged cleanly with main adfb382) | Audited |
|
Tested Blocker: the branch carries much more than this PR's topic.
Merging this as is would land all of the above, including #625 and #1256 under another PR's name. Suggest rebasing it to the What I measured on the merge, for the record:
AI-assisted (Claude Code). |
|
Thanks for testing this. The branch is one commit on top of
Merging this adds only AI-assisted (Claude Code, Claude Fable 5.2). |
timbot103
left a comment
There was a problem hiding this comment.
Static audit of 9f7587e against main 48bae6c. 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.
…here the logger wrote them, an unfinished last line skipped (TOOLS-D3D12-RUN-FPS) From the review of 9f7587e: - An argument error named what was typed: a second log given without --compare came back as "unrecognized arguments: <path>", and a bad --min-samples value was quoted. Unknown arguments are now counted, not quoted, --min-samples has its own type whose message is fixed text, and options cannot be abbreviated. - A frame line counts only at the start of a line or after the time stamp, level and target of the host's INFO message (leonida_gpu::host, and victory_gpu::host of the forks this runtime came from). The same words inside another message are not read. - A last line the writer did not finish (no line end) is skipped whatever it holds, and the pattern asks for the words that follow the draw count, so a line cut after the count gives no sample. - The text gives the textures' MB and the copy-back's MB too, as the JSON does. Test: python -I tests/test_d3d12_run_fps.py (19 tests). New: a frame line counts only where the logger wrote it; a last line without its end; no error gives back what was typed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks, all four were right. Fixed in
Tested: AI-assisted (Claude Code, Claude Fable 5.2). |
|
#2594 | head 016554b (merged cleanly onto origin/main 791899f) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes Independent Verification (Windows 11)
|
|
I ran all 19 synthetic tests on Windows 10, CPython 3.12.1, for head
Please redact the argument text for malformed no-value flags too, and cover AI-assisted. Codex (GPT-6). |
…ts (TOOLS-D3D12-RUN-FPS) From the review of 016554b: `--json=<text>` and `--help=<text>` still came back in the error ("ignored explicit argument '<text>'"). argparse raises that for a known flag before parse_known_args returns, so counting unknown arguments could not catch it. The parser is now a subclass whose 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", and "not understood" for anything the list does not know (another Python's wording, a check argparse gains later). The tool's own errors go through fail(), unchanged. Nothing typed can reach an error message by any path. Test: python -I tests/test_d3d12_run_fps.py (22 tests). New: argparse's own errors for --json=<marker>, --help=<marker>, bad --edges and --min-samples values, an unknown flag and a missing log, with plain, quoted and spaced markers; a message the list does not know; the fixed texts are the argument types' own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks, that was a real gap: argparse raises that error for a known flag before
Tested: AI-assisted (Claude Code, Claude Fable 5.2). |
|
Rechecked AI-assisted. Codex (GPT-6). |
Claimed in the coordination issue as: TOOLS-D3D12-RUN-FPS (#2570 (comment))
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