perf: fixed slow zsh startup in new tabs - #62
Merged
Merged
Conversation
New iTerm tabs took ~0.6s to show a prompt. Profiling showed `.zshrc`
ran `compinit` three times per shell (oh-my-zsh, then the Homebrew and
Docker Desktop blocks). Each extra call re-audited ~970 completion
files, and because `fpath` differed between calls the completion dump
was rewritten twice on every start (~0.45s). A second, intermittent
cause: `ZSH_COMPDUMP` was keyed on `$HOST`, so macOS flipping the
hostname (VPN / DHCP reverse-DNS) rebuilt the whole dump again.
- Put Homebrew's `site-functions` and `~/.docker/completions` on
`fpath` before sourcing oh-my-zsh so its single `compinit` covers
them, and dropped the two trailing `compinit` blocks
- Replaced the `$(brew --prefix)` subprocess with
`${commands[brew]:h:h}`
- Kept Docker Desktop's marker comments so it does not re-append its
own `compinit` block on a future update
- Disabled the oh-my-zsh auto-update check via
`zstyle ':omz:update' mode disabled`: its two `git` calls through
Apple's xcrun shim cost ~45ms per tab; update manually with
`omz update`
- Gave `ZSH_COMPDUMP` a fixed filename
Startup on a tty (what iTerm spawns) went from 0.61s to 0.11s.
Verified that aliases, functions, options, keybindings, prompt, and
tab-completion candidates are unchanged, with one exception:
`docker <TAB>` now uses Docker Desktop's generated completer instead
of the legacy static script Homebrew links from the app bundle, which
was mis-parsing `docker --help` output into bogus candidates.
[skip ci]
Signed-off-by: Salim Djerbouh <[email protected]>
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.
New iTerm tabs took ~0.6s to show a prompt. Profiling showed
.zshrcrancompinitthree times per shell (oh-my-zsh, then the Homebrew and Docker Desktop blocks). Each extra call re-audited ~970 completion files, and becausefpathdiffered between calls the completion dump was rewritten twice on every start (~0.45s). A second, intermittent cause:ZSH_COMPDUMPwas keyed on$HOST, so macOS flipping the hostname (VPN / DHCP reverse-DNS) rebuilt the whole dump again.site-functionsand~/.docker/completionsonfpathbefore sourcing oh-my-zsh so its singlecompinitcovers them, and dropped the two trailingcompinitblocks$(brew --prefix)subprocess with${commands[brew]:h:h}compinitblock on a future updatezstyle ':omz:update' mode disabled: its twogitcalls through Apple's xcrun shim cost ~45ms per tab; update manually withomz updateZSH_COMPDUMPa fixed filenameStartup on a tty (what iTerm spawns) went from 0.61s to 0.11s. Verified that aliases, functions, options, keybindings, prompt, and tab-completion candidates are unchanged, with one exception:
docker <TAB>now uses Docker Desktop's generated completer instead of the legacy static script Homebrew links from the app bundle, which was mis-parsingdocker --helpoutput into bogus candidates.[skip ci]