Native Minecraft servers with GraalVM Native Image
github.com
github.com
So we don't even know if it actually makes things faster? Startup are a none issue, CPU / memory is but you need proof for that.
Graal does not support ZGC or Shenandoah so it's hard to say if the G1 version from Graal is up to speed.
Yes it is. Developing any short term job -- that runs multiple seconds and goes away -- like lambda or k8s jobs with Java is meaningless for exactly this reason. The startup time is longer than the run time.
First time I hear about MultiPaper, another idea I had which I din't know someone was already working on LOL. It's a pretty promising idea considering the current performance problems of the game. This could possibly allow thousands of players in the same server which would be AMAZING, almost a completely different game. Imagine if MultiPaper was compiled to native using GraalVM.
The students "measured noticeable reductions in terms of memory footprint of up to 43%" [1] in some preliminary experiments. More from the accompanying blog post:
"We also hope that the Minecraft community builds on our work and helps benchmark different configurations for native Minecraft servers in more detail and in larger settings."
Please feel free to share any numbers on CPU/memory usage with us!
[1] https://medium.com/graalvm/native-minecraft-servers-with-gra...
If I understand the article correctly, you're preempting all possibly unoptimized/expensive code paths (reflection) by attempting to literally execute all of them? While it's a cool experiment, isn't it a bit error-prone (besides being a lot of effort of course, but playing Minecraft on the side does sound pretty fun!)?
The thing was built to address the burgeoning embedded w/ a little horsepower market with its variety of hardware and OSes.
Now it runs Enterprise server software… and Minecraft.
There are certainly pathological cases where it could cause major issues.
AOT suffers from not having runtime information, so anything involving dynamic dispatch (which is REALLY heavily used in java) will be a lot harder to optimize. JITs get to cheat because they know that the `void foo(Collection bar)` method is always or usually called with an `ArrayList`. PGO is the AOT world's answer to this problem, but it generally explodes build times and requires real world usage.
In java land, there's also the option of "AppCDS" which can cut down a large portion of that compilation time between processes.
https://www.graalvm.org/22.2/examples/java-performance-examp...
(Side note: this was when I was co-maintaining MCPC so was typically with mods installed and they heavily use NBT which I suspect is where a lot of that string allocation was happening.)
lets you spawn new game instances on the fly, reduce time spent loading the chunks and game data
you save a lot of money when you scale, and you improve latency, people don't complain with huge loading time and stutters for fresh servers
ask anybody working on the industry
fun fact, that's the first thing Riot did when they acquired Hytale
They rewrote their C# client to C++ for portability
And they rewrote their Java server to C++ for performance (and cost saving)
Tech Change: https://hytale.com/news/2022/7/summer-2022-development-updat...
https://github.com/cuberite/cuberite
"Cuberite is a Minecraft-compatible multiplayer game server that is written in C++ and designed to be efficient with memory and CPU"
Cuberite has been demoed running on old ARM Android phones and hosting multiple players off it at once. Its performance absolutely annihilates the Java based 'vanilla' server
AFAIK, the Java client uses LWJGL, which is a native library.
Native compilation usually makes things a little slower, not faster. Using the closed-source Enterprise version, and using PGO gets it back to around the same speed as the VM version I believe currently.
That's no longer the case. If you have one, you can "purchase" the other for free. See https://www.minecraft.net/en-us/article/java---bedrock-editi... and https://help.minecraft.net/hc/en-us/articles/6657208607501 for details.
Also, there are mods for the Java server which allow both Java and Bedrock clients to connect to the same server and play together. I don't know the details, but I have played in a server which used these mods.
This is correct. I am running a vanilla SMP for my son, and he plays primarily on the switch. I use a Java server running Fabric and Geyser/Floodgate in order to allow his switch to connect to the server. Everything runs smoothly, so far.
How exactly does that work? Afaik there are quite a few behavioral differences between the two, especially for technical things like redstone and pistons.
I've got a number is spring web applications from which I create an uberjar (jar file with all dependencies) and run them in a Centos server using something like java -jar server.jar (it's a little more complex than this but you get the idea).
Would I be able to use graalvm to create native binaries from these jars? Is there some kind of tutorial describing the procedure?
Is this possible without a license/paying big money?
Finally, is this worth it? Will the apps become any faster?
Frameworks like Quarkus and Micronaut have been written with native in mind and I think Spring is also working on it (Spring Native).
There is spring native that will solve it for the most part, but I’m not sure how hard it is to change an existing spring web app to that.
GraalVM has a community edition, which is free, I’m not sure about the license.
And it is likely not worth it, performance will likely be worth, but memory usage and startup speed will decrease. It can be worth it for command line apps or some tiny microservice that is mostly idle.
I'll also take a peek on spring native it seems to be available in beta: https://github.com/spring-projects-experimental/spring-nativ...
There is a Graal Community Edition, which is free. Search for graal and spring pet clinic demo, you will likely find an article reducing startup time 100x (starting pet clinic in 15ms), and reducing memory 2-3x.
I don't know about 'faster', but in my experience most spring applications are RAM bound, not CPU bound. So the native binaries can result in scaling back to smaller and cheaper cloud instances, or smaller VMs. Imagine halving your monthly cloud instance bill, if you are looking for 'worth it'.
If you want to play with a framework where the native part works pretty okay, and still be able to use your dependent injection and dependencies, have a look at Quarkus. They even have some spring 'polyfills'.
GraalVM is regular OpenJDK with the compiler switched out, AFAIK.
Do you have a source for this? Or how do you know?
> Updated the OpenJDK release on which GraalVM Community Edition is built ...
and
> Updated the Oracle JDK release on which GraalVM Enterprise Edition is built ...
There are a lot of non-biased benchmarks you can find online, most of them showing that Graal (both CE/EE, though particularly EE) are more performant than OpenJDK.
You then also have the option to compile to native, or to embed/run code in other languages baked in.
It's a no-lose scenario IMO.
Also, not every GC is available, or only in the enterprise version.
The community version has only serial or nothing, which are ok for small heaps or short lived processes.
Caveat: I also haven't been using Native Images yet, though. So I can't comment on if it'll be dramatically different for that build target.
GraalVM is first and foremost a JIT compiler written in Java that can be plugged into OpenJDK. Due to it being written in a higher level language than the original Hotspot compilers (written in C++) they are easier to write/maintain/experiment with. This mode of operation is used extensively by Twitter for example, because on their workloads it provides better performance than Hotspot, but the two trades blows in general. But this uses the standard javac compiler so it is basically just a slightly different JVM implementation.
Since a JIT compiler outputs machine code it can be “easily” modified to do so in an offline setting as well — this is Graal’s AOT/native compilation mode. This will take a long time compared to some other compilers (I don’t exactly know the reason for that, probably Java’s dynamic nature requiring more wide-reaching analysis?), but will have lower memory usage and faster startup speed compared to the traditional execution mode (but rarely better performance).
There is also Truffle, which turns “naive” language interpreters into efficient JIT compiled runtimes and allowing polyglot execution, which is a whole other dimension.
Thanks a lot @kaba0, big-O would be smart put your comment as part of the GraalVM site FAQ for "What is GraalVM".
Cheers.
EDIT: One request for a small clarification
> But this uses the standard javac compiler so it is basically just a slightly different JVM implementation.
What is "this"? Are you referring to TFA?
That’s not true. For the majority of applications the JIT compiler will be much faster (either Graal’s JIT compiler or Hotspot). Startup time, and memory reduction is true though for AOT.
There are multiple benchmarks that show marginal gains using GraalVM CE for big data workloads; it might make sense if you're still stuck on Java 8 or 11. The enterprise edition shows more significant gains.
How would this be possible for a static native executable?