26

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.

5
  • Is this on a brand new app, or on an existing app? Jan 25, 2011 at 3:56
  • 1
    Checked in Sytem Monitor (Ubuntu). Tested now with rake db:migrate command its using %100 cpu with about 50mb ram
    – Harry
    Jan 25, 2011 at 4:14
  • This is strace output shorttext.com/k6g37kpi52
    – Harry
    Jan 25, 2011 at 4:30
  • seems like gettimeofday issue on linux. maybe your kernel has some extra configurations for timer?
    – Zepplock
    Jan 25, 2011 at 5:04
  • No extra configurations. It is clean Ubuntu 10.10 installation. With RVM, Ruby 1.9.2 and gems.
    – Harry
    Jan 25, 2011 at 17:57

2 Answers 2

7

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.

1
3

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.

4
  • I found process ID of the Ruby instance then checked using strace. Process log has lots of wait process. "[pid 2204] 04:26:08.156009 futex(0x58c1c4, FUTEX_WAIT_PRIVATE, 1015189, {0, 9842003}) = -1 ETIMEDOUT (Connection timed out)"
    – Harry
    Jan 25, 2011 at 2:31
  • So network IO, could it be that you are accessing the DB via IP? Do you have proper dns resolver? Try to switch all domain names to IP addresses. You could also run a "netstat -a" to see what/where it is trying to go to.
    – Zepplock
    Jan 25, 2011 at 4:48
  • Currently Rails working on localhost (with development environment)
    – Harry
    Jan 25, 2011 at 4:56
  • 1
    strace and dtruss are fantastic diagnostic tools that I just learned about thanks to this response. Thanks Zepplock
    – Abel
    Jul 15, 2011 at 19:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.