Have you ever compared the performance of a Java-based application running through the ๐๐ฎ๐๐ฎ ๐ฅ๐๐ป๐๐ถ๐บ๐ฒ ๐๐ป๐๐ถ๐ฟ๐ผ๐ป๐บ๐ฒ๐ป๐ with a ๐ป๐ฎ๐๐ถ๐๐ฒ ๐ฒ๐ ๐ฒ๐ฐ๐๐๐ฎ๐ฏ๐น๐ฒ compiled using GraalVM?
For many years, I strongly associated Java with being an interpreted language that requires the JRE to run applications. However, a few years ago, something big happened, and now there are projects that can compile Java code into binary executables.
I heard some rumors that native builds might be significantly faster. It was interesting, but not compelling enough for me to start experimenting with it yet. However, we’re now reaching a point where projects like GraalVM have matured, and most issues have been addressed. So, itโs been really fascinating to dive into this topic and explore modern options.
And you know what? The results of our tests are quite contradictory, and it seems we canโt yet conclude if one approach will come out on top. However, weโre ready to share some observations relevant to our use cases:
– The ๐๐๐ฎ๐ฟ๐๐๐ฝ ๐๐ถ๐บ๐ฒ of native code is faster (obviously!).
– The ๐บ๐ฒ๐บ๐ผ๐ฟ๐ ๐ณ๐ผ๐ผ๐๐ฝ๐ฟ๐ถ๐ป๐ of native code is significantly smaller.
– ๐ฃ๐ฒ๐ฟ๐ณ๐ผ๐ฟ๐บ๐ฎ๐ป๐ฐ๐ฒ of native code in our test scenarios is slightly lower.
– You need to be very careful with the ๐ฑ๐ฒ๐ฝ๐ฒ๐ป๐ฑ๐ฒ๐ป๐ฐ๐ถ๐ฒ๐ included in your binary during compilation, as the ๐๐ถ๐๐ฒ ๐ผ๐ณ ๐๐ผ๐๐ฟ ๐ฝ๐ฟ๐ผ๐ฑ๐๐ฐ๐ might become unreasonably high.
– You ๐ฐ๐ผ๐บ๐ฝ๐ถ๐น๐ฒ ๐ณ๐ผ๐ฟ ๐ฎ ๐๐ฝ๐ฒ๐ฐ๐ถ๐ณ๐ถ๐ฐ ๐ฝ๐น๐ฎ๐๐ณ๐ผ๐ฟ๐บ, so you canโt run an x86 file on ARM – losing that luxury of cross-platform coding. Of course, you can compile for other platforms, but you’ll need to manage more files in the end and avoid mixing them up.
– ๐๐ฒ๐ฏ๐๐ด๐ด๐ถ๐ป๐ด a running native process on the fly isโฆ challenging ๐ You canโt use most of the convenient tools to connect to it, so make sure to use good logging in your apps.
– Running Java as a simple binary with no dependencies feelsโฆ odd! But it also empowers you to do this ๐ถ๐ป ๐๐ถ๐๐๐ฎ๐๐ถ๐ผ๐ป๐ ๐๐ต๐ฒ๐ฟ๐ฒ ๐ถ๐ ๐ฝ๐ฟ๐ผ๐๐ถ๐ฑ๐ฒ๐ ๐ฏ๐ฒ๐ป๐ฒ๐ณ๐ถ๐๐, such as when you are ๐ฒ๐ ๐ฝ๐ฒ๐ฟ๐ถ๐ฒ๐ป๐ฐ๐ถ๐ป๐ด ๐ฎ ๐ฅ๐๐ ๐ฑ๐ฒ๐ณ๐ถ๐ฐ๐ถ๐. Additionally, you donโt need to worry about security vulnerabilities in JAVA and deal with urgent upgrades.
We plan to dive deeper into this topic. Maybe with the proper tuning of compilation parameters, native could surprise us even more!