Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of JRuby performance optimization

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the JRuby performance optimization methods". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what JRuby performance optimization methods are.

1. Tuning the compiler

JRuby has long abandoned the secret to follow XRuby on the road of compiling this cow B, compiling Ruby Script into bytecode, so this link can not be ignored.

There are two compilation methods:

◆ AOT mode: directly generate class files, take off the skin of Ruby, we are everyone's "love" Java.

◆ JIT model: make full use of mature jit technology, we do not take off completely, hazy beauty is the real beauty. It is enabled by default from version 0.9.9.

Jruby-J-Djruby.jit.enabled=false

2. Close ObjectSpace

ObjectSpace is a module that Ruby uses to manipulate all run-time objects, which is quite awesome. The implementation of this is relatively easy in c ruby, but it is more expensive for JRuby. In fact, in most cases, you don't need it, so it's best to turn it off. JRuby provides

Jruby-J-Djruby.objectspace.enabled=false

Option to close it.

3. Open thread pool

We know that threads in c ruby are green lightweight threads, so the runtime is immobile with a hundred or so "threads" running around. However, in JRuby, the implementation of threads is a real native thread (that is, Ruby threads and Java threads are one to one). It is no wonder that you are so easy to move hundreds of threads. So JRuby provides a thread pool option to open threads as much as possible at run time, but when short-lived Ruby threads are created repeatedly, they will be reused, which improves performance in most cases, especially if one thread is started for each call. However, the specific effect is still the actual data to be tested.

Jruby-J-Djruby.thread.pooling=true

4. Use Java "server" mode virtual machine, which is a well-known JRuby performance optimization technique.

Jruby-J-server myscript.rb thank you for reading, these are the contents of "what are the JRuby performance optimization methods?" after the study of this article, I believe you have a deeper understanding of what JRuby performance optimization methods have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report