3

I have a pretty large rails app (Rails 3.2.3), using the asset pipeline. There are are quite a few files in the assets folder.

Under 1.8.7, running rake assets:precompile takes 4 minutes. This is long, but due to the sheer number of assets I'm willing to tolerate it.

The problem is that after upgrading the app to 1.9.2, running rake assets:precompile takes 28 minutes.

Here are the relevant gem versions:

rails (= 3.2.3)
uglifier (1.2.3)
  execjs (~> 1.3.0)
therubyracer (~> 0.9.9)
  libv8 (~> 3.3.10)
sprockets (2.1.2)
  hike (~> 1.2)
  rack (~> 1.0)
  tilt (~> 1.1, != 1.3.0)

When I tail -f log/production.log I see the assets being compiled, and I can't pinpoint the long delay to a single asset (though it does seem like I see the same assets multiple times in the logs -- presumably because there are multiple steps for each asset?)

What other steps should I try to help diagnose what the issue is?

Ben Scheirman
  • 39,034
  • 20
  • 96
  • 135
  • 1
    1.9.3 breaks a few other things, but it's on my list of things to check. But this *should* work fine on 1.9.2... – Ben Scheirman May 18 '12 at 16:31
  • 1
    Indeed, but 1.9.2 had serious regressions with load time that were fixed in 1.9.3. You might want to try [backporting the patch](http://www.rubyinside.com/get-edge-ruby-faster-loading-ruby-1-9-2-now-4973.html) to your 1.9.2 install and see if that helps. This is just a guess though. – Andrew Marshall May 18 '12 at 17:05
  • 1
    I did end up upgrading to 1.9.3 and asset compilation now takes roughly 3-4 minutes. – Ben Scheirman May 19 '12 at 18:38
  • @AndrewMarshall, Care to answer the question so I can mark yours as the right one? – Ben Scheirman May 19 '12 at 18:38
  • Also, just for completeness, the problem definitely lied within the stylesheets folder, as removing this and running asset precompile on 1.9.2 produced quick results. Must be the sheer number of stylesheets in the app? /shrug. – Ben Scheirman May 19 '12 at 18:39
  • Done! See below. Glad it helped `:)`. – Andrew Marshall May 20 '12 at 01:35

1 Answers1

1

Ruby 1.9.2 had severe regressions in load time, which I believe grew exponentially with the number of files loaded. This hit Rails apps really hard, and I suspect it's the cause behind the greatly increased asset compilation time you're seeing.

This has been fixed in 1.9.3, so try upgrading to that or backporting the load patch to 1.9.2.

Andrew Marshall
  • 89,426
  • 20
  • 208
  • 208