For small tasks, such as converting an AsciiDoc document, there are certain flags you can enable for JRuby and Java that make it startup much, much faster, esp when invoked via Java (like 3x as fast). The trade-off is that you are disabling optimizations that impact long-running processes, but...exactly, we don't need them.
Here's the set of flags I've worked out thus far:
-Djruby.compat.version=RUBY1_9 -Djruby.compile.mode=OFF -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none
Here's an example of making a simple JRuby call without these flags:
time jruby -e 'puts "Hello, World!"'
real 0m1.170s
user 0m1.966s
sys 0m0.078s
Now I'll add these flags,
export JRUBY_OPTS="-Djruby.compat.version=RUBY1_9 -Djruby.compile.mode=OFF -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none"
and call the same script again:
time jruby -e 'puts "Hello, World!"'
real 0m0.090s
user 0m0.070s
sys 0m0.021s
That certainly speeds things up.
Now, I'll execute the generate-resources goal in Maven to invoke the Asciidoctor Maven plugin, first without any flags:
real 0m7.361s
user 0m14.733s
sys 0m0.297s
Now I'll add the flags. The only way I can figure out to pass these flags to JRuby is to set them as Maven options:
real 0m3.310s
user 0m4.537s
sys 0m0.260s
Voila! I think that will certainly save a lot of waiting :)
If anyone knows:
a. Flags that can make it go even faster
b. How to pass flags to JRuby w/o having to apply them to Maven globally
please let us know!
-Dan
--
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597