graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
lread 2020-03-06T15:18:35.242400Z

Updated our clj-graal-docs to reflect momentous release of Clojure 1.10.2-alpha1 🎉 https://github.com/lread/clj-graal-docs/commit/2de39cddfa1af54868ff7297ed3c04093d734ad1

❤️ 1
🎉 1
borkdude 2020-03-06T15:21:00.243500Z

Other good news: I was able to restore the startup time of babashka on version 20 from 25ms back to 13ms with a "hack" that I got from the GraalVM developers: https://github.com/oracle/graal/issues/2136#issuecomment-595814343

🎉 1
lread 2020-03-06T15:28:27.245Z

Cool! It is not Clojure specific, but maybe worth pointing to from clj-graal-docs?

borkdude 2020-03-06T15:36:43.245800Z

Sure

lread 2020-03-06T15:38:42.246700Z

I shall do

borkdude 2020-03-06T15:56:36.247Z

@lee Here's the commit on master: https://github.com/borkdude/babashka/commit/5723206ca2949a8e6443cdc38f8748159bcdce91

lread 2020-03-06T15:57:08.247200Z

sweet! tx!

lread 2020-03-06T16:08:55.247400Z

pushed

borkdude 2020-03-06T16:11:02.248100Z

Cool! Small annotional note: the issue only happens with specific usages of certain classes that are somehow related to security, urls and whatnot. So not all projects will hit this issue.

borkdude 2020-03-06T16:11:43.248500Z

Maybe it's also related to enabling the SSL stuff. Likely, but I haven't tested that hypothesis.

borkdude 2020-03-06T16:13:04.249200Z

Here is a binary compiled with a 20 dev version with the patch of conditional loading the macOS library (this is what they did fix). And the additional tweak. https://4891-201467090-gh.circle-artifacts.com/0/release/babashka-0.0.75-SNAPSHOT-macos-amd64.zip

borkdude 2020-03-06T16:14:44.249400Z

$ multitime -s0 -n100 ~/Downloads/bb-20dev -e 'nil'
===> multitime results
1: /Users/borkdude/Downloads/bb-20dev -e nil
            Mean        Std.Dev.    Min         Median      Max
real        0.015       0.002       0.013       0.015       0.022
user        0.005       0.000       0.005       0.006       0.006
sys         0.005       0.001       0.004       0.005       0.011

borkdude 2020-03-06T16:15:16.249900Z

Hmm, maybe mentioning the multitime util to measure startup time is also a nice addition. sogaiu brought it to my attention

borkdude 2020-03-06T16:30:24.250600Z

Maybe we should also have build instructions in the repo for GraalVM itself. E.g. here they are welcoming a contribution: https://github.com/oracle/graal/issues/2136#issuecomment-595847888 But I would first have to figure out how to set up all this stuff if I were to contribute.

borkdude 2020-03-06T16:30:45.251200Z

Again, sogaiu has figured this out once I think.

borkdude 2020-03-06T16:30:56.251500Z

Maybe also @retrogradeorbit

lread 2020-03-06T17:42:41.251900Z

yeah multitime is new to me as well, (thanks @sogaiu!)

👍 1
lread 2020-03-06T17:51:34.252Z

tx, added the above notes to clj-graal-docs

👍 1
wcohen 2020-03-06T18:06:08.253300Z

@borkdude did you ever get sqlite working with native-image?

borkdude 2020-03-06T18:46:57.253400Z

thnks!

mkvlr 2020-03-06T20:12:26.254Z

what’s the biggest apps that people have used native image for successfully?

mkvlr 2020-03-06T20:16:31.254200Z

I probably should not expect this to ever finish, and successfully less so :thinking_face:

wcohen 2020-03-06T20:23:19.255200Z

Additionally, I'm trying to get geo to work on graal but struggling with this JNI: https://github.com/Factual/geo/blob/master/src/geo/h3.clj#L16 It loads a native library from a resource after copying it to a temp file, so System/loadLibrary can't just be called in main to give it to graal: https://github.com/uber/h3-java/blob/master/src/main/java/com/uber/h3core/H3CoreLoader.java#L122 Using something like {"pattern":".*libh3.*"} in resource-config.json seems to embed the resources in the binary, but I can't get graal to get past the UnsatisfiedLinkError, even if I manually add in the native methods into jni-config.json. This (https://github.com/oracle/graal/issues/1828) suggests turning off --initialize-at-build-time in situations like these, but that option seems necessary to get native-image to work with clojure in general. Any ideas?

borkdude 2020-03-06T20:31:08.255500Z

@wcohen For JNI examples, see clj-graal-docs

borkdude 2020-03-06T20:31:35.255900Z

@wcohen Here is an example that talks to a Postgres DB: https://github.com/leafclick/pgmig

borkdude 2020-03-06T20:32:12.257200Z

I haven't tried sqlite in a while, it's not trivial but since the postgres example works, I expect it to be possible

wcohen 2020-03-06T20:32:56.258200Z

Yes -- that example and clj-graal-docs have been quite helpful. The question around sqlite is the same as this one, since sqlite embeds a range of platform-dependent binaries that get copied to a temp file and loaded on startup

borkdude 2020-03-06T20:33:39.259Z

@mkvlr > what’s the biggest apps that people have used native image for successfully? In general I think it's best to start small, there are a lot of things that can make native-image go 📈 and you want to have an idea what's causing it.

mkvlr 2020-03-06T20:37:21.259700Z

right, compiling our whole thing to native image also doesn’t make any sense

mkvlr 2020-03-06T20:38:54.260100Z

but I’ll keep trying every now and then… 😼

borkdude 2020-03-06T20:39:52.260400Z

if it works the first time, there's probably something wrong.