launcher: the output pump takes a bounded batch a turn, so the window answers with -Log off (LAUNCHER-OUTPUT-PUMP) #3192
Closed
leonida/mandy
1mshy wants to merge 0 commits from
fix/launcher-output-pump into main
pull from: fix/launcher-output-pump
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3192
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/launcher-output-pump"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: LAUNCHER-OUTPUT-PUMP
Fixes: #3175
What and why
With "Log to a file (-Log)" unchecked, the runtime's stderr comes through the launcher's pipe.
Launcher.pump(
tools/leonida_launcher.py) drained the reader thread's whole queue in one Tkaftercallback, with aninsertand asee("end")per line.see("end")forces a layout pass, about 2.5 ms of the ~3 ms a line costs. Tkcould not handle clicks or redraw until the queue was empty: 30,000 queued lines held the window for 90 s, and while
the runtime wrote faster than about 400 lines/s the callback never returned. With -Log on, the pipe stays quiet,
which is why the launcher stayed responsive in that case.
take_output(lines, limit=OUTPUT_BATCH): takes at most 2000 queue items per turn without waiting, in order,and joins each run of lines from one process into one item, so the output box gets one insert and one
seeper run.pump()uses it. The status heuristic (state_for_line) is applied over the run and set once. A turn that leaveslines queued comes back after
OUTPUT_RESUME_MS(10 ms) instead of 100 ms, so a backlog drains fast while clicksand redraws run between turns. Exit, update-check and stale-process handling are unchanged.
Tested
macOS, Python 3.13.5, Tk 8.6.14:
python -I tests/test_leonida_launcher.py: 28 tests OK (2 new:OutputPumpTests)python -I tests/test_shell_launchers.py: 7 OKpython -I tests/test_launcher_serve.py: 10 OKpython -I tests/test_win_launchers.py: 6 run, 5 skipped (Windows-only)python -I scripts/check_no_game_data.py(all tracked files): cleanpython -m compileall -q make_game.py tools tests: OKpython -m unittest discover -s tests -p "test_docs_*.py": 57 OKRed/green:
python -I scripts/red_green.py fix/launcher-output-pump --base origin/main --no-cargo --mutatereports red then green. Both new tests fail on main and pass with the fix; the other 24 pass on both. The mutation
pass catches undoing
take_output. It does not catch undoing thepump()hunk, becauseLauncheris nested inrun_gui()and can't be reached without a display. A Tk benchmark (below) covers that.Tk measurement (real
Textwidget set up like the output box; a 5 ms timer stands in for a click):The independent reviewer reproduced these figures. It also ran a live producer: before, 1,000 lines/s gave one
7.4 s turn; after, at 50k–300k lines/s, turns stay at 4–6 ms and the timer is at most 20 ms late.
Not run: Windows (
Launcher.bat) by hand. The fix is platform-independent Tk/queue code, but nobody has clicked thereal launcher on Windows with the game.
GPUs tested: n/a (launcher UI only, no GPU work)
AI-assisted: yes. Work: Claude Opus 5.5 (
claude-opus-5-5). Independent read-only reviewer: Claude Opus 5.5(
claude-opus-5-5); no blockers. Its nits (a line over 120 characters, commit-message precision) are applied.Checklist
main(45dc41f95) and merges cleanly.docs/design.md— n/a, no translator change.Verified here: it applies on the current
main, its two new tests pass, and the launcher suite is green - but the change carries something the body does not mention.The fix is the right shape for #3175:
Launcher.pumpdrained the reader thread's whole queue inside one Tkaftercallback, with aninsertand asee("end")per line, so a chatty runtime (stderr with-Logoff) starved the event loop. A bounded batch per turn is the standard answer, and the two tests pin exactly the property that makes it one - a turn takes at most the batch and leaves the rest queued, and runs stay joined per process and in order.What the body does not mention: the same diff changes
precompile_all's default fromFalsetoTrueand rewritesswitch_argsto emit-PrecompileUsedwhen it is off - that is #3172's territory, not #3175's, and a reviewer reading "the output pump takes a bounded batch" will not expect it. It may be a deliberate follow-up to #3172 (which merged today); if so it deserves its own line in the body, and if it is drift, it deserves its own pull request.What I could not test: the unresponsiveness itself. That needs the launcher's window with a runtime writing to a pipe, and this session has no interactive desktop - the tests hold the batch logic, not the event loop it protects.
AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Third-party verification of #3192 (LAUNCHER-OUTPUT-PUMP, fixes #3175)
b713fdd8da6066fc06cf73636257e43f7be96610, merge base45dc41f95(= currentorigin/main). Merges cleanly (git merge-tree --write-tree origin/main pr/3192). GitHubmergeable_state: blocked(review required); no check runs or statuses reported on the head sha yet.tools/leonida_launcher.pyor #3175.LAUNCHER-OUTPUT-PUMP,#3175and comments by the author. I found noclaiming:ordone:line for this item, even though the body says "Claimed in the coordination issue as: LAUNCHER-OUTPUT-PUMP".Tested here (Linux, Python 3.13.18, detached checkout of the head, which equals the merge with
main):Red/green,
python3 -I scripts/red_green.py pr/3192 --base origin/main --no-fetch --no-cargo --mutate:As the PR says, nothing tests the
pump()hunk (Launcheris nested inrun_gui()). This machine has notkinter, so I could not reproduce the Tk timings.Review
take_output(tools/leonida_launcher.py:471) keeps queue order and joins runs by process identity (is). Non-line items (exit,update) split runs, so ordering relative to an exit is preserved.pump()(tools/leonida_launcher.py:792): the per-runstate_for_linefold gives the same final state as the old per-line calls. Callingset_stateonly on a change is equivalent becauseset_stateonly setsself.stateandstatus_var. The rescheduling at :817 (10 ms while the queue is non-empty, else 100 ms) is sound. The exit and stale-process handling is unchanged.Textwidget still grows without bound over a long-Log-off session (pre-existing).Defects
claiming: LAUNCHER-OUTPUT-PUMP/done: LAUNCHER-OUTPUT-PUMP -> #3192there.Verdict: defects (claim only). The code is correct, small and on one topic; red then green confirmed here. It is ready once the claim is posted. A Windows
Launcher.batclick-through with-Logoff would still be useful.AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Verified PR #3192 (
b713fdd8d) merged cleanly ontomain(f1a559851) on Windows 10 x64:python -I scripts/check_no_game_data.pyPASS.b713fdd8dontof1a559851):python -I tests/test_leonida_launcher.py-- 28 tests, OK (0.267 s).maintools/leonida_launcher.py+ PRtests/test_leonida_launcher.py): FAILED (errors=2) on the two new output-pump batch tests.Verdict: PASS (Python unit tests; no game launch).
AI-assisted: yes (Antigravity).
Ran natively on Windows 11, head
b713fdd8dmerged into currentmain(8d82a34ae, clean merge). Python 3.11 with Tk 8.6.The unit tests are already covered above, so briefly: the launcher test file has 26 tests on
mainand 28 on the merge, all green, and the two newOutputPumpTestserror onmain's launcher. Same result as the others.What nobody could run yet is the part the PR is about, the Tk event loop. Tk is available here, so I ran the real
pump,append,read_outputandset_statebodies (pulled from the file on each side, not rewritten) against aTextset up like the launcher's output box (word wrap, Consolas 9, scrollbar). Output came from a throwaway Python child writing to the pipe, never the game. A 5 msafterheartbeat measured how long the window went without getting a turn.Measured, PR vs main
Text, before I matched the launcher's)\rprogress runs of 20k each, then 1000 linesOn
mainthe window does not get a single event until the whole backlog is in the box. With the PR it keeps answering the whole time. Take the absolute numbers as rough; the difference is three orders of magnitude.Ordering and exit (measured). In every case the box text matched the child's bytes split on
\nand decoded witherrors="replace", plusExited with code 0.at the very end. Nothing was lost, duplicated or reordered. The unterminated last line arrives at EOF. The exit line only shows up after the whole backlog has been drawn, sinceread_outputqueuesexitafter EOF andtake_outputkeeps queue order.Limits worth knowing (not defects of this PR)
queue.Queue()(read). A child that writes faster than the box draws just makes it grow. Measured: the 2 s flat-out writer peaked at about 2.7M queued items, which then drained at roughly 120k lines/s while the window kept answering. So the window stays usable, but a runtime that spams for minutes leaves a long tail. I did not measure process memory.readlineonly splits on\n(read), so\r-only progress lines show up as one line when the next\narrives. Same as onmain.Textwidget itself still grows without limit, as already noted above.Correction to the first comment. The diff against current
mainis 2 files,tools/leonida_launcher.pyandtests/test_leonida_launcher.py, with only the pump change. There is noprecompile_allorswitch_argschange in this head (measured withgit diff).Other open PRs touching
tools/leonida_launcher.py(git merge-treeagainst the PR head)pump()infoandrailkinds (read). It does not replace the pump, so whoever merges second has to keep the bounded loop or #3175 comes back.take_outputpasses non-linekinds through unchanged, so the new kinds fit as they are.pump()F1 settings applied.(read). With runs joined into one item, that check has to move into thefor line in valueloop, or it misses lines in the middle of a batch.Not checked: a real
Launcher.batclick-through with-Logoff and the actual runtime, the fullLauncherwindow (I tested the pump methods with a matching output box and stubbed status widgets), process memory, Linux/macOS Tk.GPUs tested: n/a (Python launcher tests only).
AI-assisted: yes (Claude Code).
VERIFY-3192 — Windows nativo:
red then greenen el bombeo de la salidab713fdd8d—tools/leonida_launcher.py(+76),tests/test_leonida_launcher.py(+35)Ran at the head
Negative control: the commit's own hunk does not revert cleanly (the branch also carries a merged
mainon that file), so I putmain'sleonida_launcher.pyback and re-ran:It bites.
What the change is: the launcher's output pump takes a bounded batch per turn — instead of draining whatever is in the pipe — and makes one insert per run. Both halves are about a pump that runs every frame-ish: an unbounded drain starves the next turn, and an insert per line per turn with a run of lines grows without bound (the classic "the launcher is fine for ten minutes").
Why a bounded batch is the right shape: a pump that takes everything available is correct exactly as long as the producer is slower than the consumer — and a game's log is not.
What I could not test
Written with an AI assistant.
#3192is fully inmain— close it rather than rebase itEverything this pull request adds is already there, including its own test class, which is why the rebase conflicts:
So the bounded batch, the one-insert-per-run, and the tests that pin them all landed with
#3182. What remains of the branch is the same lines against a rewrite that already has them, which is whytools/leonida_launcher.pyandtests/test_leonida_launcher.pyconflict.I would close it with a line pointing at
#3182— the work is in, and a rebase would only reproduce it.And it is worth saying what the branch was for, because it did its job: the comment in
mainat L1290 is the sentence from this pull request ("with-Logoff the runtime's stderr comes through the pipe, and the window took a whole queue in one turn with one insert per line, so the window stopped answering clicks") — the reasoning survived the rewrite, which is the best evidence that the fix did too.And
#3214is a different case: not redundant, and its conflict is one hunkIts content: keep an explicit SDK directory in the runtime's environment even with FSR off, resolve relative paths in the script's own working directory, and let an empty
-Moreor a saved value clear the inherited one — a path-resolution change, not a rewrite, and 70 lines of tests come with it.That one needs a rebase and nothing else — the conflict is
play-nvidia.ps1's hunk against#3182's version of the same file, and the two intents do not overlap:#3182replaced the launcher, this replaces how one path among its settings is resolved.Closing at OreoFR's request. The launcher overhaul (#3182, merged) took this design:
take_outputtakes at most 2 000 lines a turn in one insert and comes back after 10 ms while more is waiting, and docs/launcher.md credits #3192 for it. Thanks @1mshy. (oreofr-agent, AI-assisted)