Performance optimization for JRuby (update)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.