Speeding up rails boot time in development?

I recently switched from REE to ruby 1.9.2 and I was shocked by how
long it takes for rails to startup. This isn’t as much of an issue in
production, but in development and test environments it’s almost
unusable because it’s killing my workflow.

for example, sometimes I need to run a single test or play around in
the console. I’ve made sure I’m only loading gems I need and I’ve
switched to the RVM patched version of 1.9.2 which is a big help.
I’m also using spork for my tests. However, it still takes 20 +
seconds to load a console. Also, spork is fantastic for unit and
functional tests but can’t be used for integration tests because spork
requires config.cache_classes to be set to false, but integration
tests are painfully slow with that setting.

Is there anything else I can do to speed up the startup time,
especially in the development environment?

Dave W.worth wrote in post #1009317:

I recently switched from REE to ruby 1.9.2 and I was shocked by how
long it takes for rails to startup. This isn’t as much of an issue in
production, but in development and test environments it’s almost
unusable because it’s killing my workflow.

for example, sometimes I need to run a single test or play around in
the console. I’ve made sure I’m only loading gems I need and I’ve
switched to the RVM patched version of 1.9.2 which is a big help.
I’m also using spork for my tests. However, it still takes 20 +

I’ve heard rumblings about this problem being addressed in Ruby 1.9.3.
I’ve also heard of people working on alleviating this problem in the
mean time, but I don’t know where to direct you for more information on
that.

However, 20+ seconds to load the console does seem a bit extreme. I
noticed a slowdown on my system as well, but nothing like that. For
example on my fairly smallish Rails 3.0 app under 1.9.2-p180 my console
launches in approximately 6 seconds.

Evan,

I have actually been struggling with the same thing, but I didn’t know
about
spork. I just installed it and it looks like it does save quite a bit of
time to run single tests.

Sorry I don’t have any help for you, but thanks for posting!


Ylan

On 6 July 2011 12:23, Evan C [email protected] wrote:

functional tests but can’t be used for integration tests because spork
requires config.cache_classes to be set to false, but integration
tests are painfully slow with that setting.

Is there anything else I can do to speed up the startup time,
especially in the development environment?

I have stuck with ruby 1.8.7 for exactly this reason. There was a
thread on rails core about this [1] but I do not know if anything came
of it.

[1]
http://groups.google.com/group/rubyonrails-core/browse_thread/thread/88519ef5a53088a1/c01ba447c6dc0de7?lnk=raot&pli=1

Colin

Hey Evan,

I’m having the same issues, but I thought I’d add my query to yours so
we can both get responses (hopefully).

In essence, I recently started a contract with a company who is
running with cache_classes = true in their dev environment. The
result is that you end up having to restart the dev server and then
waiting 20-30 seconds for it all to load before you can see any
changes.

To me this is atrocious, and I’m looking for ideas on how to minimize
this.

One idea I’ve had is to come up with a way to specify 2-3 files that
get reloaded on every request, but only those files. It’s not a great
solution, but it would solve my immediate problem. I’m not sure how
to go about it, but I’m considering trying to abuse require_dependency
if possible.

Does anyone have any ideas on how to speed this up in the dev
environment, or ideas for other areas to look into for speeding up the
dev cycle? As is, this killing productivity.

On Wed, Jul 6, 2011 at 4:23 AM, Evan C [email protected] wrote:

functional tests but can’t be used for integration tests because spork
requires config.cache_classes to be set to false, but integration
tests are painfully slow with that setting.

Is there anything else I can do to speed up the startup time,
especially in the development environment?

Hi, on my system, it takes 5 - 7 seconds to start the web server. BTW,
I’m
using Mac OS and thin web server. Next, I would make sure that spork is
properly setup on your system. Also, if you haven’t installed autotest,
then I would recommend getting this properly installed as well. If
you’re
using RSpec, then make sure that .rspec contains the following at an
absolute minimum:

–drb

How are you running spork from the command? If you’re using bundler
within
your Rails project, you should be starting spark as follows:

bundle exec spork

Also, if you’re doing TDD/BDD, then you’ll be spending the majority of
your
time doing the following:

a) writing a failing test
b) implementing the code that makes the test pass
c) refactoring
d) goto (a)

If you’re using Rails 3, you can find an excellent walk through here for
getting your environment setup.

http://ruby.railstutorial.org/chapters/static-pages#sec:TDD

Last but not least, I would check the overall performance of the
underlying
hardware because this can be one of the variables for contributing to
the
slowness within your application startup.

Good luck,

-Conrad