lag-triage: timestamped, redacted flight recorder with heal-time episode snapshots

This commit is contained in:
Noah Masur
2026-10-17 13:11:32 -04:00
parent 33c426bc8e
commit bc43f3dfaf
4 changed files with 99 additions and 7 deletions
@@ -20,11 +20,14 @@ let
# harness on fish 4.8.1 (see docs/CHANGELOG.md 2026-08-29 and
# presets/programs/lag-triage/upstream_repro.py). Spawning fish with the
# variable already exported makes every pane shell immune.
# Flight recorder for the still-unsolved post-TUI typing lag: sampling the
# process CURES the lag (a wedged thread gets kicked loose), so the only way
# to observe it is a recorder that is already running before the lag starts.
# Armed by `touch ~/.local/state/lag-triage/RECORD`; new panes then log
# fish's reader/thread internals to ~/.local/state/lag-triage/flight/.
# Flight recorder for the still-unsolved post-TUI typing lag: the lag only
# shows up in long-lived pane shells and has never reproduced in a fresh
# shell, so the recorder must already be running when it starts.
# Armed by `touch ~/.local/state/lag-triage/RECORD`; new panes then stream
# fish's debug log through flight_filter.pl, which adds millisecond
# timestamps (the September logs had none, which made them inconclusive)
# and redacts typed/pasted text. Ctrl-b (heal-autosuggest) snapshots the
# recent log into ~/.local/state/lag-triage/episodes/ before healing.
# Remove the RECORD file to disable (zero overhead when off).
fish-no-query-term = pkgs.writeShellScriptBin "fish-no-query-term" ''
export fish_features=no-query-term
@@ -32,8 +35,16 @@ let
if [ -e "$dir/RECORD" ]; then
mkdir -p "$dir/flight"
find "$dir/flight" -type f -mtime +3 -delete 2>/dev/null
export FISH_DEBUG='reader,term-support,proc-termowner,iothread,fd-monitor,topic-monitor'
export FISH_DEBUG_OUTPUT="$dir/flight/fish-$(date +%Y%m%d-%H%M%S)-$$.log"
log="$dir/flight/fish-$(date +%Y%m%d-%H%M%S)-$$.log"
fifo="$dir/flight/.fifo-$$"
rm -f "$fifo"
if mkfifo -m 600 "$fifo"; then
# The filter exits on EOF once fish (this pid after exec) exits.
${lib.getExe pkgs.perl} ${./lag-triage/flight_filter.pl} "$fifo" "$log" </dev/null >/dev/null 2>&1 &
export FISH_DEBUG='reader,reader-render,term-support,proc-termowner,iothread,fd-monitor,topic-monitor,complete,autoload,history,uvar-notifier'
export FISH_DEBUG_OUTPUT="$fifo"
export FISH_FLIGHT_LOG="$log"
fi
fi
exec ${lib.getExe pkgs.fish} "$@"
'';