I would like some clarity on how to use java performance options with
jruby.
It seems like there is a -J-X… flag for the jruby which mimic the
java
options but I don’t know which takes preference and what’s the best way
to
deal with these options.
Normally I run things from scripts which end up constructing something
like
this
Hate to bump myself but I would really appreciate some clarity about
this
issue.
Today I am fooling around with to torqbox the next generation of
torquebox.
I installed the gem and am running jruby 1.7.8
I run the torqbox command on my sample rails app (no real controllers,
just
a large gemfile) and it shows a running memory size of a little under
400
megs. I then run the following command
/usr/bin/java -jar jruby/jruby-complete-1.7.8-with-bundler.jar
bin/torqbox
(I also tried it with a plain old jruby-complete no bundler)
and the same app now takes up almost twice as much memory (700K+).
warning: -J-XX:+TieredCompilation argument ignored (launched in same
VM?)
warning: -J-XX:TieredStopAtLevel=1 argument ignored (launched in same
VM?)
warning: -J-noverify argument ignored (launched in same VM?)
warning: -J-Xmx500m argument ignored (launched in same VM?)
warning: -J-Xss2048k argument ignored (launched in same VM?)
warning: -J-Xcompile.invokedynamic=false argument ignored (launched in
same
VM?)
warning: -J-Djruby.launch.inproc=false argument ignored (launched in
same
VM?)
and no change still large amount of memory being used.
So it looks like JRUBY_OPTS is being ignored altogether. Can anybody
explain how JRUBY_OPTS is supposed to work.
This is an artifact of the way you’re starting JRuby. The “-J” prefixed
JRUBY_OPTS are JVM options that have to be set before the JVM boots.
This is why your options work when passed directly to the ‘java’ command
and why it warns about the arguments being ignored when you set
$JRUBY_OPTS but do not use the jruby launcher (and instead use java -jar
…).
Because you’re using JRuby as a jar instead of downloading a JRuby
distribution and using its launchers, it’s up to use to make sure you
set the appropriate JVM options before the JVM boots.
Is there a preference as to which one I should set.
From what I can gather you can set _JAVA_OPTIONS in your environment and
you can set JRUBY_OPTS . if I set _JAVA_OPTIONS will invoking jruby use
those options? If I set both which gets priority?
JAVA_OPTS is used by the jruby launcher to pass options to the JVM
as it starts. That environment variable does nothing if you use the
jruby jar directly.
JRUBY_OPTS is used by both the jruby launcher and JRuby itself. When
using the launcher, all command-line arguments will work as if passed
to the jruby command. When using the jar directly, only options
processed after the JVM starts will be honored (Ruby compat version,
etc). In this latter case, options handled only by the launcher will
not work (-Xjit.threshold=# style options, --manage, others you see
processed by bin/jruby.bash).
The -J options are processed by the JRuby launcher and used to pass
options directly to the JVM. When using the jar directly, remove the
-J and pass those options to the java command.
There’s no real preference as to which you use. they are all provided
as convenience mechanisms for the various launch scenarios.
Those options can still be passed via JRUBY_OPTS or directly on the
commandline. It’s just the “-J” prefixed options that won’t be supported
with “java -jar …”