Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GraalVM native image as option to run Java. #107

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

thomaswue
Copy link
Contributor

This adds the capability to run the Java code as a GraalVM native image. For installing GraalVM, one can use SDKMan:
sdk install java 23.0.1-graal

Alternatively, the binaries are available here: https://www.graalvm.org/downloads/

Measurements on my machine (Intel 13th Gen Core i9-13900K) show that it brings the time for Java for the loop example down to the levels of C/C++ and Rust:

C = 1.52
C = 1.50
C = 1.51

Java = 1.59
Java = 1.60
Java = 1.60

Java GraalVM = 1.51
Java GraalVM = 1.50
Java GraalVM = 1.50

@helpermethod
Copy link

I wonder if it would be even better to generate the random number at build time 😄

@thomaswue
Copy link
Contributor Author

@helpermethod With proper loop transformations, the primary work of the benchmark (summing up the modulo values) could be done outside the outer loop. This would then reduce the time to almost zero. We have all the relevant optimizations available in the Graal compiler, but the current heuristics do not play well enough together to trigger the transformation.

@bddicken
Copy link
Owner

bddicken commented Dec 2, 2024

Awesome, thanks.

@bddicken bddicken merged commit 027da61 into bddicken:main Dec 2, 2024
@auula
Copy link

auula commented Dec 5, 2024

nice !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants