4 ms·
This is only partly true. HotSpot is pretty amazing performance wise. For certain code patterns it really does produce assembly competitive and even better than
by zmmmmm 5y ago
This is only partly true. HotSpot is pretty amazing performance wise. For certain code patterns it really does produce assembly competitive and even better than what you get from the equivalent vanilla C++ solution.
The issues are (a) it only kicks in once something gets profiled quite a few times (so your first encounters with a function - the one you base your impressions of usually, are at its worst), (b) the overhead of JIT weighs down the machine further at exactly the moment (a) is occurring. And then (c) there are quite a lot of code patterns and in particular architectural styles encouraged by the Java ecosystem that are hostile to this whole process.
I do wonder why Java has not gone the python direction of caching the JIT output in binary form so at least the 2nd time you launch an app it doesn't need to be redone every time.
- kaba0 5y agoIt did actually work for a time that you could point the jvm to precompiled class files, but it got discontinued (it was part of GraalVM which has a different pace to OpenJDK) But imo that is only relevant for startup - otherwise the problem with Java’s JIT compilation is the identity of objects, which makes it much harder to do some optimizations. Hopefully with valhalla we will see quite a boost.
- native_samples 5y agoIt's complicated to do binary caching for various low level reasons. Amongst other things, the generated binary code is specific to the precise location in memory and makes lots of assumptions about the state of the runtime like what classes have been been initialized. Still, HotSpot has been slowly (too slowly) getting AOT-like optimizations in the form of AppCDS. It doesn't actually store compiled code but a lot of other internal data structures can be stored to disk in native form and just mmapped at startup. It's usually a 30% win or so, which isn't bad.