fix: reduce idle TUI CPU usage#36
Conversation
|
Final validation report for head Implemented idle redraw gating plus cached resource-parse regexes, with follow-up fixes from review for resize redraws, scrollbar fade frames, session-save errors, failed loading placeholders, and resize-batched input. Validation passed:
Review/CI:
|
7829406 to
7fe0dae
Compare
|
Final validation report for rebased head Resolved the merge conflicts by rebasing Implemented idle redraw gating plus cached resource-parse regexes, with follow-up fixes from review for resize redraws, scrollbar fade frames, session-save errors, failed loading placeholders, resize-batched input ordering, and preserving redraw requests after resize-plus-input batches. Validation passed:
Review/CI:
|
Summary
Idle ghzinga panes could burn CPU just by staying open.
The TUI loop redrew every pass, and each redraw rebuilt GitHub-link regexes while parsing visible text.
This change makes idle panes stay idle, while still redrawing for input, fetch results, loading spinners, control commands, and timed refresh work.
What Changed
The implementation plan is to remove the immediate hot path first, then make the event loop obey the bigger production rule: idle means idle.
This change implements those two steps without changing the rendered UI.
LazyLocksoResourceId::parseno longer recompiles them during render.terminal.draw(...)only runs when state changed or a redraw is explicitly needed.Testing
I ran the full local gate from
AGENTS.md.The capture scripts need Python newer than the system
/usr/bin/python3, so I ran those with the bundled Python 3.12 interpreter.cargo fmt --checkcargo testcargo clippy --all-targets --all-features -- -D warningsnpx -y @simpledoc/simpledoc check/Users/onur/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 captures/ghzinga-pr-81834/capture_ghzinga.py --validate-only/Users/onur/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 captures/ghzinga-pr-81834/capture_ghzinga.py --root captures/ghzinga-issue-88499 --mode issue --validate-only/Users/onur/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 captures/ghzinga-pr-81834/capture_mouse_smoke.py --validate-only/Users/onur/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 captures/ghzinga-issue-88499/capture_mouse_smoke.py --validate-only/Users/onur/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 scripts/update-capture-manifests.py --checkRisks
The main risk is missing a redraw after an unusual state change.
The loop now marks redraws for fetch completion, control requests, loading ticks, app events, auto-refresh starts, loading-resource refresh starts, and file-patch load starts.
This does not add a full render-row cache yet.
That can still be a follow-up if a loaded screen with very large visible content is expensive during real user input.
Follow-ups
Add an idle CPU regression harness that opens a large fixture, waits without input, and asserts the process stays near zero CPU.
Cache parsed link rows by resource/text/width if interactive redraws are still expensive on very large resources.
Smoke-tested the patched interactive TUI on
fixtures/pr-81834.jsonfor 60 seconds with--refresh-seconds 0; sampled process stayed at0.0%CPU for all six samples.