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

loading RVM seems slow #2582

Closed
tisba opened this issue Jan 28, 2014 · 12 comments

Comments

Projects
None yet
4 participants
@tisba
Copy link

commented Jan 28, 2014

While trying to debug the slow zsh startup, I noticed that

[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm

takes a significant amount of time. Using time /usr/local/bin/zsh -c "source $HOME/.rvm/scripts/rvm" I noticed that it takes about 1 sec (+/- 150ms). For a college of mine (@railsbros-dirk) the same command (same zsh and RVM version) takes about 0.15s.

I already reinstalled RVM (rvm implode) without any difference.

I'd like to debug this further but I don't know where to start exactly :-/

I'm using

  • OS X 10.9.1
  • rvm 1.25.15 (master)
  • zsh 5.0.5 (via homebrew)
  • iTerm2 Build 1.0.0.20140112
@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 28, 2014

try:

time /usr/local/bin/zsh -c "rvm_trace_flag=1; source $HOME/.rvm/scripts/rvm" 2>&1 | tee big.log

and gist big.log
although zsh tracing has no timestamps - maybe we could find something in there, if it does not help we can add timestamps also to zsh tracing (it's there already for bash, it's slowing things a bit down, but helps a lot to find bottle necks)

@tisba

This comment has been minimized.

Copy link
Author

commented Jan 29, 2014

@mpapis Here is the gist: https://gist.github.com/tisba/8685367. Is there anything in particular I should look for? Thanks for your help!

mpapis added a commit that referenced this issue Jan 29, 2014

mpapis added a commit that referenced this issue Jan 29, 2014

mpapis added a commit that referenced this issue Jan 29, 2014

@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 29, 2014

so the log did not help, I have updated logging to include time, for now trying accuracy to second, if that does not help we can try the slower way with date ... also removed few occurrences of grep should speed things a bit (~100ms)

@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 29, 2014

missed to add - please test again and provide new log

@tisba

This comment has been minimized.

Copy link
Author

commented Jan 29, 2014

hmm, I ran rvm get head (I assumed that your commit is only available there).

$ time /usr/local/bin/zsh -c "rvm_trace_flag=1; source $HOME/.rvm/scripts/rvm" | tee big.log
/usr/local/bin/zsh -c "rvm_trace_flag=1; source $HOME/.rvm/scripts/rvm"  0.08s user 0.08s system 111% cpu 0.148 total
tee big.log  0.00s user 0.00s system 1% cpu 0.148 total

And big.log is empty. I'm confused :-/

But the zsh startup time also significantly improved. time /usr/local/bin/zsh -i -c "exit" is now just about 0.5s.

So either rvm get head did the trick or something else changed on my box.

mpapis added a commit that referenced this issue Jan 29, 2014

@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 29, 2014

please try again, the log should contain some data now ... although I'm not sure it will be fine grained enough to find the spot that slows it down

@tisba

This comment has been minimized.

Copy link
Author

commented Jan 30, 2014

@mpapis here you go https://gist.github.com/tisba/8713474

I'm sorry @mpapis, but the slowness problem seems to have vanished into thin air. zsh start up time seems to be okay now again. I have no idea what has changed :-/

@tisba tisba closed this Jan 30, 2014

@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 30, 2014

(in the gist) everything happened in the scope of one second, please let me know if you hit this problem again

@tisba

This comment has been minimized.

Copy link
Author

commented Jan 30, 2014

will do, sorry for the noise :-/

@mpapis

This comment has been minimized.

Copy link
Member

commented Jan 30, 2014

it's fine, we got one optimization thank to you :)

@a0s

This comment has been minimized.

Copy link

commented Aug 25, 2016

Hmm, i have same problem with speed of source "$HOME/.rvm/scripts/rvm" last two days , but after profiled with time /usr/local/bin/bash -c "rvm_trace_flag=1; source $HOME/.rvm/scripts/rvm" 2>&1 | tee big.log the problem was disappeared. The log is here https://gist.github.com/orangeudav/80fff5484198f58085bf17447a787042
This is sort of magic i think :)
ps In one moment i saw error that uname and ps not found ...

> rvm --version
rvm 1.27.0 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
> uname -a
Darwin scud.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
> echo $PATH
/Users/orangeudav/.rvm/gems/ruby-2.3.1/bin:/Users/orangeudav/.rvm/gems/ruby-2.3.1@global/bin:/Users/orangeudav/.rvm/rubies/ruby-2.3.1/bin:/Users/orangeudav/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/orangeudav/.rvm/bin
@TheNotary

This comment has been minimized.

Copy link

commented Mar 18, 2018

Confirmed, it's like magic,

$ rvm version
rvm 1.28.0 (latest) by Wayne E. Seguin

$ time /bin/bash -c "rvm_trace_flag=1; source $HOME/.rvm/scripts/rvm" 2>&1 | tee big.log

New terminals are booting up in under half a second (as opposed to >1s before the magic 'diagnostic' command was run). It seems that it does take 200ms to perform the source command still. Is there another diagnostic command to improve upon that or is 200ms expected performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.