5 ms·
Java’s linker is based on an open world assumption, where you can add arbitrary stuff to the classpath and dynamically link it at runtime. This defeats most co
by hedora 6y ago
Java’s linker is based on an open world assumption, where you can add arbitrary stuff to the classpath and dynamically link it at runtime. This defeats most compiler optimizations, so you’re left with the JIT.
GraalVM makes a closed world assumption, so it can do things like dead code elimination (for library functions that don’t get called), and apply static analysis to inline virtual method calls, perform constant propagation, and so on.
This lets it greatly outperform the JVM, at the expense of some rarely used functionality.
Basically, it’s like switching from the JIT to a C compiler’s -O3.
- bdibs 6y agoAnd is that with their javac or is it reserved only for their native image generation?
- smabie 6y agoIn my experience, native image is noticeably slower than regular openjdk, at least for Scala. The start up speed is nice, though.
- asymptotically2 6y agoYou need to pay Oracle $lots for a GraalVM enterprise licence to get profile guided optimisations, if you want some of your peak performance back.
- pjmlp 6y agoTwitter thinks otherwise, as they are the major consumer of GraalVM in production.
- didibus 6y agoGraalVM is a JIT compiler for the most part. That's the one Twitter uses I believe. SubstrateVM is what lets you perform a closed world assumption ahead of time build. And that does indeed run left performant most of the time, but it uses less memory and starts faster.
- pjmlp 6y agoUnless one feeds it with PGO data, just like it happens in most AOT workflows for optimizations like devirtualization.
- secondcoming 6y agoWhat part of production, do you know? Because mobile.twitter.com links are slow as hell to load
- pjmlp 6y agoTwitter has a couple of talks about it. https://jaxenter.com/graalvm-chris-thalinger-interview-163074.html https://jaxenter.com/graalvm-chris-thalinger-interview-16307...
- marta_morena_25 6y ago> This lets it greatly outperform the JVM, at the expense of some rarely used functionality. Outperform in what metric? Startup time? Granted. Anything else? Not so much. >Basically, it’s like switching from the JIT to a C compiler’s -O3. Yeah and that would be pretty bad (it's not a good analogy to begin with). "-O3" doesn't have anything that a JIT couldn't have. The only advantage is again, startup time. JIT compilation has otherwise only advantages over static compilcation, especially in highly polymorphic code, such as java. Static compilation for polymorphic code is a joke in terms of performance... And every C++ programmer should know that. I didn't look at the spec, but I would assume that AOT is only the bootup and then the JIT will take over anyway. This means, they'd do some basic precompilation for fat bootup and then use JIT again to optimize the code further based on runtime analysis. Everything else would be a ridicolous step backwards in time and make AOT completely useless, except for some niche scenarios.
- TimTheTinker 6y agoAs far as I know, Truffle is able to do some absolutely incredible compile-time optimizations —- reaching deeply into what we would normally regard as strictly semantic territory. (For an example, see some of the optimizations done by TruffleRuby for things like `myArray.sort.first` - which it apparently optimizes by terminating the sort as soon as the first element is sorted to the front of the array... and all that without any special hints in the standard library. Please correct me if I’m wrong... it’s been a few years since I’ve read in depth about TruffleRuby. And granted this example isn’t Java, but I imagine there are great parallels there.)
- deleted 6y ago[deleted]
- tosh 6y agoI'm not sure how it would terminate sort early, my initial assumption was that for small arrays there might be special-casing? this seems to be a related thread on twitter: https://twitter.com/ChrisGSeaton/status/1001582169578524672 https://twitter.com/ChrisGSeaton/status/1001582169578524672