12 ms·
A two-tier JIT. Interesting to see tiered JIT compilation catch on the way it has. I seem to remember a few years ago reading that the Java HotSpot team had giv
by MaxBarraclough 9y ago
A two-tier JIT. Interesting to see tiered JIT compilation catch on the way it has. I seem to remember a few years ago reading that the Java HotSpot team had given up on tiered JIT compilation as being not worthwhile.
How far we've come. A whirlwind tour of todays JITs (apologies for the million links):
.Net Core seems not to use tiered compilation. It never interprets the IR; everything is run through the same JIT compiler. https://github.com/dotnet/coreclr/issues/4331 https://github.com/dotnet/coreclr/issues/4331
HotSpot uses three tiers these days (counting direct interpretation as a tier) - https://docs.oracle.com/javase/8/docs/technotes/guides/vm/performance-enhancements-7.html#tieredcompilation https://docs.oracle.com/javase/8/docs/technotes/guides/vm/pe...
JavaScriptCore/Nitro seems to use four - https://webkit.org/blog/3362/introducing-the-webkit-ftl-jit/ https://webkit.org/blog/3362/introducing-the-webkit-ftl-jit/
Edge's Chakra engine has two - https://blogs.msdn.microsoft.com/ie/2014/10/09/announcing-key-advances-to-javascript-performance-in-windows-10-technical-preview/ https://blogs.msdn.microsoft.com/ie/2014/10/09/announcing-ke...
V8 seems to use two - https://v8project.blogspot.co.uk/2017/05/launching-ignition-and-turbofan.html https://v8project.blogspot.co.uk/2017/05/launching-ignition-...
Firefox's SpiderMonkey JS engine uses two - https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Sp...
- pjmlp 9y ago.NET focus always was native code, either AOT with NGEN or JIT on load. The only variants of .NET with interpreter support were from 3rd party implementations, and the .NET Micro Framework, used in NETduino. And now their focus seems to be to improve their AOT story. Another interesting evolution was Android, with Dalvik and its basic JIT, ART with AOT on installation, to ART reboot with an interpreter in Assembly, followed by JIT and AOT code cache with PGO.
- bad_user 9y agoOn .NET Core's focus, that's not actually true: http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-method-and-Tiered-Compilation/ http://mattwarren.org/2017/12/15/How-does-.NET-JIT-a-method-... Android optimizes for battery life, but it's also worth noting that Dalvik was a really rudimentary JIT, having no benefits from JIT compilation, only drawbacks, the ART with AOT being a good upgrade. But tiered compilation is in a different league, being about speculating what's going to happen depending on what the process has witnessed thus far. The point of tiered compilation is to profile/guard stuff at runtime and recompile pieces of code based on changing conditions, which is how you can optimize virtual call sites or other dynamic pieces, which you can't do ahead of time because the missing part is the decompiler which can revert optimizations based on invalidated conditions. It's really interesting actually, because you can profile a C++ app and use that to optimize your AOT compilation, but the compiler is still limited by the things it can prove ahead of time, or otherwise it would be memory unsafe.
- pjmlp 9y agoI wrote "And now their focus seems to be to improve their AOT story.", I didn't say anything about .NET Core. Should have been more explicit, as I was referring to CoreRT and .NET Native. > But tiered compilation is in a different league, being about speculating what's going to happen depending on what the process has witnessed thus far. Just as ART was refactored on Android 7 and 8. ART with pure AOT is only for Android 5 and 6. https://source.android.com/devices/tech/dalvik/jit-compiler https://source.android.com/devices/tech/dalvik/jit-compiler
- AlphaSite 9y agoI think tiered and speculative optimisation are independent concepts. Tiered is specifically that you have a fast compiler and a slow compiler (or further tiers). Speculative is as you describe.
- rcthompson 9y agoIs it actually a JIT? It's just compiling everything unconditionally. I guess the fact that the second tier replaces previously compiled functions with more optimized versions makes it a JIT? Or does the definition of JIT require recompiling in response to information about which code would benefit most?
- chrisseaton 9y agoDo you think for something to be a JIT it must only compile code immediately before it's used? In that case the only real JIT I know of is basic-block-versioning. I think almost all JITs will compile branches or methods to some extent before they are actually needed. Yours is probably not a reasonable definition therefore. I think a JIT is just a compiler that can compile as the program is running.
- rcthompson 9y ago> Do you think for something to be a JIT it must only compile code immediately before it's used? I mean, that's more or less what the name "just-in-time compiler" implies. I'm aware that the name is not necessarily a precise definition, but I'm not sure how far the definition stretches. Does JIT have a precise agreed-upon definition, or is it somewhat more vaguely defined?
- chrisseaton 9y agoNo these terms never have precise meanings, and trying to debate them too much doesn't achieve much. But if your definition doesn't actually work for any examples of the thing you're defining at all except one then it's probably wrong.
- rcthompson 9y agoOk, fair enough. I was worried that there was some precise definition I had missed, but if that's not the case, I agree there's no point in debating it.
- hsivonen 9y agoUnsurprising, considering that browsers load code on demand and despite the original vision for Java, the JVM and CRL tend to be used for apps for which it's acceptable to have slow startup time.
- hyperpape 9y agoI'm not aware of any effort to retire tiered compilation. It was even promoted to be the default in Java 8 (2014). http://www.oracle.com/technetwork/articles/java/architect-evans-pt1-2266278.html http://www.oracle.com/technetwork/articles/java/architect-ev... The only downside I'm aware of is that it increases the pressure on the code cache. If your code cache is not large enough, it will thrash as methods are discarded then recompiled. We had significant performance problems with a server and it took quite awhile until we realized that was the cause. A cache of 256 mb was more than enough for us running a 2 million LOC monolith under Tomcat, so the absolute memory use isn't that significant. (Reference we found while researching: http://engineering.indeedblog.com/blog/2016/09/job-search-web-app-java-8-migration/ http://engineering.indeedblog.com/blog/2016/09/job-search-we...). Once you know this is an issue, it's easy to monitor, but it is one more thing that can go wrong in the JVM.
- MaxBarraclough 9y agoOops, I wasn't clear. I'd meant that, if I recall correctly, the HotSpot team initially experimented with combining the 'client' and 'server' JITs for tiered compilation, but decided it was a lot of complexity for little gain, and didn't commit. Only a couple years later did they re-attempt it and stick with it. I could be mistaken here, and I wasn't able to find anything online to support me.
- bzbarsky 9y agoSpiderMonkey has an interpreter too, in addition to the two JIT tiers.
- hthh 9y agoWhat is "Nitro"?
- ygra 9y agoSafari's JS engine, as far as I know.