What are exactly the minimum and recommended system requirements for Graalvm Native Image? #9270
-
Howdy! I'm planing to leverage GraalVM Native Image on a project I will start develop shortly to generate memory-optimized apps for commercial purposes. However, I'm wondering what are the requirements to generate native images. I mean, minimum RAM amount, number of CPU cores, storage size, etc For what I know JVM is usually resources hungry and the process to generate native image doesn't seem so subtle or smooth. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @UltraBurstXD. There's no official guidance as it will depend a lot on how big is your project and whether you want to optimize for fast builds or using the smallest instance possible. In terms of memory I would argue that for small and mid sized projects you can go even with 2 GB RAM. For cores, even one would do but obviously more is better. As an example, I just compiled a basic Spring web app, on a good machine and with all optimizations on: ========================================================================================================================
GraalVM Native Image: Generating 'demo' (executable)...
========================================================================================================================
[1/8] Initializing... (4.1s @ 0.19GB)
Java version: 23+18, vendor version: Oracle GraalVM 23-dev+18.1
Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
C compiler: gcc (redhat, x86_64, 8.5.0)
Garbage collector: Serial GC (max heap size: 80% of RAM)
2 user-specific feature(s):
- com.oracle.svm.thirdparty.gson.GsonFeature
- org.springframework.aot.nativex.feature.PreComputeFieldFeature
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Build resources:
- 24.59GB of memory (79.2% of 31.05GB system memory, determined at start)
- 32 thread(s) (100.0% of 32 available processor(s), determined at start)
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
[2/8] Performing analysis... [*****] (14.5s @ 1.48GB)
16,960 reachable types (89.4% of 18,971 total)
26,038 reachable fields (59.2% of 44,016 total)
89,842 reachable methods (64.9% of 138,464 total)
5,901 types, 236 fields, and 6,133 methods registered for reflection
62 types, 63 fields, and 55 methods registered for JNI access
4 native libraries: dl, pthread, rt, z
[3/8] Building universe... (3.3s @ 1.62GB)
[4/8] Parsing methods... [**] (4.1s @ 1.74GB)
[5/8] Inlining methods... [****] (0.8s @ 1.92GB)
[6/8] Compiling methods... [*****] (30.7s @ 3.19GB)
[7/8] Laying out methods... [***] (7.1s @ 3.27GB)
[8/8] Creating image... [**] (4.8s @ 1.88GB)
47.67MB (59.35%) for code area: 52,431 compilation units
31.89MB (39.70%) for image heap: 406,510 objects and 402 resources
778.48kB ( 0.95%) for other data
80.33MB in total
------------------------------------------------------------------------------------------------------------------------
6.3s (8.7% of total time) in 936 GCs | Peak RSS: 4.98GB | CPU load: 20.61
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
/home/opc/demo-central/nljug-native-spring-boot/target/demo (executable)
========================================================================================================================
Finished generating 'demo' in 1m 11s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS Even having 32 GB available on the machine, most of the time RSS stayed under 2 GB. |
Beta Was this translation helpful? Give feedback.
-
The most "constraint" environment I have experience with is GitHub runners with ~6G RAM and 2 cores. Most tests and apps I have seen are able to build fine there, but there have definitely been complex projects where the builder ran out of memory. Out of personal experience I would say most modern PCs with at least 8GB RAM and 4 cores are good enough, but if you are going to do regular builds and have somewhat more complex projects I would recommend going for at least 16GB of RAM and 8 cores. Storage should not be an issue IMHO, small projects usually require 50-100MB of disk space while the more complicated ones might go up to 1GB. For the GraalVM installation itself you will need 500-600MB. All that said, please keep in mind that you will spent most of your time developing and testing in JVM mode and only build the native image once your code is ready for production (in JVM mode). This will significantly limit the time spent in native compilation which is more time consuming and resource demanding than working with the JVM. Hope that helps. |
Beta Was this translation helpful? Give feedback.
Hi @UltraBurstXD. There's no official guidance as it will depend a lot on how big is your project and whether you want to optimize for fast builds or using the smallest instance possible. In terms of memory I would argue that for small and mid sized projects you can go even with 2 GB RAM. For cores, even one would do but obviously more is better.
As an example, I just compiled a basic Spring web app, on a good machine and with all optimizations on:
======================================================================================================================== GraalVM Native Image: Generating 'demo' (executable)... ===================================================================…