I am trying to compile a springboot App to native using graalVM, the application itself has nothing in it, just the application main file, when running gradle nativeCompile, the image is about ~50Mb in size, is this the expected size ? or am i missing some optimizations ? In the Build logs i noticed some log lines such as :
========================================================================================================================
[1/8] Initializing... (4.9s @ 0.24GB)
Java version: 17.0.7+8-LTS, vendor version: Oracle GraalVM 17.0.7+8.1
Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
C compiler: cl.exe (microsoft, x64, 19.36.32534)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s)
- org.springframework.aot.nativex.feature.PreComputeFieldFeature
Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time
Field org.springframework.cglib.core.AbstractClassGenerator#imageCode set to true at build time
Field org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.core.NativeDetector#imageCode set to true at build time
Field org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.core.KotlinDetector#kotlinPresent set to true at build time
Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to true at build time
Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build time
Field org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build time
[2/8] Performing analysis... [*****] (12.9s @ 1.21GB)
11,346 (88.27%) of 12,854 types reachable
17,177 (67.40%) of 25,485 fields reachable
58,937 (61.80%) of 95,367 methods reachable
3,583 types, 134 fields, and 1,826 methods registered for reflection
78 types, 74 fields, and 62 methods registered for JNI access
5 native libraries: crypt32, ncrypt, psapi, version, winhttp
[3/8] Building universe... (1.9s @ 1.87GB)
[4/8] Parsing methods... [**] (4.4s @ 1.35GB)
[5/8] Inlining methods... [***] (0.5s @ 2.52GB)
[6/8] Compiling methods... [*****] (28.5s @ 4.55GB)
[7/8] Layouting methods... [**] (3.2s @ 2.09GB)
[8/8] Creating image... [**] (3.2s @ 2.62GB)
32.11MB (59.34%) for code area: 31,614 compilation units
21.57MB (39.87%) for image heap: 311,575 objects and 33 resources
440.91kB ( 0.80%) for other data
54.12MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
10.81MB java.base 6.62MB byte[] for code metadata
5.09MB kotlin-reflect-1.8.21.jar 3.15MB byte[] for java.lang.String
3.44MB java.xml 2.24MB java.lang.String
3.25MB svm.jar (Native Image) 2.02MB java.lang.Class
2.05MB spring-core-6.0.9.jar 1.88MB byte[] for general heap data
1.45MB spring-boot-3.1.0.jar 673.03kB byte[] for reflection metadata
857.06kB spring-beans-6.0.9.jar 531.84kB com.oracle.svm.core.hub.DynamicHubCompanion
754.30kB logback-core-1.4.7.jar 487.22kB java.util.HashMap$Node
623.80kB spring-expression-6.0.9.jar 397.81kB java.util.concurrent.ConcurrentHashMap$Node
391.42kB kotlin-stdlib-1.8.21.jar 320.75kB c.o.svm.core.hub.DynamicHub$ReflectionMetadata
3.23MB for 46 more packages 2.94MB for 2231 more object types
Are there any knows optimizations that i can add ? or this is the normal behaviour ?