-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support for GraalVM Native Images #1316
Comments
Lettuce requires a bit of reflection and proxy configuration to properly build for Graal native images. Happy to add Graal hints and update the documentation. I’m not super familiar with Graal so any kind of support is appreciated. |
I've done a quick test removing the |
@ilopmar we received today a PR with native image configuration. Do you mind having a look at #1318? I went through the config on your side and added the missing elements in the comments so we can merge both sources for the Graal native image config. Going ahead, I'd refrain from adding netty-specifics as they rather belong into netty itself unless we're applying reflection to netty types. |
@mp911de I put some comments there. As I said before, once you have a PR ready, ping me and I will test it :-) |
The first batch of GraalVM Native config files is merged to Lettuce via #1318. Documentation is available from https://github.com/lettuce-io/lettuce-core/wiki/Using-Lettuce-with-Native-Images. 5.3.2 and 6.0.0 snapshot are available from OSS Sonatype snapshot repositories. Care to give it a test? |
I've tried the 5.3.2 snapshot with my simple test application (the one I shared when I open this issue). I've removed all the Lettuce config (now included in the library) and kept the rest of the GraalVM config (including the one for Netty). I'm only able to create the native-image if I use the flag
Where you able to generate the native-image without that flag? |
I haven’t removed that flag so far. In fact, I had to upgrade my GraalVM because that one I had installed (Version 19) didn’t work at all. I downloaded the latest release that was released in May. |
I retried without For the time being, please use |
Thanks for the explanation. I asked because I didn't see that option mention on the documentation and without it, at this moment is not possible to create the native-image. That would surprise users trying to do it. |
Okay, let me add it to the docs. |
Excellent! Thank you very much for your help. I'll include all the GraalVM configuration in Micronaut-Redis and when you release next version I'll remove it! :-) |
5.3.2 is scheduled for Mid/Late July. Thanks everyone for your kind support. Closing this ticket as solved. |
Feature Request
It would be nice to make the library compatible with GraalVM out of the box.
Is your feature request related to a problem? Please describe
Currently is not possible to convert a Java app with Lettuce to a GraalVM native image.
Describe the solution you'd like
The library should include all the necessary GraalVM configuration so users don't need to do anything on their own applications. This may also imply doing so modifications in the library to make it compatible.
Describe alternatives you've considered
I've been playing a little bit with this and I've create a simple plain Java application that uses the library to connect to Redis and execute a few commands. The application is available at: https://github.com/ilopmar/redis-lettuce-graalvm, please take a look at the README about how to run the app.
I don't have experience neither with Redis nor the library so I'm pretty sure that the code can be improved a lot. Please feel free to do it :-)
Things to consider:
I've used the GraalVM Tracing Agent (see this) to help with the generation of all the GraalVM configuration. Take a look at the files
jni-config.json
,proxy-config.json
andreflect-config.json
here.At this moment, with the only things that my sample application uses from the library, all those previous GraalVM reflection configuration is needed. I'm not 100% sure if all of that is really necessary because I don't know the internals of the library.
It is only possible to generate the native image adding the flag
--report-unsupported-elements-at-runtime
(see this). The GraalVM team discourage the use of that option so probably some changes in the library are needed to being able to remove it.I also needed to add
org.hdrhistogram:HdrHistogram
andorg.latencyutils:LatencyUtils
dependencies to be able to run the native-image. Without them the process fails when starting with the following error. I don't know why they are mandatory because I'm able to run the application with the JVM without them.A good starting point could be to add more different usages of the library (which I don't know) to the sample aplicaiton and try to generate the native image. If it works maybe you can include that generated configuration in the library jars so users don't need to.
Also the documentation should be updated because, when I added a
Command
(see this) I also needed to include it inproxy-config.json
(see this) and inreflect-config.json
(see this). I'm not really sure if the library could create that configuration automatically for the users, so at least, for a first version of the GraalVM support this should be documented.Teachability, Documentation, Adoption, Migration Strategy
With the changes to support GraalVM included in the library, users would be able to convert their applications that use it to GraalVM native-images. Also frameworks like Micronaut, Spring,... and other would also benefit from this.
The text was updated successfully, but these errors were encountered: