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

Performance issues changing versions on linux #926

Closed
mockdeep opened this issue Dec 6, 2015 · 7 comments · Fixed by #2317
Closed

Performance issues changing versions on linux #926

mockdeep opened this issue Dec 6, 2015 · 7 comments · Fixed by #2317
Labels
needs followup We need some info or action from whoever filed this issue/PR. performance This relates to anything regarding the speed of using nvm.

Comments

@mockdeep
Copy link

mockdeep commented Dec 6, 2015

I'm using nvm with avn on Linux Mint and seeing some delays switching between different projects, anywhere from half a second to nearly 2 seconds, even when the version doesn't change:

$ time cd project_1
avn activated v4.2.2 (avn-nvm v4.2.2)
real    0m1.738s
user    0m1.146s
sys 0m0.829s

project_1 $ time cd ../project_2
avn activated v4.2.2 (avn-nvm v4.2.2)
real    0m1.738s
user    0m1.162s
sys 0m0.820s

project_2 $ time nvm use 4.2.2
Now using node v4.2.2 (npm v3.4.1)
real    0m0.625s
user    0m0.507s
sys 0m0.167s

For comparison, I also timed rvm switching ruby versions and it's pretty quick when changing directories:

$ time cd project_1
real    0m0.074s
user    0m0.025s
sys 0m0.072s

project_1 $ ruby -v
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]

project_1 $ time cd ../project_2
real    0m0.079s
user    0m0.032s
sys 0m0.067s

project_2 $ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

What's interesting is that if I call rvm use directly, it's actually a little slower. Not sure if they do some extra checks, or if maybe they change ruby versions on cd asynchronously:

project_2 $ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

project_2 $ time rvm use 2.2.3
Using /home/fletch/.rvm/gems/ruby-2.2.3
real    0m0.395s
user    0m0.271s
sys 0m0.133s
@ljharb
Copy link
Member

ljharb commented Dec 6, 2015

I'm not sure what rvm does, but it's very strange that avn would add over a second. Can you try nvm use somethingElse && time nvm use in the directory, so simulate nvm's reading of the .nvmrc file?

@ljharb ljharb added needs followup We need some info or action from whoever filed this issue/PR. performance This relates to anything regarding the speed of using nvm. labels Dec 6, 2015
@mockdeep
Copy link
Author

mockdeep commented Dec 7, 2015

@ljharb, looks basically the same as above:

$ nvm use 0.10.32 && time nvm use
Now using node v0.10.32 (npm v1.4.28)
Found '/home/fletch/projects/project_1/.nvmrc' with version <4.2.2>
Now using node v4.2.2 (npm v3.4.1)
real    0m0.617s
user    0m0.511s
sys 0m0.156s

@ljharb
Copy link
Member

ljharb commented Dec 7, 2015

0.6s, while not as fast as I'd like, is plenty fast enough. Based on the timings, I'd say it might be something inside avn itself? Let's keep this open and continue discussion on wbyoung/avn#32 :-) thanks for filing!

@wbyoung
Copy link
Contributor

wbyoung commented Dec 7, 2015

@ljharb is the reading of the .nvmrc file the majority of the work that's being done in the timed part of nvm use 0.10.32 && time nvm use?

As I understand it, nvm just updated the PATH, right? Anything else significant going on there?

If all that's happening is a file read and that's taking 0.6s, then I'd expect everything on the system to run slowly.

@mockdeep
Copy link
Author

mockdeep commented Dec 7, 2015

@wbyoung it actually takes about the same amount of time for me when I nvm use 4.2.2, saving it the trouble of reading the file.

@ljharb
Copy link
Member

ljharb commented Dec 7, 2015

It's 1) reading .nvmrc, 2) doing an nvm ls and grepping the output to ensure it's a matched version, 3) repeating step 2 if it's an alias or doesn't directly resolve to a version, and 4) updating the PATH.

One possible improvement could be using --silent to avoid invoking npm (to print the npm version)?

@em
Copy link

em commented Nov 7, 2016

Same here. Extremely slow. Up to 10 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR. performance This relates to anything regarding the speed of using nvm.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants