-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Perf] use
/nvm_die_on_prefix
: replicate npm config algorithm and remove npm config
call
#2317
Conversation
…remove `npm config` call
Here's the speedup I'm seeing with this change:
|
Wow, that seems huge - thank you for the benchmarks! |
93cc2ab
to
4cfc3f9
Compare
Wow! |
The current version of nvm doesn't run as long on my machine, but still quite an improvement! Running against bash$ hyperfine "bash -c '. ~/.nvm/nvm.sh'" "bash -c '. ~/proj/nvm/nvm.sh'"
Benchmark #1: bash -c '. ~/.nvm/nvm.sh'
Time (mean ± σ): 628.6 ms ± 7.8 ms [User: 614.2 ms, System: 142.0 ms]
Range (min … max): 619.3 ms … 641.8 ms 10 runs
Benchmark #2: bash -c '. ~/proj/nvm/nvm.sh'
Time (mean ± σ): 346.4 ms ± 4.4 ms [User: 319.1 ms, System: 112.4 ms]
Range (min … max): 340.1 ms … 355.3 ms 10 runs zsh$ hyperfine "zsh -c '. ~/.nvm/nvm.sh'" "zsh -c '. ~/proj/nvm/nvm.sh'"
Benchmark #1: zsh -c '. ~/.nvm/nvm.sh'
Time (mean ± σ): 764.0 ms ± 11.7 ms [User: 756.5 ms, System: 158.1 ms]
Range (min … max): 745.8 ms … 780.0 ms 10 runs
Benchmark #2: zsh -c '. ~/proj/nvm/nvm.sh'
Time (mean ± σ): 482.3 ms ± 6.8 ms [User: 467.3 ms, System: 122.4 ms]
Range (min … max): 475.5 ms … 496.4 ms 10 runs I'm unsure where that >100ms between zsh and bash comes from though... |
Seems to be roughly twice as fast, from around I would love one day for |
@matthiassaihttam thanks! if you have any more information (performance metrics, which parts of nvm contribute how much to that extra 170ms, etc), filing a new issue with it would be greatly appreciated. |
v0.37.0 has been released with this change. |
Fixes #2251. Fixes #1774. Fixes #1694. Fixes #1277. Fixes #1261. Fixes #1242. Fixes #966. Fixes #926. Fixes #860. Fixes #781. Fixes #709. Closes #1826. Closes #730.
This PR removes the call to
npm config get prefix
onnvm use
, instead partially replicating the algorithm npm itself uses to build up its config. Since we don't have to actually produce a config, merely detect if any option is set that would influencenpm config get prefix
(namely,prefix
orglobalconfig
), the checks are simpler and can be done relatively quickly. Previously, #1679, 1458de7, 8ee6f30, and a1def71 implemented partial forms of this checking. This PR specifically adds the checks for npmrc files, which allows the call to npm to be removed.