Java Reference
In-Depth Information
Inlining is enabled by default. It can be disabled using the -XX:-Inline flag, though it is
such an important performance boost that you would never actually do that (for example, dis-
abling inlining reduces the performance of the stock batching test by over 50%). Still, be-
cause inlining is so important, and perhaps because there are many other knobs to turn, re-
commendations are often made regarding tuning the inlining behavior of the JVM.
Unfortunately, there is no basic visibility into how the JVM inlines code. (If you compile the
JVM from source, you can produce a debug version that includes the flag -
XX:+PrintInlining . That flag provides all sorts of information about the inlining decisions
that the compiler makes.) The best that can be done is to look at profiles of the code, and if
there are simple methods near the top of the profiles that seem like they should be inlined, try
some experiments with inlining flags.
The basic decision about whether to inline a method depends on how hot it is and its size.
The JVM determines if a method is hot (i.e., called frequently) based on an internal calcula-
tion; it is not directly subject to any tunable parameters. If a method is eligible for inlining
because it is called frequently, then it will be inlined only if its bytecode size is less than 325
bytes (or whatever is specified as the -XX:MaxFreqInlineSize= N flag). Otherwise, it is eli-
gible for inlining only if it is small: less than 35 bytes (or whatever is specified as the -
XX:MaxInlineSize= N flag).
Sometimes you will see recommendations that the value of the MaxInlineSize flag be in-
creased so that more methods are inlined. One often overlooked aspect of this relationship is
that setting the MaxInlineSize value higher than 35 means that a method might be inlined
when it is first called. However if the method is called frequently—in which case its per-
formance matters much more—then it would have been inlined eventually (assuming its size
is less than 325 bytes). Otherwise, the net effect of tuning the MaxInlineSize flag is that it
might reduce the warm-up time needed for a test, but it is unlikely that it will have a big im-
pact on a long-running application.
Search WWH ::

Custom Search