-
Notifications
You must be signed in to change notification settings - Fork 240
GraalVM support #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraalVM support #255
Conversation
- aws-lambda-java-core - aws-lambda-java-serialization
…da-java-libs into graalvm-support
|
Hi @msailes, what is this PR waiting for? We are facing with the same issues when trying to use spring native with graalvm.. |
|
@szab100 if possible could you contact me at msailes@amazon.co.uk Thanks, |
|
@msailes should the runtime client work with graalvm? We use scala and are trying to use your approach to get a native-image running to reduce cold start and resource requirements. Sadly I get this error Eventhough I tried to manually include those two libraries as native-image resource args We have been struggling quite a lot getting this to work, any thoughts, hints or ideas? Thanx in advance |
|
Hi @stejsj , It is not currently supported no. The best thing to do would be to copy the config files from this sample application. |
|
Thanks @msailes I actually allready did that, but native-image fails when i provide the config param -H:ReflectionConfigurationResources="+ baseDirectory.value / "src" / "main" / "resources" / "META-INF" / "native-image" / "com.amazonaws/aws-lambda-java-runtime-interface-client/resource-config.json" It says it cannot find the two mentioned files, I then tried to add them as resources with full path but still got the same error when testing the lambda in the console... "-H:IncludeResources="+baseDirectory.value / "src" / "main" / "resources" / "META-INF" / "resources" / "aws-lambda-runtime-interface-client.glibc.so","-H:IncludeResources="+baseDirectory.value / "src" / "main" / "resources" / "META-INF" / "resources" / "aws-lambda-runtime-interface-client.musl.so" So somehow I may have missed up when converting the java / maven example to scala + sbt :-( Been struggling quite a bit so would really love to get it working, Now I try with our own implementation of custom runtime, but that lacks many of the features and support for lambda that this project should provide Thanks once again |
|
I don't know much about sbt, the maven plugin just knows to look in a set location. I'm guessing that's different for your situation. I would recommend asking in the GraalVM slack, they have a channel just for native-image. |
|
@msailes thank you will try that |
| [ | ||
| { | ||
| "name":"com.amazonaws.services.lambda.runtime.LambdaRuntime", | ||
| "methods":[{"name":"<init>","parameterTypes":[] }], | ||
| "fields":[{"name":"logger"}], | ||
| "allPublicMethods":true | ||
| }, | ||
| { | ||
| "name":"com.amazonaws.services.lambda.runtime.LambdaRuntimeInternal", | ||
| "methods":[{"name":"<init>","parameterTypes":[] }], | ||
| "allPublicMethods":true | ||
| } | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file needed if we have the dynamic Feature?
| { | ||
| "resources":{ | ||
| "includes":[ | ||
| {"pattern":"\\Qaws-lambda-runtime-interface-client.glibc.so\\E"}, | ||
| {"pattern":"\\Qaws-lambda-runtime-interface-client.musl.so\\E"} | ||
| ]}, | ||
| "bundles":[] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be dynamically generated?
| [ | ||
| { | ||
| "name":"java.lang.Void", | ||
| "methods":[{"name":"<init>","parameterTypes":[] }] | ||
| }, | ||
| { | ||
| "name":"java.util.Collections$UnmodifiableMap", | ||
| "fields":[{"name":"m"}] | ||
| }, | ||
| { | ||
| "name":"jdk.internal.module.IllegalAccessLogger", | ||
| "fields":[{"name":"logger"}] | ||
| }, | ||
| { | ||
| "name":"sun.misc.Unsafe", | ||
| "fields":[{"name":"theUnsafe"}] | ||
| } | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to define reflect-config for JDK internal methods and classes?
| && rm -rf /var/cache/yum | ||
|
|
||
|
|
||
| ENV GRAAL_VERSION 21.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we share this value with the one we define in pom.xml?
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.amazonaws</groupId> | ||
| <artifactId>aws-lambda-java-runtime-interface-client</artifactId> | ||
| <version>1.1.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.amazonaws</groupId> | ||
| <artifactId>aws-lambda-java-events</artifactId> | ||
| <version>3.9.0</version> | ||
| </dependency> | ||
| </dependencies> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outdated dependencies
| { | ||
| try{ | ||
| //test to make sure all events are available | ||
| Class.forName("com.amazonaws.services.lambda.runtime.events.CloudFrontEvent"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness, this handler should ensure that all methods/classes that are accessible outside of the native-image are also accessible within the native-image. Maybe we could achieve this by running a JAR handler before this one to generate a list of all reachable entities and pass this in as an event payload to this function handler, that will in turn try to load them all
| "allDeclaredConstructors": true, | ||
| "allPublicConstructors": true, | ||
| "allDeclaredMethods": true, | ||
| "allPublicMethods": true, | ||
| "allDeclaredClasses": true, | ||
| "allPublicClasses": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need allDeclared as opposed to just allPublic?
| public class LambdaEventsGraalVMFeature implements Feature { | ||
|
|
||
| public static final String EVENTS_PACKAGE_NAME = "com.amazonaws.services.lambda.runtime.events"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this generic enough for it to be reused across all our libraries in this project, and move it out of the runtime addressable scope. It should be a build-only class that is not exposed in the library.
This is essentially boilerplate code that will traverse our libraries and determine what the appropriate native-image config is, so we don't really need a copy of it per project.
| [ | ||
| { | ||
| "name":"com.amazonaws.services.lambda.runtime.api.client.runtimeapi.LambdaRuntimeClientException", | ||
| "methods":[{"name":"<init>","parameterTypes":["java.lang.String","int"] }] | ||
| }, | ||
| { | ||
| "name":"com.amazonaws.services.lambda.runtime.api.client.runtimeapi.InvocationRequest", | ||
| "fields":[{"name":"id"}, {"name":"invokedFunctionArn"}, {"name":"deadlineTimeInMs"}, {"name":"xrayTraceId"}, {"name":"clientContext"}, {"name":"cognitoIdentity"}, {"name":"content"}], | ||
| "allPublicMethods":true | ||
| } | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be auto-generated like reflect-config.json?
| build: | ||
| commands: | ||
| - set -x | ||
| - echo "Running Image ${IMAGE_TAG}" | ||
| - docker network create "${OS_DISTRIBUTION}-network" | ||
| - > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some parts of this script have been refactored, we should update this
Issue #, if available:
Description of changes:
GraalVM config and regression test.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.