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.
https://jaxenter.com/graalvm-chris-thalinger-interview-16307...
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.
(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.)
this seems to be a related thread on twitter:
Startup time matters a lot especially for Java applications. The reason Java never got to the desktop (including browser) I believe was the startup time.
Startup time matters a lot also for micro-services.
A 2nd great benefit of GraalVM I think is it makes it easy to integrate programs written in different languages, say Node.js and Java for instance.
What do you mean by this? There are a lot of desktop Java applications...
* Pycharm * Datagrip * Charles * JDiskReport * TexturePacker * Android Studio and associated tools * Apache Directory Studio * Zed attack proxy
That's just stuff that I've used recently and on an ongoing basis... I feel like I see quite a bit more of it.
I think it's mainly the fact that it has always been very difficult to create executable files.
Running java requires you to install the given version of JRE instead of just downloading an application and starting it.
You could not fit it on a floppy
JITs can do great optimizations in theory. But in practice they have only so much time to do optimizations.
And startup time, binary distribution size, memory footprint matter too.
It grew out of the MaximeVM project at Sun labs.
Other well known meta-circular JVM,were Squawk for Sun SPOT and Jikes RVM.
Then on top of that, it provides a LLVM like infrastructure to build compilers and language runtimes, all in memory safe language like Java.
Additionally there is a long term roadmap to increasingly replace C++ parts of OpenJDK with GraalVM code.
That being said, the people at Spring don't recommend it for production use yet. Here's what they have to say about it:
"While GraalVM is now GA, GraalVM native image feature which allows ahead-of-time compilation of Java applications into executable images is only available as an early adopter plugin, so we don't consider it production ready yet."
https://github.com/spring-projects/spring-framework/wiki/Gra...
Wasn't this feature already supported in JDK 14 with the jpackage tool?
Jpackage bundles a small Java VM (with only the features you use) together with your compiled bytecode into a single executable. When it runs it starts up the VM and executes bytecode on that VM exactly the same as it would be if you were to run a jar on a preexisting JDK/JRE installation.
Graal compiles your full app ahead of time into a native code binary. There is no bytecode/translation happening at runtime. That is why GraalVM advertises faster startup and lower memory footprint.
So there are essentially 3 ways to run JVM (Java/Scala/Kotlin/...) code:
* compile into bytecode jar -> requires existing VM runtime
* compile into bytecode jar + bundle VM runtime -> no dependencies required, runs as the previous option
* compile into native binary -> no dependencies required, runs native, starts and runs faster
This is incorrect. Jpackage creates an installer which will unpack the VM image and any other resources.
I've tried it with a small CLI tool and it actually doesn't work that well (at least on Windows).
This is my experience as well. After installation, my installed app just didn't do anything.
Shameless plug for one real-world usage: the search feature of my personal blog is built as a GraalVM native binary, running as a serverless app on AWS Lambda [3].
Disclaimer: I work for Red Hat, who sponsor the development of Quarkus
[2] https://quarkus.io/guides/
[3] https://www.morling.dev/blog/how-i-built-a-serverless-search...
That RAM consumption sounds definitely over the top; if you still have the context, logging an issue would be very welcomed. That said, there's many libraries enabled by Quarkus (see quarkus.io/guides/), so every essential functionality should be covered by now. Still a question of course whether your specific library in a given space (like FreeMarker vs. Quarkus Qute) already is supported. In any case, thanks for checking back in regularly, things might look better next time already, as the framework evolves rapidly.
To compound the inanity - Graal is also the name of a new compiler used in the newer JVMs, in addition to the name of a completely different kind of 'JRE/SDK'.
GraalVM allows for polygot execution of a number of languages: Java, Javascript, Python, and anything compiled to LLVM bitcode.
It runs them all 'side by side' so there's no translation barrier when interacting between languages.
GraalVM also comes with a native compiler that allows you to have much faster startup time, though it comes at the cost of not getting more advanced runtime optimisations.
As far as 'performance' I don't think there is anything fundamentally different form the newer JVMs.