Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh initialization performance #3410

Open
maquejp opened this issue Aug 14, 2024 · 3 comments
Open

zsh initialization performance #3410

maquejp opened this issue Aug 14, 2024 · 3 comments
Labels
performance This relates to anything regarding the speed of using nvm. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh

Comments

@maquejp
Copy link

maquejp commented Aug 14, 2024

Operating system and version:

nvm debug output:

nvm --version: v0.40.0
$SHELL: /usr/bin/zsh
$SHLVL: 1
whoami: 'devlin'
${HOME}: /home/devlin
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /opt/oracle/instantclient_21_5:${HOME}/Developments/flutter/bin:${HOME}/Developments/flutter/bin:/usr/local/bin:${NVM_DIR}:${NVM_DIR}/versions/node/v20.12.2/bin:${HOME}/development/flutter/bin:${HOME}/.cargo/bin:${HOME}/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/sbin:/usr/local/bin:/snap/bin:/snap/bin:${HOME}/.local/share/JetBrains/Toolbox/scripts
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8.1 (x86_64-ubuntu-linux-gnu)'
uname -a: 'Linux 6.5.0-45-generic #45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 15 16:40:02 UTC 2 x86_64 x86_64 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Ubuntu 22.04.4 LTS  
random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
awk: /usr/bin/awk, mawk 1.3.4 20200120
curl: /usr/bin/curl, curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/3.0.2 zlib/1.2.11 brotli/1.0.9 zstd/1.4.8 libidn2/2.3.2 libpsl/0.21.0 (+libidn2/2.3.2) libssh/0.9.6/openssl/zlib nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.18
wget: /usr/bin/wget, GNU Wget 1.21.2 built on linux-gnu.
git: /usr/bin/git, git version 2.34.1
ls: cannot access 'grep:': No such file or directory
grep: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}), grep (GNU grep) 3.7
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
rm: /usr/bin/rm, rm (GNU coreutils) 8.32
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.8.0
nvm current: v20.12.2
which node: ${NVM_DIR}/versions/node/v20.12.2/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v20.12.2/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v20.12.2
npm root -g: ${NVM_DIR}/versions/node/v20.12.2/lib/node_modules

nvm ls output:

->     v20.12.2
default -> node (-> v20.12.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.12.2) (default)
stable -> 20.12 (-> v20.12.2) (default)
lts/* -> lts/iron (-> v20.12.2)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.20.2 (-> N/A)
lts/iron -> v20.12.2

How did you install nvm?

install script in readme

What steps did you perform?

Opening a Terminal (Ubuntu)

What happened?

The terminal take long time since a few days to "initialise", I am using zsh and oh-my-zsh
In addition the nvm command are also slow

I have zprofed

num calls time self name

  1. 1 20891.60 20891.60 97.38% 11980.82 11980.82 55.85% nvm_auto
  2. 2 8901.02 4450.51 41.49% 6244.29 3122.14 29.11% nvm
  3. 1 1582.49 1582.49 7.38% 1576.41 1576.41 7.35% nvm_ensure_version_installed
  4. 2 1019.62 509.81 4.75% 1019.62 509.81 4.75% nvm_grep

What did you expect to happen?

Quicker access to my cmd line as now it take a few seconds to load it

Is there anything in any of your profile files that modifies the PATH?

zmodload zsh/zprof

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

Path to your oh-my-zsh installation.

export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
zstyle ':omz:update' mode auto # update automatically without asking
zstyle ':omz:plugins:nvm' lazy yes
plugins=(git python docker docker-compose zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
alias dcd="docker compose down"
alias dcu="docker compose up -d"
alias dcl="() {docker logs -f $1}"
alias dcr="dcd ; dcu"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$NVM_DIR:$PATH"
export PATH="/usr/local/bin:$PATH"
export ANDROID_HOME=/home/devlin/Android/Sdk
export ANDROID_NDK=/home/devlin/Android/Sdk/ndk
export PATH="$HOME/Developments/flutter/bin:$PATH"
export PATH="/home/devlin/Developments/flutter/bin:$PATH"
export PATH="/opt/oracle/instantclient_21_5:$PATH"
export LD_LIBRARY_PATH="/opt/oracle/instantclient_21_5:$LD_LIBRARY_PATH"

Load Angular CLI autocompletion.

source <(ng completion script)

To customize prompt, run p10k configure or edit ~/.p10k.zsh.

[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

zprof

@shriharip
Copy link

shriharip commented Aug 23, 2024

I want to link the old issue here as the problem still exists #2724

On a mac os

2,6 GHz 6-Core Intel Core i7
16GB Ram

Fresh install of Sonoma. and both zsh and fish shells take lot of time to load.

@ljharb
Copy link
Member

ljharb commented Aug 23, 2024

@shriharip nvm doesn't support fish, but thanks for the link for zsh.

@ljharb ljharb added performance This relates to anything regarding the speed of using nvm. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh labels Aug 23, 2024
@ljharb ljharb changed the title Performance zsh initialization performance Aug 24, 2024
@craiganderson-iotv
Copy link

I can confirm that initialisation takes >10 seconds on macOS 15 running on an i7 Mac mini with 16 GB RAM
It was much faster on macOS 14, though still observably slow — ~2-3 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance This relates to anything regarding the speed of using nvm. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh
Projects
None yet
Development

No branches or pull requests

4 participants