10 ms·
Native Minecraft servers with GraalVM Native Image
- fsiefken 4y agoCan the same trick be used with the java client? My son runs minetest on the raspberry pi 400 as minecraft is to slow. I'll do everything for a bit more fps.
- sdwvit 4y agoHit Shift + F3 to see a frame time breakdown, then you can determine if it is slow graphics or cpu. If it is CPU, maybe graal helps, but it's hard to tell upfront. Also check out some mods dedicated to improving performance like Sodium.
- LtdJorge 4y agoIt's always CPU with Minecraft. 1 thread can't do much more.
- fniephaus 4y agoI don't think the student looked into that at all, but I guess it depends on what the Java client uses for drawing. GraalVM Native Image currently doesn't support AWT on Linux/JDK17+, but we are working on fixing that soon.
- cesarb 4y ago> it depends on what the Java client uses for drawing AFAIK, the Java client uses LWJGL, which is a native library.
- fniephaus 4y agoThanks for the info! Seems like it's worth trying to compile the Java client with GraalVM Native Image then, given that this exists: https://github.com/chirontt/lwjgl3-helloworld-native https://github.com/chirontt/lwjgl3-helloworld-native
- fniephaus 4y agoApparently, someone has managed to compile the Minecraft client to native: https://medium.com/@kb1000/what-youve-done-with-the-server-i-ve-done-with-the-client-a51bbdde42fc https://medium.com/@kb1000/what-youve-done-with-the-server-i...
- chrisseaton 4y ago> I'll do everything for a bit more fps. 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.
- the_gipsy 4y agoMinecraft Bedrock edition runs better. It has feature parity but is not compatible with java server, and requires a new purchase IIRC.
- cesarb 4y ago> Minecraft Bedrock edition runs better. It has feature parity but is not compatible with java server, and requires a new purchase IIRC. 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-edition-pc-out-june-7 https://www.minecraft.net/en-us/article/java---bedrock-editi... and https://help.minecraft.net/hc/en-us/articles/6657208607501 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.
- dvaun 4y ago> Also, there are mods for the Java server which allows both Java and Bedrock clients to connect to the same server and play together. 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.
- Asraelite 4y ago> Also, there are mods for the Java server which allow both Java and Bedrock clients to connect to the same server and play together. How exactly does that work? Afaik there are quite a few behavioral differences between the two, especially for technical things like redstone and pistons.
- cesarb 4y agoMost of these behavioral differences are in the server. So what happens, is that it behaves as if you were playing the Java edition, even when using a Bedrock client.
- wingmanjd 4y agoCheck out the sodium mod [1], if you haven't already. I've had great success eeking out a few more precious frames with it on older hardware. IIRC, it works on both x86 and ARM processors. [1] https://github.com/CaffeineMC/sodium-fabric https://github.com/CaffeineMC/sodium-fabric
- cesarb 4y agoThere are mods which heavily optimize the java client performance, these would have a greater effect than just ahead-of-time compilation. For instance, the modpack at https://github.com/Fabulously-Optimized/fabulously-optimized https://github.com/Fabulously-Optimized/fabulously-optimized packages several of these performance mods together (see https://github.com/Fabulously-Optimized/fabulously-optimized/blob/main/INCLUDED-MODS.md https://github.com/Fabulously-Optimized/fabulously-optimized... for the list).
- Thaxll 4y ago"As such, it is supposed to require fewer CPU and memory resources, provide better startup times, and be easier and cheaper to deploy." 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.
- vips7L 4y agoAre they using Graal enterprise? Last I checked Community Edition of native image uses the serial collector not G1.
- fniephaus 4y agoThe students used both, the community and enterprise editions of GraalVM. Indeed, G1 is an enterprise feature: https://www.graalvm.org/22.2/reference-manual/native-image/optimizations-and-performance/MemoryManagement/ https://www.graalvm.org/22.2/reference-manual/native-image/o...
- majidazimi 4y ago>Startup are a none issue 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.
- HideousKojima 4y agoA Minecraft server is not a short term job.
- vgalin 4y agoI guess it can be in a specific case: minigames servers (such as Hypixel), which are just a bunch of servers "connected" together. Players start into a "lobby" server, where they can choose a minigame, and are then sent to another server where they spend a few minutes.
- notme1234 4y agoIs Graal VM a silver bullet? Ignoring startup times, will Graal VM out perform classic JVM (IBM/Oracle etc'). I guess the optimization of the classic JVM are hard to beat. Also, cross compile is not working with Graal VM (which makes it harder to deploy than a good old Jar file).
- the-smug-one 4y agoOn some micros Graal beats C2, on some others it doesn't. It's not a silver bullet. GraalVM is regular OpenJDK with the compiler switched out, AFAIK.
- metadat 4y ago> GraalVM is regular OpenJDK with the compiler switched out, AFAIK. Do you have a source for this? Or how do you know?
- fniephaus 4y agoJust look at the 22.2 release notes [1]: > Updated the OpenJDK release on which GraalVM Community Edition is built ... and > Updated the Oracle JDK release on which GraalVM Enterprise Edition is built ... [1] https://www.graalvm.org/release-notes/22_2/ https://www.graalvm.org/release-notes/22_2/
- metadat 4y agoGot it, thank you @fniephaus. Really appreciate the info, and please keep up the fantastic work!
- gavinray 4y agoI use GraalVM as my standard non-native JDK (OpenJDK replacement) and I'd say the performance is somewhat better. 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.
- KingOfCoders 4y agoNo need to go for the client, it's working fine on my machine, nearly 60fps with a 12-core, 32gb + RTX2080TI with Iris, Sodium, Phosphor and Lithium </i>.
- LtdJorge 4y agoNearly 60, lol. Also, fps are not the real problem for the client. I had a modpack with 16GB assigned crashing due to OOM errors. Forge is awesome, but modding the hell out of MC requires extreme specs.
- imtringued 4y agoI upgraded my computer to 32 GB RAM just to play Minecraft.
- Linda703 4y ago[dead]
- terafo 4y agoI don't think this repo provides any value. It compiles only Vanilla server, doesn't provide any benchmarks while spending whole paragraph on GraalVM Enterprise and Oracle Cloud(a single worst cloud experience I've ever had, it took me two dozen attempts to register until I finally gave up) Free Tier promotion
- das_keyboard 4y ago> The native executable sometimes fails on startup. Restarting it a few times usually helps. How would this be possible for a static native executable?
- fniephaus 4y agoIt fails for some reason when reading user data from disk. The error also goes away if you nuke the user data but that's less convenient.
- rr888 4y agoThe whole advantage of GraalVM is startup time, which is important for containers, Lambda jobs etc, because it doesn't have to compile bytecode on startup. It isn't supposed to be faster than regular JVM, which has the advantage of being able to analyze and recompile hotspots.
- spapas82 4y agoI've always had some questions about graalvm so I'd like to hijack this thread, forgive the out of topic comment please! 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?
- fesc 4y agoI think right now this Isn’t possible with “normal” Spring because Spring and various other libraries you’ll normally use make heavy use of reflection. Frameworks like Quarkus and Micronaut have been written with native in mind and I think Spring is also working on it (Spring Native).
- spapas82 4y agoThank you for the suggestions I'll take a peek at them!
- kaba0 4y agoYou would likely not be able to turn them to native binaries without a ton of work — spring uses reflection very heavily, so you would have to list every class that would get reflectively checked (including spring internals). 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.
- spapas82 4y agoThank you for the information! Doing some research myself I found some things about the license and integration with spring here: https://www.graalvm.org/faq/ https://www.graalvm.org/faq/ ; it seems that no license is needed for graalvm! I'll also take a peek on spring native it seems to be available in beta: https://github.com/spring-projects-experimental/spring-native https://github.com/spring-projects-experimental/spring-nativ...
- IntelMiner 4y agoShout out for Cuberite as an alternative Minecraft server project that desperately needs more volunteers https://github.com/cuberite/cuberite 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
- 10000truths 4y agoIn a similar vein, there is also a Rust-based Minecraft server implementation: https://github.com/feather-rs/feather https://github.com/feather-rs/feather