The growing sense of JRuby is a promising project, combining Ruby's sexy syntax with Java's extremely rich class library, and the ability of a team to continually fix bugs and improve performance, which has the potential to be a "boy killer". The four recommendations for performance tuning are listed on the JRuby wiki:
1, tuning compiler, JRuby long qiantouming follow Xruby embarked on the path of compiling this cow B, the Ruby script compiled into bytecode, so this link is definitely can not be ignored.
Two ways of compiling:
AOT mode: Directly generated class file, take off ruby this layer of skin, we are people to see "Love" java.
JIT mode: Make full use of the mature JIT technology, we are not all off, hazy beauty is really beautiful. The default from the 0.9.9 version of the start is opened, the closure of the words (I would like to say all off)
Jruby-j-djruby.jit.enabled=false
2. Close ObjectSpace
ObjectSpace is a module that Ruby uses to manipulate all Run-time objects, and this function is rather bull X. This implementation in C Ruby is relatively easy, but for the JRuby cost is more expensive, in fact, in most cases you basically do not use this dongdong, then it is best to close it, JRuby provides
Jruby-j-djruby.objectspace.enabled=false
option to close it.
3. Open Thread Pool
We know that the threads in C Ruby are green lightweight threads, so the runtime runs with a hundred 10 "threads" running a run full of inscribed; However, in JRuby, the implementation of the thread is the local thread (that is, ruby thread and Java thread 1:1), You are so motionless hundreds of threads that it's not slow to blame. So JRuby provides a thread pool option that runs as much as you want, but when short-lived Ruby threads are repeatedly created, these threads are reused, which in most cases improves performance, especially if each call starts with a thread. But the concrete effect is still to test the actual data to speak.
Jruby-j-djruby.thread.pooling=true
4, the use of Java "Server" mode virtual machine, the Earth fornication all know
Jruby-j-servermyscript.rb
5, try to use the latest JDK, in my test, jdk6 run JRuby is the most efficient.