Fork me on GitHub
#clojure-europe
<
2020-05-29
>
plexus07:05:05

Goeiemorgen!

ordnungswidrig08:05:24

Anybody here knowing about graalvm and native image generation?

plexus08:05:51

I recently played with it for Funnel (https://github.com/lambdaisland/funnel) @ordnungswidrig. What do you want to know?

plexus08:05:12

https://github.com/plexus/clj.native-image -> fork of clj.native-image with some improved cli arg handling

ordnungswidrig08:05:01

I'm trying to native compile a project using Crux and netty give a lot of headache. Also analysis take >15min easily

ordnungswidrig08:05:42

I've enabled direct linking in the uberjar build. But I'm missing the tools and knowledge to check what's actually going on.

ordnungswidrig08:05:58

@plexus I'm going to try clj.native-image I've tried cambada and manually invoking native-image so far.

plexus08:05:48

it's really just a wrapper around invoking native-image directly, not sure it'll make a huge difference. You still need to specify a lot of the flags that get passed down

plexus08:05:24

I use these

"--initialize-at-build-time"
               "--no-fallback"
               "--enable-https"
               "--allow-incomplete-classpath"
               "-H:Name=funnel"
               "-H:Log=registerResource"
               "-H:ResourceConfigurationFiles=resource-config.json"

plexus08:05:08

but yeah I can't imagine doing this on an established project, I basically just had this running in a loop so that I could immediately see if something broke the compilation

plexus08:05:50

analysis takes a few minutes for me too, and that's on a tiny project, so not too suprised about the 15mins

plexus08:05:34

people are helpful in #graalvm (and more knowledgeable than I am)

plexus08:05:12

also anecdote I started with graal 19, worked fine, upgraded to 20 and compilation would fail. I have not yet gotten to the bottom of it, just went back to 19

ordnungswidrig08:05:09

Oh, that might explain why I remember have fewer problems before.

thomas08:05:52

@borkdude has done quite a few things with GraalVM, maybe he can help?

borkdude08:05:47

@ordnungswidrig My 2 cts: I do not recommend using wrappers, just write a shell script. Wrappers just limit what you can do, sooner or later it's going to be a blocker. I use leiningen for creating uberjars. Then I pass those to native-image with the -jar argument. Also use direct linking, warn-on-reflection etc. A lot of the problems I've had with GraalVM native-image are documented here: https://github.com/lread/clj-graal-docs

borkdude08:05:10

But yeah, #graalvm would be the place to discuss this.

borkdude08:05:13

I've upgraded babashka, which is by far the most involved GraalVM project I've had so far, to 20.1.0 java 11 recently.

ordnungswidrig08:05:06

How can I (set! warn-on-reflection true)`` for every namespace with clj? With leiningen I lein check but clj tooling is new to me.

borkdude08:05:55

I usually just put this at the top of the namespace. Just to make it tooling independent.

4
ordnungswidrig08:05:21

I’ve got many namespaces 😛

borkdude08:05:34

Use emacs macros 😉

👍 4
otfrom10:05:00

@borkdude using emacs macros is always the right decision 😄

borkdude08:05:34

You can also run the project every so often with leiningen, there you can set it using :globals {*warn-on-reflection* true}

borkdude08:05:54

I do use clj and lein both for most projects, because they both have their merits

borkdude08:05:17

For java 11 there is an issue with clojure lang Reflector, which is described in clj-graal-docs. I've also got a library which you can include which fixes this automatically

borkdude08:05:37

here's a blog on how to enable direct linking and how it can help compilation times: https://epiccastle.io/blog/faster-graalvm-clojure-compilation-times/

ordnungswidrig08:05:04

I had read that article and it was helpful.

ordnungswidrig08:05:14

Looking for the lib now

otfrom10:05:00
replied to a thread:Use emacs macros :wink:

@borkdude using emacs macros is always the right decision 😄

jasonbell10:05:20

@otfrom Just to follow up, you were right, it was REPL related with regards to me import problems. Uberjar’d it and the whole lot when it with no issues. Cheers.

jasonbell10:05:03

Though it was a good excuse to go in and clean up the data first all the same 😉