2 ms·
> Modern compilers do a lot of things like inlining and unrolling Smart ones do, I've been writing Java lately and that behavior tends to be unpredictable and
by willcipriano 6y ago
> Modern compilers do a lot of things like inlining and unrolling
Smart ones do, I've been writing Java lately and that behavior tends to be unpredictable and rare[0]. I'd use a inline keyword if I had one, or preprocessor directive of some kind if I had that but I don't. I agree it's harder to read but I feel like changing a JVM flag to get a behavior that I want is more inscrutable than having a long method with a comment noting that this in inlined for performance reasons. With modern machines and the price of memory I tend to lean hard to the memory side of the time-memory tradeoff.
[0]"First, it uses counters to keep track of how many times we invoke the method. When the method is called more than a specific number of times, it becomes “hot”. This threshold is set to 10,000 by default, but we can configure it via the JVM flag during Java startup. We definitely don't want to inline everything since it would be time-consuming and would produce a huge bytecode."
https://www.baeldung.com/jvm-method-inlining https://www.baeldung.com/jvm-method-inlining