MusicDin / graalvm-project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraalVM Project

Goal of this project

Goal of this project is to make KumuluzEE framework compatible with GraalVM.

GraalVM installation

Installation steps are available on GraalVM official site.

Project elements

  • Simple service:
    • API which return constants
    • Servlet which returns constants
    • Only one module (no business logic and no DB connectivity)
  • Dockerfile for building a docker image
    • Folder Dockerfiles contains backups and different type of docker files

Usage

Note: maven-plugin goal has to be set to repackage for uber-jar and to copy-dependencies for exploded.

Running with scripts (EXPLODED)

To execute mvn and tracing agent run trace.sh script.

After tracing run build.sh script in order to build no-fallback image.

After generating image simply run graalvm-basic.

Note: Edit those scripts to fit your needs

Manually - UBER(FAT) JAR

mvn clean package 

Use native-image-agent to generate configuration files for native-image (application will start):

java -agentlib:native-image-agent=config-merge-dir=api/src/main/resources/META-INF/native-image -jar api/target/graalvm-basic.jar 

Then generate native-image:

sudo native-image --no-fallback \
        --allow-incomplete-classpath \ 
        --enable-https \
        -H:+JNI \
        -H:+PrintClassInitialization \
        -H:+ReportExceptionStackTraces \
        -H:EnableURLProtocols=http,https,jar,jrt \
        -H:ConfigurationFileDirectories=api/src/main/resources/META-INF/native-image/ \
        -H:ReflectionConfigurationFiles=api/src/main/resources/META-INF/native-image/reflect-config.json \
        -H:ResourceConfigurationFiles=api/src/main/resources/META-INF/native-image/resource-config.json \
        -H:JNIConfigurationFiles=api/src/main/resources/META-INF/native-image/jni-config.json \
        -jar api/target/graalvm-basic.jar

If everything is done right, you should be able to start native-image:

./graalvm-basic 

Manually - EXPLODED

mvn clean package 

Use native-image-agent to generate configuration files for native-image (application will start):

sudo java -agentlib:native-image-agent=config-output-dir=api/src/main/resources/META-INF/native-image -cp api/target/classes:api/target/dependency/* com.kumuluz.ee.EeApplication

Then generate native-image:

sudo native-image --no-fallback \
        --allow-incomplete-classpath \ 
        --enable-https \
        -H:+JNI \
        -H:+PrintClassInitialization \
        -H:+ReportExceptionStackTraces \
        -H:EnableURLProtocols=http,https \
        -H:ConfigurationFileDirectories=api/src/main/resources/META-INF/native-image/ \
        -H:ReflectionConfigurationFiles=api/src/main/resources/META-INF/native-image/reflect-config.json \
        -H:ResourceConfigurationFiles=api/src/main/resources/META-INF/native-image/resource-config.json \
        -H:JNIConfigurationFiles=api/src/main/resources/META-INF/native-image/jni-config.json \
        -cp api/target/classes:api/target/dependency/* com.kumuluz.ee.EeApplication \
        graalvm-basic

If everything has been done right, you should be able to start native-image:

./graalvm-basic 

Known (potential) errors

  1. Resource web.xml is not included in generated image. Issue opened on GraalVM Github may help, though it is not solved.

Boot time comparison

All tests were executed on virtual machine with 8 vCPU and 64GB RAM.

Each time in table represents an avarage time of 100 boots (in milliseconds). Times are saved in time_tests folder.

Project Time to boot in JVM Fallback image No-fallback image
this project 1787 ms 1832 ms /
fri-pointer 7832 ms 8347 ms /

Useful links

Forums/Issues

Technologies used in project

About


Languages

Language:Shell 68.5%Language:Dockerfile 17.9%Language:Java 13.6%