Fork me on GitHub
#graalvm
<
2021-04-15
>
ballpark13:04:25

I would like to run Clojure in an AWS Lambda with minimal startup time. It seems that would be a good use for GraalVM's native-image. Any disagreements there? Any experience reports? Any good docs or instructions you've found on doing that? Thanks!

Ben Sless12:04:01

How would you define minimal startup time? Have you tested how much you can cut from startup time by using direct linking, AOT, removing metadata, etc?

ballpark16:04:16

@UK0810AQ2 I have not tested those things. I only have the impression that Graal makes things fast. However, building with Graal does not seem to be trivial, so I may revert to Java

Ben Sless17:04:58

Building with a Native Image does significantly reduce start up time, however, the generated binary, by the Community Edition at least, performs worse than a JVM run would after the JIT has warmed up, so you need to consider the run time of the application itself. If it's under a few seconds a native image would probably be better. From minutes upwards a JVM would be better. Building a native image used to be harder but the Clojure community has figured out the big parts, so unless you're doing something weird or radical, it should be simple. Maybe just a bit resource intensive.

lukasz13:04:00

That's a recurring topic in #babashka channel, as it fits the bill perfectly in most cases

👍 2
Tomas Brejla14:04:35

But even using clojure itself and compiling it via graalvm might be a good way. Depending on the tasks you need to do (and libraries you want to use), using clj+ graalvm might give you lower footprint and probably better performance if it's important for you. But at a cost of rather slow build times, as native-image compilation is waaay slow. What's nice about babashka is that it already comes in natively-compiled form.

👍 1
ballpark14:04:49

Ahh, cool, I will see if babashka will meet my needs, thanks!

Tomas Brejla14:04:42

check this thread from yesterday, started by lukasz 🙂 https://clojurians.slack.com/archives/CLX41ASCS/p1618416923161500

Karol Wójcik14:04:03

It supports both java runtime and native one. This month I'm adding support for interceptor chain & GraalVM EE. Docs are lacking tbh, but @U017Y2J9F0W is working on it. 🙂

Karol Wójcik14:04:25

You can find examples in /examples folder. If you need some help with starting out then let me know :)