How to write friendly Java JIT optimization code?

If you want to squeeze the last bit of performance out of your code, you would like to use JIT optimization as best as possible. For example, a labeling method to simplify the method, avoid polymorphism in critical places, etc.

But I could not find a link or a list of options that a java programmer can use to “tip” the JIT compiler for faster code? Don't we have a list of “best programming” practices for low latency performance from JIT?

+6
source share
2 answers

The best way to write JIT-friendly code is to write simple, simple code because it is what JIT is looking for and knows how to optimize. No tricks!

Different JVMs also have different JITs, so to be sure that your code works well with all of them, you should not rely on any of them.

A common way to improve JIT performance is through the external configuration of the JVM. Since most JVMs today know how to directly access the inline code method, most performance results come from tuning the garbage collector. Here, a lot of effort is used to avoid having to stop your program during collection, and you can tune your knowledge a bit about how the basic equipment is configured and what works better than others. But not Java code, it should be simple and simple.

+10
source

HotSpot and others have repeatedly stated that the best approach is to write simple, simple code.

+7
source

Source: https://habr.com/ru/post/891772/


All Articles