launcher: the output pump takes a bounded batch a turn, so the window answers with -Log off (LAUNCHER-OUTPUT-PUMP) #3192

Closed
1mshy wants to merge 1 commit from upstream-pr/3192 into main
1mshy commented 2026-12-02 17:49:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by 1mshy on 2026-12-02T17:49:39Z.


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 Tk after callback, with an
insert and a see("end") per line. see("end") forces a layout pass, about 2.5 ms of the ~3 ms a line costs. Tk
could 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.

  • New 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 see per run.
  • pump() uses it. The status heuristic (state_for_line) is applied over the run and set once. A turn that leaves
    lines queued comes back after OUTPUT_RESUME_MS (10 ms) instead of 100 ms, so a backlog drains fast while clicks
    and 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 OK
  • python -I tests/test_launcher_serve.py: 10 OK
  • python -I tests/test_win_launchers.py: 6 run, 5 skipped (Windows-only)
  • python -I scripts/check_no_game_data.py (all tracked files): clean
  • python -m compileall -q make_game.py tools tests: OK
  • python -m unittest discover -s tests -p "test_docs_*.py": 57 OK

Red/green: python -I scripts/red_green.py fix/launcher-output-pump --base origin/main --no-cargo --mutate
reports 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 the pump() hunk, because Launcher is nested in
run_gui() and can't be reached without a display. A Tk benchmark (below) covers that.

Tk measurement (real Text widget set up like the output box; a 5 ms timer stands in for a click):

Queued lines Before: longest turn / timer late by After: longest turn / timer late by / drained in
2,000 5.9 s / 5.9 s —
30,000 89.4 s / 90 s 5 ms / 13 ms / 0.23 s
300,000 — 8 ms / 14 ms / 2.3 s
30,000 into a box already holding 200,000 — 5 ms / 11 ms / 0.23 s

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 the
real 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

  • Based on current main (45dc41f95) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md — n/a, no translator change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5611877086 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192). Originally posted by [1mshy](https://github.com/1mshy) on 2026-12-02T17:49:39Z. --- 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 Tk `after` callback, with an `insert` and a `see("end")` per line. `see("end")` forces a layout pass, about 2.5 ms of the ~3 ms a line costs. Tk could 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. - New `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 `see` per run. - `pump()` uses it. The status heuristic (`state_for_line`) is applied over the run and set once. A turn that leaves lines queued comes back after `OUTPUT_RESUME_MS` (10 ms) instead of 100 ms, so a backlog drains fast while clicks and 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 OK - `python -I tests/test_launcher_serve.py`: 10 OK - `python -I tests/test_win_launchers.py`: 6 run, 5 skipped (Windows-only) - `python -I scripts/check_no_game_data.py` (all tracked files): clean - `python -m compileall -q make_game.py tools tests`: OK - `python -m unittest discover -s tests -p "test_docs_*.py"`: 57 OK **Red/green:** `python -I scripts/red_green.py fix/launcher-output-pump --base origin/main --no-cargo --mutate` reports 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 the `pump()` hunk, because `Launcher` is nested in `run_gui()` and can't be reached without a display. A Tk benchmark (below) covers that. **Tk measurement** (real `Text` widget set up like the output box; a 5 ms timer stands in for a click): | Queued lines | Before: longest turn / timer late by | After: longest turn / timer late by / drained in | |---|---|---| | 2,000 | 5.9 s / 5.9 s | — | | 30,000 | 89.4 s / 90 s | 5 ms / 13 ms / 0.23 s | | 300,000 | — | 8 ms / 14 ms / 2.3 s | | 30,000 into a box already holding 200,000 | — | 5 ms / 11 ms / 0.23 s | 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 the real 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 - [x] Based on current `main` (45dc41f95) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md` — n/a, no translator change.
fiestorra commented 2026-12-02 18:00:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T18:00:05Z.


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.

merge base 5b1fff821 (= current origin/main), head b713fdd8d
git apply on main   (9 files)

python -I tests/test_leonida_launcher.py    Ran 28 tests   OK

new, and they are the ones that matter:
  OutputPumpTests.test_a_turn_takes_at_most_the_batch_and_leaves_the_rest_queued
  OutputPumpTests.test_runs_are_joined_per_process_and_kept_in_order

The fix is the right shape for #3175: Launcher.pump drained the reader thread's whole queue inside one Tk after callback, with an insert and a see("end") per line, so a chatty runtime (stderr with -Log off) 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 from False to True and rewrites switch_args to emit -PrecompileUsed when 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353848503 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7353848503). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T18:00:05Z. --- **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.** ``` merge base 5b1fff821 (= current origin/main), head b713fdd8d git apply on main (9 files) python -I tests/test_leonida_launcher.py Ran 28 tests OK new, and they are the ones that matter: OutputPumpTests.test_a_turn_takes_at_most_the_batch_and_leaves_the_rest_queued OutputPumpTests.test_runs_are_joined_per_process_and_kept_in_order ``` **The fix is the right shape for #3175**: **`Launcher.pump` drained the reader thread's whole queue inside one Tk `after` callback**, with an `insert` and a `see("end")` per line, **so a chatty runtime (stderr with `-Log` off) 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 from `False` to `True` and rewrites `switch_args` to emit `-PrecompileUsed` when 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.
MoonEyes commented 2026-12-02 18:04:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:04:26Z.


Third-party verification of #3192 (LAUNCHER-OUTPUT-PUMP, fixes #3175)

  • Head: b713fdd8da6066fc06cf73636257e43f7be96610, merge base 45dc41f95 (= current origin/main). Merges cleanly (git merge-tree --write-tree origin/main pr/3192). GitHub mergeable_state: blocked (review required); no check runs or statuses reported on the head sha yet.
  • No earlier comments or reviews on the pull request. No other open pull request touches tools/leonida_launcher.py or #3175.
  • Claim: not found. I searched #2570 (and recent comments of #1608 and #14) for LAUNCHER-OUTPUT-PUMP, #3175 and comments by the author. I found no claiming: or done: 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):

python3 -I tests/test_leonida_launcher.py                  Ran 28 tests OK
python3 -I tests/test_shell_launchers.py                   Ran 7 tests OK
python3 -I scripts/check_no_game_data.py tools/leonida_launcher.py tests/test_leonida_launcher.py   rc=0
python3 -m compileall -q tools/leonida_launcher.py tests/test_leonida_launcher.py                   rc=0
python3 -m unittest discover -s tests -p "test_docs_*.py"  Ran 57 tests OK

Red/green, python3 -I scripts/red_green.py pr/3192 --base origin/main --no-fetch --no-cargo --mutate:

red then green (2): OutputPumpTests.test_a_turn_takes_at_most_the_batch_and_leaves_the_rest_queued
                    OutputPumpTests.test_runs_are_joined_per_process_and_kept_in_order
pass on both: 24
mutations: tools/leonida_launcher.py:464 caught, tools/leonida_launcher.py:793 not caught
verdict: red then green

As the PR says, nothing tests the pump() hunk (Launcher is nested in run_gui()). This machine has no tkinter, 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-run state_for_line fold gives the same final state as the old per-line calls. Calling set_state only on a change is equivalent because set_state only sets self.state and status_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.
  • Not a defect of this PR: the output Text widget still grows without bound over a long -Log-off session (pre-existing).

Defects

  1. Missing claim in #2570 (Maintainer quick guide: "It is claimed in the coordination issue by the pull request's author"). The author should post claiming: LAUNCHER-OUTPUT-PUMP / done: LAUNCHER-OUTPUT-PUMP -> #3192 there.

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.bat click-through with -Log off would still be useful.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353915081 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7353915081). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:04:26Z. --- **Third-party verification of #3192 (LAUNCHER-OUTPUT-PUMP, fixes #3175)** - Head: `b713fdd8da6066fc06cf73636257e43f7be96610`, merge base `45dc41f95` (= current `origin/main`). Merges cleanly (`git merge-tree --write-tree origin/main pr/3192`). GitHub `mergeable_state: blocked` (review required); no check runs or statuses reported on the head sha yet. - No earlier comments or reviews on the pull request. No other open pull request touches `tools/leonida_launcher.py` or #3175. - **Claim: not found.** I searched #2570 (and recent comments of #1608 and #14) for `LAUNCHER-OUTPUT-PUMP`, `#3175` and comments by the author. I found no `claiming:` or `done:` 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`): ``` python3 -I tests/test_leonida_launcher.py Ran 28 tests OK python3 -I tests/test_shell_launchers.py Ran 7 tests OK python3 -I scripts/check_no_game_data.py tools/leonida_launcher.py tests/test_leonida_launcher.py rc=0 python3 -m compileall -q tools/leonida_launcher.py tests/test_leonida_launcher.py rc=0 python3 -m unittest discover -s tests -p "test_docs_*.py" Ran 57 tests OK ``` **Red/green**, `python3 -I scripts/red_green.py pr/3192 --base origin/main --no-fetch --no-cargo --mutate`: ``` red then green (2): OutputPumpTests.test_a_turn_takes_at_most_the_batch_and_leaves_the_rest_queued OutputPumpTests.test_runs_are_joined_per_process_and_kept_in_order pass on both: 24 mutations: tools/leonida_launcher.py:464 caught, tools/leonida_launcher.py:793 not caught verdict: red then green ``` As the PR says, nothing tests the `pump()` hunk (`Launcher` is nested in `run_gui()`). This machine has no `tkinter`, 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-run `state_for_line` fold gives the same final state as the old per-line calls. Calling `set_state` only on a change is equivalent because `set_state` only sets `self.state` and `status_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. - Not a defect of this PR: the output `Text` widget still grows without bound over a long `-Log`-off session (pre-existing). **Defects** 1. Missing claim in #2570 (Maintainer quick guide: "It is claimed in the coordination issue by the pull request's author"). The author should post `claiming: LAUNCHER-OUTPUT-PUMP` / `done: LAUNCHER-OUTPUT-PUMP -> #3192` there. **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.bat` click-through with `-Log` off would still be useful. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
lixonik commented 2026-12-02 20:02:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T20:02:30Z.


Verified PR #3192 (b713fdd8d) merged cleanly onto main (f1a559851) on Windows 10 x64:

  • Clean-room check: python -I scripts/check_no_game_data.py PASS.
  • Green (merged b713fdd8d onto f1a559851): python -I tests/test_leonida_launcher.py -- 28 tests, OK (0.267 s).
  • Red -> Green proof (main tools/leonida_launcher.py + PR tests/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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7357120188 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7357120188). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T20:02:30Z. --- Verified PR #3192 (`b713fdd8d`) merged cleanly onto `main` (`f1a559851`) on Windows 10 x64: - **Clean-room check:** `python -I scripts/check_no_game_data.py` PASS. - **Green (merged `b713fdd8d` onto `f1a559851`):** `python -I tests/test_leonida_launcher.py` -- **28 tests, OK** (0.267 s). - **Red -> Green proof (`main` `tools/leonida_launcher.py` + PR `tests/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).
Kal0s-design commented 2026-12-02 21:00:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T21:00:20Z.


Ran natively on Windows 11, head b713fdd8d merged into current main (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 main and 28 on the merge, all green, and the two new OutputPumpTests error on main'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_output and set_state bodies (pulled from the file on each side, not rewritten) against a Text set 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 ms after heartbeat measured how long the window went without getting a turn.

Measured, PR vs main

child output PR: longest turn / longest heartbeat gap main: same text identical to child output, exit line last
100k short lines 5 ms / 29 ms, done in 0.9 s 44 to 51 s in one turn (two runs), window frozen yes on both
5000 lines of 4 KB 19 ms / 34 ms ~44 s in one turn (measured with a plain Text, before I matched the launcher's) yes on both
5 \r progress runs of 20k each, then 1000 lines 66 ms / 81 ms still stuck in the first turn when I stopped it, minutes later yes (PR)
2 s of writing flat out (2.78M lines) 76 ms / 136 ms, done ~22 s after the child exited still stuck in the first turn after 3 minutes, stopped yes (PR, checked line by line)
50k lines with invalid UTF-8, last line without newline 51 ms / 67 ms ~51 s in one turn yes on both

On main the 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 \n and decoded with errors="replace", plus Exited 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, since read_output queues exit after EOF and take_output keeps queue order.
Limits worth knowing (not defects of this PR)

  • The batch counts items, not bytes. With 2000 lines of 4 KB already queued, one turn took 237 ms (measured). Still far better than before, but a run with very long lines can stutter.
  • The queue is an unbounded 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.
  • readline only splits on \n (read), so \r-only progress lines show up as one line when the next \n arrives. Same as on main.
  • The Text widget itself still grows without limit, as already noted above.

Correction to the first comment. The diff against current main is 2 files, tools/leonida_launcher.py and tests/test_leonida_launcher.py, with only the pump change. There is no precompile_all or switch_args change in this head (measured with git diff).

Other open PRs touching tools/leonida_launcher.py (git merge-tree against the PR head)

PR result note
#3182 (launcher overhaul) conflict in pump() Keeps the old drain-everything loop and adds info and rail kinds (read). It does not replace the pump, so whoever merges second has to keep the bounded loop or #3175 comes back. take_output passes non-line kinds through unchanged, so the new kinds fit as they are.
#3209 (custom parameters) conflict in pump() Adds a per-line check for F1 settings applied. (read). With runs joined into one item, that check has to move into the for line in value loop, or it misses lines in the middle of a batch.
#3130 clean
#2958 clean

Not checked: a real Launcher.bat click-through with -Log off and the actual runtime, the full Launcher window (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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358650558 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7358650558). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T21:00:20Z. --- Ran natively on Windows 11, head `b713fdd8d` merged into current `main` (`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 `main` and 28 on the merge, all green, and the two new `OutputPumpTests` error on `main`'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_output` and `set_state` bodies (pulled from the file on each side, not rewritten) against a `Text` set 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 ms `after` heartbeat measured how long the window went without getting a turn. **Measured, PR vs main** | child output | PR: longest turn / longest heartbeat gap | main: same | text identical to child output, exit line last | |---|---|---|---| | 100k short lines | 5 ms / 29 ms, done in 0.9 s | 44 to 51 s in one turn (two runs), window frozen | yes on both | | 5000 lines of 4 KB | 19 ms / 34 ms | ~44 s in one turn (measured with a plain `Text`, before I matched the launcher's) | yes on both | | 5 `\r` progress runs of 20k each, then 1000 lines | 66 ms / 81 ms | still stuck in the first turn when I stopped it, minutes later | yes (PR) | | 2 s of writing flat out (2.78M lines) | 76 ms / 136 ms, done ~22 s after the child exited | still stuck in the first turn after 3 minutes, stopped | yes (PR, checked line by line) | | 50k lines with invalid UTF-8, last line without newline | 51 ms / 67 ms | ~51 s in one turn | yes on both | On `main` the 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 `\n` and decoded with `errors="replace"`, plus `Exited 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, since `read_output` queues `exit` after EOF and `take_output` keeps queue order. **Limits worth knowing (not defects of this PR)** - The batch counts items, not bytes. With 2000 lines of 4 KB already queued, one turn took 237 ms (measured). Still far better than before, but a run with very long lines can stutter. - The queue is an unbounded `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. - `readline` only splits on `\n` (read), so `\r`-only progress lines show up as one line when the next `\n` arrives. Same as on `main`. - The `Text` widget itself still grows without limit, as already noted above. **Correction to the first comment.** The diff against current `main` is 2 files, `tools/leonida_launcher.py` and `tests/test_leonida_launcher.py`, with only the pump change. There is no `precompile_all` or `switch_args` change in this head (measured with `git diff`). **Other open PRs touching `tools/leonida_launcher.py`** (`git merge-tree` against the PR head) | PR | result | note | |---|---|---| | #3182 (launcher overhaul) | conflict in `pump()` | Keeps the old drain-everything loop and adds `info` and `rail` kinds (read). It does not replace the pump, so whoever merges second has to keep the bounded loop or #3175 comes back. `take_output` passes non-`line` kinds through unchanged, so the new kinds fit as they are. | | #3209 (custom parameters) | conflict in `pump()` | Adds a per-line check for `F1 settings applied.` (read). With runs joined into one item, that check has to move into the `for line in value` loop, or it misses lines in the middle of a batch. | | #3130 | clean | | | #2958 | clean | | Not checked: a real `Launcher.bat` click-through with `-Log` off and the actual runtime, the full `Launcher` window (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).
fiestorra commented 2026-12-02 23:50:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:50:17Z.


VERIFY-3192 — Windows nativo: red then green en el bombeo de la salida

Own commit b713fdd8d — tools/leonida_launcher.py (+76), tests/test_leonida_launcher.py (+35)

Ran at the head

python -I tests/test_leonida_launcher.py     Ran 28 tests — OK

Negative control: the commit's own hunk does not revert cleanly (the branch also carries a merged main on that file), so I put main's leonida_launcher.py back and re-ran:

Ran 28 tests — FAILED (errors=2)

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

  • A real launch with the pump under load: the tests drive the pump's bookkeeping; the title's log volume is the condition that matters.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362485248 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7362485248). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:50:17Z. --- ## VERIFY-3192 — Windows nativo: `red then green` en el bombeo de la salida | | | |---|---| | Own commit | `b713fdd8d` — `tools/leonida_launcher.py` (+76), `tests/test_leonida_launcher.py` (+35) | **Ran at the head** ``` python -I tests/test_leonida_launcher.py Ran 28 tests — OK ``` **Negative control**: the commit's own hunk does not revert cleanly (the branch also carries a merged `main` on that file), so I put **`main`'s `leonida_launcher.py`** back and re-ran: ``` Ran 28 tests — FAILED (errors=2) ``` **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 - **A real launch with the pump under load**: the tests drive the pump's bookkeeping; the title's log volume is the condition that matters. Written with an AI assistant.
fiestorra commented 2026-12-03 02:08:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T02:08:42Z.


#3192 is fully in main — close it rather than rebase it

Everything this pull request adds is already there, including its own test class, which is why the rebase conflicts:

main: tools/leonida_launcher.py
  L1290  # The window's output pump (Launcher.pump) takes at most OUTPUT_BATCH items of the reade…
  L1293  OUTPUT_BATCH = 2000
  L1297  def take_output(lines: queue.Queue, limit: int = OUTPUT_BATCH) -> list[tuple]:
  L2848  # At most OUTPUT_BATCH items a turn, each run of lines in one insert (take_output, whose…

main: tests/test_leonida_launcher.py
  class OutputPumpTests(unittest.TestCase):     ← this pull request's class

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 why tools/leonida_launcher.py and tests/test_leonida_launcher.py conflict.

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 main at L1290 is the sentence from this pull request ("with -Log off 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 #3214 is a different case: not redundant, and its conflict is one hunk

d3d12/scripts/play-nvidia.ps1         | 27 ++++++++----
tests/test_play_nvidia_menu_choice.py | 70 ++++++++++++++++++++++++++++

Its 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 -More or 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: #3182 replaced the launcher, this replaces how one path among its settings is resolved.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365134014 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7365134014). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T02:08:42Z. --- ## `#3192` is fully in `main` — close it rather than rebase it **Everything this pull request adds is already there, including its own test class**, which is why the rebase conflicts: ``` main: tools/leonida_launcher.py L1290 # The window's output pump (Launcher.pump) takes at most OUTPUT_BATCH items of the reade… L1293 OUTPUT_BATCH = 2000 L1297 def take_output(lines: queue.Queue, limit: int = OUTPUT_BATCH) -> list[tuple]: L2848 # At most OUTPUT_BATCH items a turn, each run of lines in one insert (take_output, whose… main: tests/test_leonida_launcher.py class OutputPumpTests(unittest.TestCase): ← this pull request's class ``` **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 why `tools/leonida_launcher.py` and `tests/test_leonida_launcher.py` conflict.** **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 `main` at L1290 is the sentence from this pull request** (*"with `-Log` off 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 `#3214` is a different case: **not redundant, and its conflict is one hunk** ``` d3d12/scripts/play-nvidia.ps1 | 27 ++++++++---- tests/test_play_nvidia_menu_choice.py | 70 ++++++++++++++++++++++++++++ ``` **Its 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 `-More` or 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**: `#3182` replaced the launcher, **this replaces how one path among its settings is resolved.**
OreoFR commented 2026-12-03 03:36:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T03:36:35Z.


Closing at OreoFR's request. The launcher overhaul (#3182, merged) took this design: take_output takes 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)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7366746742 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3192#issuecomment-7366746742). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T03:36:35Z. --- Closing at OreoFR's request. The launcher overhaul (#3182, merged) took this design: `take_output` takes 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)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3192
No description provided.