Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 initializes extremely slow on Ruby 1.9.2

I'm using RVM for managing environment, installed Ruby 1.9.2.p136 (i think its latest release.) and Rails 3, created gemsets and run bundler. everything working good so far but;

Rails initalizes extremely slow when running commands, i.e. generate, destroy, rake etc. Takes about 30-45 seconds to complete command. This will never happens if use Ruby Enterprise Edition or Ruby 1.8.7

Why this happens. Any thoughts? Running on Ubuntu 10.10, RVM, Ruby 1.9.2, Rails 3

Thanks.

like image 789
Harry Avatar asked Jan 25 '11 01:01

Harry


2 Answers

There is a thread about this on Rails-Core - http://groups.google.com/group/rubyonrails-core/browse_thread/thread/88519ef5a53088a1/c01ba447c6dc0de7?lnk=raot

To quote Yehuda Katz

"There are things that the C require code does in 1.9 that slow things down. One such example is re-checking $LOAD_PATH to make sure it is all expanded on every require. This is something that should be addressed by ruby-core. I'll open a ticket on redmine if there isn't one already."

I am also experiencing this problem and a $LOAD_PATH issue seems like a potential cause. Lets hope it gets fixed soon.

like image 191
Alastair Brunton Avatar answered Nov 15 '22 05:11

Alastair Brunton


Try to strace (on unix), dtruss (on mac) your command (might need to "sudo" though). It'll show you where the process is spending its time. Notice where it pauses. This is definitely not normal.

like image 34
Zepplock Avatar answered Nov 15 '22 06:11

Zepplock