Skip to content

Investigate remaining zsh startup slowness (1.5-2s, not captured by zsh -i -c exit) #5

Description

@rolfsormo

What we know so far

After fixing the eager conda shell.zsh hook and a .zshrc.devboost double-source
bug this session, synthetic timing (zsh -i -c exit, and zprof) shows shell
initialization itself down to ~0.2s, dominated by zinit plugin loading (~55%) and
_mise_hook (~25%).

However, real-world observed time from opening a new terminal window/tab to a usable
prompt is still 1.5-2 seconds — a ~1.3-1.8s gap that zsh -i -c exit structurally
can't see, because it exits immediately without ever reaching an actual interactive
prompt render.

Suspects (not yet confirmed)

  • iTerm2 shell integration handshake (~/.iterm2_shell_integration.zsh is sourced,
    179 lines) — may have its own async round-trip cost separate from zsh's own init.
  • compinit/completion cache: found 9 different stale .zcompdump* files on this
    machine, tied to different old hostnames/machine names (Rolfs-2021-MBP,
    Rolf's MacBook Pro, Rolfs-MacBook-Pro, Rolfs-MacBook-Pro-2, two different
    macbookpro.lan PIDs). compinit's default hostname-based cache-file lookup may be
    missing the "right" cache or doing extra work because of this — worth checking
    whether it's silently doing a full rebuit (which stats every function in $fpath,
    a well-known multi-second cost) versus using a cache.
  • Two active plugin managers (see the znap→zinit issue) doing genuinely redundant
    plugin-loading work, on top of whatever startup overhead each carries individually.
  • Terminal-app-side rendering/GPU cost, unrelated to the shell at all — needs to be
    ruled in/out separately from anything zsh-side.

Next steps

  • Get an accurate time-to-first-prompt measurement that isn't zsh -i -c exit (e.g.
    a precmd hook that timestamps and writes to a file, triggered from a genuinely
    fresh interactive shell — not a nested/synthetic one).
  • Clean up stale .zcompdump* files and re-measure.
  • Re-measure after the znap→zinit consolidation lands (should remove one full
    redundant plugin-manager init).
  • If a large gap remains, profile iTerm2 integration and terminal-app-level startup
    separately from the shell itself.

Relates to

  • The environment-health-checks module issue (stale .zcompdump as a checkable item).
  • The znap→zinit consolidation issue (redundant plugin manager as a contributing cause).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions