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

Silencing noise in the Rails development log

The standard Rails development log contains a lot of noise that is rarely meaningful for debugging. The Quiet Assets gem is a mandatory part of my Rails development process as it removes the logging noise of the asset pipeline.

Also, if WEBrick is used as a development server, the following entry is logged for each asset pipeline log entry (whether silenced or not by Quiet Assets):

WARN  Could not determine content-length of response body.
Set content-length of the response or set Response#chunked = true

While some have suggested monkey-patching WEBrick or installing Thin as an alternate server (which doesn’t work under JRuby), the simplest way to remove those statements is to add WEBrick specifically in your Gemfile:

gem 'webrick', '~> 1.3.1', group: :development