- Newest
- Most votes
- Most comments
We've got similar issue running GraalVM native image for JDK21, and AL2/AL2023 Lambda runtime(tried both and the issue persists). Intermittent Lambda failures with following message:
The current machine does not support all of the following CPU features that are required by the image: [CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA].
Phase: init Status: error Error Type: Runtime.ExitError
Please rebuild the executable with an appropriate setting of the -march option.
What we tried in the end is follow the recommendation from the error message and add -march=compatibility
argument for native image build in the pom.xml file:
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<buildArgs combine.children="append">
......
<arg>-march=compatibility</arg>
......
</buildArgs>
<skipTests>true</skipTests>
</configuration>
</plugin>
More details on the march option can be found on the GraalVM website: https://www.graalvm.org/latest/reference-manual/native-image/overview/Options/
It seemed to solve the issue (it's intermittent so we'll need to monitor the Lambda for a few days). Post the fix here hoping to get some validation, since we had this issue before and wasn't able to find a fix(thought it's the lambda runtime but not) - this is the second time we patch a fix for this issue.
UPDATE:
More investigation was undertaken, I've found the CPU features supported in Lambda AL2023 runtime: https://docs.aws.amazon.com/linux/al2023/ug/system-requirements.html#system-requirements-cpu Also for x86-64 arch, we can check all the CPU features in the wiki below: https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
According to AWS:
All AL2023 x86-64 binaries are built for the x86-64v2 revision of the x86-64 architecture by passing -march=x86-64-v2 to the compiler.
The x86-64v2 revision of the architecture adds the following CPU features on top of the baseline x86-64 architecture:
- CMPXCHG16B
- LAHF-SAHF
- POPCNT
- SSE3
- SSE4_1
- SSE4_2
- SSSE3
However, from the Lambda error message, the CPU features used were (and we may or may not actually need all of them):
[CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA]
From the list above, AVX, AVX2, BMI1, BMI2, FMA are under the x86-64-v3
level.
If we don't need those additional CPU features in the native image (it's a trade-off between the performance and the compatibility), we can align the target machine by giving -march=x86-64-v2
during the native image build phase.
But for best compatibility, we used -march=compatibility
, though the difference between these 2 options are to be benchmarked.
If this is happening with Graalvm Java 17, try Graalvm Java 21. Also, try switching the Java versions in the Lambda to match this.
Relevant content
- asked 3 years ago
- asked 7 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 2 years ago
I am not sure that helps. After a bit of digging, this error could mean the deployed image is built with newer version of CPU architecture (with new CPU instructions); and I believe the issue is the lambda is deployed with old CPU architecture which does not have these instruction support.
Ref: https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.2#native-compilation---work-around-missing-cpu-features
I recon' the fix is to apply "-march=compatibility" option, instruct Graalvm to compile image with backwards-compatibility