Lambda failed with Java compiled into machine code

0

hi, We have a few lambda(s) deployed with native Java (compiled Java code down to machine code with Graalvm). It has been working with no issue in the last 4 months.

Since yesterday, intermittently, the lambda fails to execute with the following error 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].

I think there is a compatibility issue here and would like some advise of how to resolve it.

thanks in advance, KC

asked a year ago959 views
2 Answers
0

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.

answered 8 months ago
-1

If this is happening with Graalvm Java 17, try Graalvm Java 21. Also, try switching the Java versions in the Lambda to match this.

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions