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

nvm_resolve_local_alias default has bad performance #3416

Open
futurist opened this issue Aug 24, 2024 · 0 comments
Open

nvm_resolve_local_alias default has bad performance #3416

futurist opened this issue Aug 24, 2024 · 0 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

Comments

@futurist
Copy link

futurist commented Aug 24, 2024

Operating system and version:

macOS 14.5

nvm debug output:

nvm --version: v0.39.7
$TERM_PROGRAM: iTerm.app
$SHELL: /opt/homebrew/bin/bash
$SHLVL: 1
whoami: 'my'
${HOME}: /Users/my
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${HOME}/.pyenv/shims:${HOME}/.pyenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:${HOME}/.local/bin:${HOME}/.gobrew/current/bin:${HOME}/.gobrew/bin:${HOME}/anaconda3/bin:${HOME}/go/bin:${HOME}/.deno/bin:${HOME}/bin/flutter/bin:${HOME}/bin:${HOME}/Library/Python/2.7/bin:${HOME}/.cargo/bin:${HOME}/go/bin:${HOME}/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/opt/openjdk@17/bin:${HOME}/.sdkman/candidates/gradle/current/bin:${HOME}/.pyenv/bin:${HOME}/.cargo/bin:${HOME}/go/bin:${HOME}/.gobrew/current/bin:${HOME}/.gobrew/bin:${NVM_DIR}/versions/node/v22.5.1/bin:${HOME}/.local/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/puppetlabs/bin:/Applications/iTerm.app/Contents/Resources/utilities:${HOME}/.rvm/bin:/usr/local/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: 'http://npm.taobao.org/mirrors/node'
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.2.32(1)-release (aarch64-apple-darwin23.4.0)'
uname -a: 'Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030 arm64'
checksum binary: 'sha256sum'
OS version: macOS 14.5 23F79
awk: /usr/bin/awk, awk version 20200816
curl: /usr/bin/curl, curl 8.6.0 (x86_64-apple-darwin23.0) libcurl/8.6.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.61.0
-bash: wget: command not found
wget:  (wget -c),
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir (_omb_util_alias_init_mkdir)
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.39.3 (Apple Git-146)
grep: /usr/bin/grep (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
nvm current: v22.5.1
which node: ${NVM_DIR}/versions/node/v22.5.1/bin/node
which iojs:
which npm: ${NVM_DIR}/versions/node/v22.5.1/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v22.5.1
npm root -g: ${NVM_DIR}/versions/node/v22.5.1/lib/node_modules

nvm ls output:

       v18.20.4
->      v22.5.1
default -> node (-> v22.5.1)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v22.5.1) (default)
stable -> 22.5 (-> v22.5.1) (default)
lts/* -> lts/iron (-> N/A)
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.4
lts/iron -> v20.15.1 (-> N/A)

How did you install nvm?

install script in readme

What steps did you perform?

  1. use this script in thread: https://stackoverflow.com/a/5015179/4691964
  2. use gdate(from coreutils) instead of date to make %N work
  3. analyze the log

What happened?

Found the nvm_resolve_local_alias default have bad performance.

It took 2 seconds in my M3 chip macbookPro:
image

Why it need 2 seconds to get default version? seems it's just a simple task.

What did you expect to happen?

nvm_resolve_local_alias default should be quick, and save 2 seconds for my bash startup.

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

~/.bashrc

@futurist futurist changed the title nvm_resolve_local_alias default performance nvm_resolve_local_alias default have bad performance Aug 24, 2024
@futurist futurist changed the title nvm_resolve_local_alias default have bad performance nvm_resolve_local_alias default has bad performance Aug 24, 2024
@ljharb ljharb added pull request wanted This is a great way to contribute! Help us out :-D performance This relates to anything regarding the speed of using nvm. labels Aug 27, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants