This is a bit of a follow-up from a previous question on improving rails console loading time.
The first great suggestion was to figure out which gems take too long.
Next answer, suggested using :require => nil and loading those gems later.
With some gems however, it’s not entirely clear how to accomplish this without breaking things. Here’s a list of our ‘biggest offenders’, I wonder if someone can suggest the best approach to loading them only when necessary?
require gon: 2.730000 (2.870059)
require omniauth-openid: 1.410000 (1.503858)
require cancan: 2.640000 (2.707467)
require fog: 2.730000 (2.846530)
require activeadmin: 3.650000 (3.923877)
and of course there are many more that take around 1 second or less, which also adds up… but at least removing the big ones will already improve things.
While not a direct answer to your question, there are two things you might try:
First, have you tried the Falcon patches for 1.9.3? The patches include some pretty significant load time improvements.
If you’re using RVM, you can do a quick-and-dirty install with
Second, make sure you’re setting GC tuning environment variables. Ruby, by default, allocates GC parameters that are appropriate for small scripts, but not for full Rails apps. Here are my settings, though you’d want to derive your own based on your application’s needs:
And my results using ruby 1.9.3-p286:
Setting the GC tuning parameters has the biggest improvement, but we can get yet another ~26% improvement performance by using the falcon patches. The combination of the falcon patches plus the GC parameters results in over a 75% reduction in boot time.