Repository navigation
[CTX-2466] fix(stability): opt-in main-loop stall watchdog and long-run soak (#2483) - #2488
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 51 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Xuepoo
force-pushed
the
ctx-2483/diag-longrun-freeze
branch
2 times, most recently
from
October 22, 2026 11:30
60886b3 to
e66365d
Compare
) The owner's long-run freeze left no process or log behind. Add a bounded, quiet-by-default observer: the event loop marks its current phase, a monitor thread samples the heartbeat from outside, and a no-progress window writes the last phase, uptime, bounded app context, process totals, and a bounded thread-state snapshot (state/wchan/syscall/comm). The latest stall report also lands in one truncated XDG state slot so a terminated session still leaves evidence. Disabled unless BITTY_STALL_WATCHDOG opts in; no product behavior change. Refs #2483
…2483) scripts/longrun-soak.sh runs an isolated Xvfb display and XDG roots, drives output/scrollback, kitty images, input, and resizes, probes ctl liveness and RSS/threads/fds every sample, and counts watchdog reports. --stall-probe reproduces the blocking raw-mode PTY write and captures the watchdog report. The live path owns only its recorded process groups; CI runs the headless contract test. Refs #2483
…2483) Readiness now comes from the process table (the non-reading child is a real process), not grid text: in a no-WM Xvfb session the presented grid may not carry the marker, and a wrapped marker would never match as one string. The probe also records a diagnostic dump on failure, and an inconclusive start fails closed instead of reporting a silent pass. Regression mode (--stall-probe without --expect-stall) now fails when the burst blocks. Refs #2483
The thread sampler reads /proc/self/task, so MAX_THREAD_ROWS is only used on Linux. The macOS and Windows bin builds run with -D warnings and rejected the unused constant; gate it at the definition with the reason. Those jobs then produced no M1/compat artifacts, which is why both Tier 1 aggregates reported MISSING results. Verified with -D warnings for x86_64-pc-windows-gnu and aarch64-apple-darwin. Refs #2483
Xuepoo
force-pushed
the
ctx-2483/diag-longrun-freeze
branch
from
October 22, 2026 12:13
e66365d to
416e7be
Compare
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Issue #2483's two engineering follow-ups, with the owner's freeze shape reproduced and captured live:
crates/bitty-terminal/src/stall_watchdog.rs): when a tick/event phase makes no progress for N ms, a monitor thread logs the last phase, uptime, bounded app context, process totals, and a bounded thread-state snapshot (state, wchan, syscall number, comm). It also writes one truncated XDG state slot so a terminated session still leaves evidence.scripts/longrun-soak.sh): isolated Xvfb + XDG roots, real output/scrollback/image/input/resize load, a liveness probe on every sample, and an opt-in--stall-probethat reproduces the blocking-PTY-write class.No product behavior changes: the watchdog is quiet unless
BITTY_STALL_WATCHDOGopts in, and phase marks are one relaxed store plus a timestamp.Why
The owner saw
Application Not Respondingafter a long session with no hung process and no captured log. The issue asks for (a) a bounded watchdog that records the last phase/stage/uptime and thread state and (b) an audit of long-uptime blocking/growth paths, validated by a soak.Proven findings
P1 — a non-reading raw-mode child parked the event loop in
write(2)(captured pre-fix; fixed by #2457)While #2457 was still unmerged, the event loop wrote PTY input inline:
PtyWriter::write_allforwarded to the blocking sink (crates/bitty-pty/src/writer.rs:45), called fromwrite_input_best_effort(crates/bitty-runtime/src/runtime/input.rs:2050) on the runtime owner thread (route_input_bytes, same file).Live capture from
scripts/longrun-soak.sh --stall-probe --expect-stall(isolated Xvfb, real fish,sh -c 'stty raw -echo; sleep 900'in the pane), on a pre-b0ad911abase:syscall=1iswrite(2)on x86_64;phase=ctl-drainis the controller-queue drain that appliesterminal send. This is the paru/#2446 class, reproduced against the long-run shape, and it validated the watchdog's phase/thread snapshot end-to-end.Canonical mode does not block (the kernel buffers hundreds of KiB); raw mode with a non-reading child is the bounded-queue shape, which is why the probe sets
stty raw -echo. The probe waits for the child in the process table before bursting, so a burst can never land in a still-cooked prompt.#2457 is now merged as
b0ad911a(#2446). After rebasing onto it, the same probe stays bounded:On a pre-#2457 base the same probe in regression mode exits 1 (
FAIL stall probe blocked); on currentmainit exits 0, so the harness is a regression check for the fix.P2 — no long-uptime growth or stall under mixed load (5-minute soak)
scripts/longrun-soak.sh --duration-secs 300 --interval-secs 10 --workload mixedwith the bar plugin active (output bursts, Kitty transmit/place/delete, input, X11 resize):A separate idle instance stayed responsive after 25 minutes (ctl 20-40 ms, 15 threads, 62 fds), so idle parking alone does not drift.
P3 — existing long-run bounds verified (static)
bitty-runtime/src/config.rs:68,:1352; invariant checkbitty-term-state/src/state/invariants.rs:239bitty-runtime/src/config.rs:1128bitty-terminal/src/terminal_app.rs:331,:2609CHANNEL_CAPACITY_CHUNKS × READ_CHUNK_SIZE)bitty-runtime/src/runtime/pty.rs:638bitty-runtime/src/runtime/panes.rs:1056bitty-runtime/src/runtime/bell.rs:48bitty-runtime/src/runtime/component_host.rs:30bitty-lua/src/host.rs:373,bitty-runtime/src/plugin_runtime/mod.rs:1878bitty-plugin-host/src/event.rs:721bitty-rich/src/lib.rs:47-53bitty-terminal/src/config_reload.rs:471bitty-terminal/src/terminal_app.rs:911call sitesbitty-plugin-host/src/audio.rs:677Suspected, not reproduced
pollster::block_on(GpuContext::initialize_for_surface),terminal_app.rs:3611). A driver-level hang would look identical to the owner's ANR, but it is a one-shot window/resume path, not long-uptime growth. Not triggered in the soak.pump_due_timers_at). A host call that blocks past the budget would pause a tick; no such stall was observed with the bar plugin's 1 s clock and modules.None of these are claimed as the owner's trigger. The watchdog is designed to name the phase on the next occurrence.
Watchdog contract
BITTY_STALL_WATCHDOG=1|true|on|yesenables it;BITTY_STALL_WATCHDOG=<ms>enables with that threshold;BITTY_STALL_WATCHDOG_MSoverrides (clamped 50..=600000 ms). Absent/0/false/off/garbage leaves it disabled, so CI and normal sessions spawn no thread and emit nothing.$XDG_STATE_HOME/bitty/stall-watchdog.log(single truncated slot; recovery lines never overwrite it).redact_text_for_stderrgate as other diagnostics.Soak harness
The harness starts only its own Xvfb and app process group, records those PIDs, and kills only them. Evidence (
samples.csv,summary.txt,bitty.log,stall-evidence.txt, optionalstall-stacks.txt) stays under--out-dir(defaultrecording/longrun-soak, gitignored) and carries counts, not host paths.just longrun-soak-testruns the headless contract test in CI.Verification
cargo fmt --all -- --check— passcargo clippy -p bitty-terminal --all-targets --locked -- -D warnings— passcargo test -p bitty-terminal --bin bitty stall_watchdog— 13/13 passjust longrun-soak-test— PASSscripts/check-scratch-paths.sh— OKcargo check -p bitty-terminal --target x86_64-pc-windows-gnu --all-targets --lockedwithRUSTFLAGS=-D warnings— pass (also covers thenot(target_os = "linux")watchdog branch)cargo check -p bitty-terminal --target aarch64-apple-darwin --all-targets --lockedwithRUSTFLAGS=-D warnings— passprobe=pass, exit 0), all on isolated Xvfb.MISSING; both cross-target checks now pass.just ci-local/actnot run in this environment (commander directive); remote CI is the gate.Follow-ups
b0ad911aand fixes P1; this PR is the diagnostics that captured it plus the harness that now guards it.~/.local/state/bitty/stall-watchdog.log.window-create.Priority: P0 | Area: stability | Labels: fix,P0,area:stability | Milestone: 0.0.26 | RFC: OQ-xxx | Task: CTX-2466
Closes #2483