Why assets: recompile so slowly on Heroku?

My deployment is to have Precompile Heroku assets. I want them to be precompiled, so I can send them to CDN (via asset_sync ), and I want it to be done on Heroku, so I don't have any compiled assets in my repo. I installed this using the Heroku guide and it works great. I added turbo-sprockets-rails3 to increase speed. Everything worked fine and then stopped; I can’t understand why.

Now, when I deploy (without public/assets ), the assets:precompile Rake task expires on Heroku. To see how long this takes, I went into the shell ( heroku run bash ):

 ~ $ time bundle exec rake assets:precompile AssetSync: YAML file found /app/config/asset_sync.yml settings will be merged into the configuration AssetSync: Syncing. Using: Directory Search of /app/public/assets AssetSync: Done. real 19m29.575s user 17m43.690s sys 0m28.480s 

Twenty minutes! But when I run it locally (2011 iMac), it is only a few minutes:

 $ env RAILS_ENV=production time bundle exec rake assets:precompile --trace ** Invoke assets:precompile (first_time) ** Execute assets:precompile ~/.rbenv/versions/1.9.3-p327-perf/bin/ruby ~/.rbenv/versions/1.9.3-p327-perf/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace ** Invoke assets:precompile:all (first_time) ** Invoke assets:cache:clean (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment AssetSync: YAML file found ~/Code/Ruby/myproject-rails/config/asset_sync.yml settings will be merged into the configuration ** Execute assets:cache:clean ** Execute assets:precompile:all AssetSync: Syncing. Using: Directory Search of ~/Code/Ruby/myproject-rails/public/assets Uploading: assets/application-3a6de939348195e9610f1321df27837a.js Uploading: assets/application-3a6de939348195e9610f1321df27837a.js.gz Uploading: assets/jquery.min-959a5819c76e1508f5a8655c289c0de8.map Uploading: assets/jquery.min.map Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js.gz AssetSync: Done. 179.92 real 19.29 user 3.98 sys 

I wrote Heroku support a week ago, and a few days later they said that they were escalating it to their Ruby team, but so far I have not heard anything. Do any of the smart people in Qaru have any possible solutions?

+4
source share
1 answer

The solution was to use the Heroku instruction to use Ruby 1.9.3, just like my local machine. Apparently 1.9.3 is much faster at compiling assets than 1.9.2, by default Heroku.

To fix this, make sure your Gemfile running:

 source "https://rubygems.org" ruby "1.9.3" # ... 

More details in Heroku docs on Ruby version .

+4
source

All Articles