top | item 10345133

(no title)

pete23 | 10 years ago

Static typing in Java does not give enough information to optimise because of polymorphism. The JIT can observe runtime behaviour and inline method calls at monomorphic sites.

http://insightfullogic.com/2014/May/12/fast-and-megamorphic-...

Worth noting also that Azul's Zing ReadyNow technology for AOT (and indeed their no-pause C4 collector) address some of the specific gripes raised here around the JVM...

discuss

order

jdmichal|10 years ago

This is absolutely correct. The primary optimization in Java JIT is determining the concrete types (potentially) present at the call site and thereby turning dynamic method dispatch (vtable) into static method dispatch. Static method dispatch then allows inlining.

fmstephe|10 years ago

Zing's ReadyNow is useful but really highlights some of the problems with JITs (in some domains). I think that ReadyNow is very interesting because its existence points to some interesting consequences of JITs in performance sensitive domains.

The driving force behind ReadyNow (as I understand it) was that many performance sensitive systems needed to be fast out of the gates on start up. This means that an interpreted->compiled->optimised-compiled transition was not acceptable.

Developers would try to solve this by running dummy data through the system before it was open to real traffic. But this had the unfortunate consequence that the JIT would optimise for dummy data only, including clever inlining at, apparently, monomorphic call sites etc. When real traffic flows into the system the JVM sees that its optimisations are no longer effective/valid. This would trigger a de-compilation/re-compilation of many code sites causing a very noticeable stutter.

Now we have ReadyNow. If you are really committed to Java or the JVM and you don't like these JIT stutters this is your solution. But this is an extra layer of complexity and another thing to be managed and another thing to fail. This is on top of your JVM, jar file soup you may already be struggling with.

I would prefer a good AOT compiler to remove this concern and give me quite good predictable performance. YMMV of course.

Sources

http://www.azul.com/products/zing/readynow-technology-for-zi...

https://groups.google.com/forum/#!searchin/mechanical-sympat...