The simplest guideline is to not inline anything unless it’s something the compiler needs or the IDE suggests. ie. if you are using generic reification you will need to inline that method. The JVM JIT is pretty good about figuring out what to inline, and unless you are very careful inline methods are more likely to hurt performance than help.
08/09/2018, 12:29 PM
If you have small functions and they take lambda parameters make sure to inline them though, those do make a big difference.
08/09/2018, 1:56 PM
how can inline hurt performances?
08/09/2018, 1:58 PM
Increase code size which is bad for caching, and it duplicates code making the JVM and JIT do double work compiling and optimizing it.
08/09/2018, 2:02 PM
Not only that but the JIT will only inline functions of up to a certain size, and inlining is a requirement to perform certain other optimizations, and I believe it won’t do much at all if a function is over a certain size. Big functions are bad for the JIT.