#453

Guard Powerlevel10k / gitstatusd against daemon accumulation in agent subshells

OpenGerry9000opened 16d ago

Summary

In multi-agent and swarm environments (running Codex, Claude Code, OMP, tmux workers), agents frequently invoke subshells with -l -i (e.g., /usr/bin/zsh -l -i -c "$AGENT_PAYLOAD"). Because ~/.zshrc unconditionally sources $HOME/.acfs/zsh/acfs.zshrc, which initializes Powerlevel10k, every automated subshell invocation spawns a dedicated 4-thread gitstatusd daemon (/tmp/gitstatus.POWERLEVEL9K.<UID>.<PID>...).

On a heavily-used development workstation or multi-agent host, this leads to:

  1. Massive process accumulation: 60–100+ concurrent gitstatusd instances left running across tmux panes and subshell sessions.
  2. Severe I/O and page cache contention: Dozens of gitstatusd daemons continuously query and stat the exact same .git indices and worktrees simultaneously, contributing to kernel IO wait spikes (folio_wait_bit_common) and disk thrashing.
  3. Wasted resources: Non-interactive or agent-automated subshells have no human prompt to display, making p10k and gitstatusd completely unnecessary in these sessions.

Proposed Fix in ACFS Zsh Configuration

In $HOME/.acfs/zsh/acfs.zshrc (or wherever prompt themes are initialized), guard Powerlevel10k / gitstatusd initialization so it only starts when running in a genuine interactive human terminal (stdout is a TTY and no agent execution payload is present):

# Skip heavy prompt daemons (p10k / gitstatusd) for non-interactive shells or agent subshell wrappers
if [[ ! -t 1 ]] || [[ -n "$CODEX_REMOTE_PAYLOAD" ]] || [[ -n "$SIFS_AGENT" ]] || [[ -n "$AGENT_ENV" ]]; then
    export GITSTATUS_ENABLE_DAEMON=0
fi

Environment

  • ACFS on Ubuntu 24.04 / Debian / Linux
  • Multi-agent orchestrators (Codex, Claude, OMP, tmux swarms)

Activity

1
Dicklesworthstone15d ago

Measured on five busy multi-agent ACFS hosts (tmux swarms): 6, 21, 25, 49 and 62 gitstatusd daemons, about 33 threads each, 7 MB average RSS on the busiest host. On the busiest host, all 62 have an interactive login zsh with a TTY as their parent, one per tmux pane. None come from TTY-less agent subshells. So here the count tracks open panes, not leaked automation shells.

Two notes on the proposed guard:

  • GITSTATUS_ENABLE_DAEMON is not a Powerlevel10k/gitstatus variable, so it would be a no-op. The real switch is POWERLEVEL9K_DISABLE_GITSTATUS=true, set before p10k loads.
  • [[ ! -t 1 ]] wouldn't touch pane shells, which are the ones that accumulate.

If the goal is fewer daemons on agent hosts, two options are cheap and safe. Either set POWERLEVEL9K_DISABLE_GITSTATUS=true when the shell has no TTY ([[ ! -t 0 || ! -t 1 ]]). Or cap GITSTATUS_NUM_THREADS (e.g. 2) for every shell, since one prompt's status needs nowhere near ~33 threads. The second option removes most of the thread count without changing any prompt.