Reducing Rails asset precompile times on JRuby

Rails asset precompile times on JRuby are considerably slower compared to MRI. I came across this post which provided suggestions on speeding up the asset precompile task.

Using the following options – using Node.js instead of therubyrhino for JS compilation, forcing the JVM to 32 bit (although this can be omitted on a 32 bit JVM) and not using JIT compilation – cut my asset precompile time from 4 mins 37 secs to 2 mins 8 secs. Using Node.js contributed to the majority of that time since I’m using a 32 bit VM.

EXECJS_RUNTIME='Node' JRUBY_OPTS="-J-d32 -X-C" rake assets:precompile

Posted

in

by

Comments

3 responses to “Reducing Rails asset precompile times on JRuby”

  1. Artur Avatar
    Artur

    Thank you for this tip. On 64bit system compilation time changed from 164 sec to 34 sec! :)

  2. Jonathan O'Connor Avatar
    Jonathan O’Connor

    In tests we did recently, our precompile times went down from 15 minutes to a minute when we set config.assets.compress to false. As we don’t have a lot of javascript, this is ok, especially as we can use the already minified versions of jQuery and the other libraries we use.

  3. Za Avatar
    Za

    Thanks for this. Our assets precompile on our 64-bit machine was halved.

    EXECJS_RUNTIME='Node' JRUBY_OPTS="-J-d32 -X-C" bundle exec rake assets:precompile
    122.81s user 7.20s system 113% cpu 1:54.95 total

    bundle exec rake assets:precompile
    470.95s user 9.90s system 178% cpu 4:28.80 total

Leave a Reply

Your email address will not be published. Required fields are marked *