Updated our clj-graal-docs to reflect momentous release of Clojure 1.10.2-alpha1 🎉 https://github.com/lread/clj-graal-docs/commit/2de39cddfa1af54868ff7297ed3c04093d734ad11❤️1🎉
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-5958143431🎉
Cool! It is not Clojure specific, but maybe worth pointing to from clj-graal-docs?
I shall do
@lee Here's the commit on master: https://github.com/borkdude/babashka/commit/5723206ca2949a8e6443cdc38f8748159bcdce91
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.
Maybe it's also related to enabling the SSL stuff. Likely, but I haven't tested that hypothesis.
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
$ 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
Hmm, maybe mentioning the
multitime util to measure startup time is also a nice addition. sogaiu brought it to my attention
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.
Again, sogaiu has figured this out once I think.
tx, added the above notes to clj-graal-docs1👍
what’s the biggest apps that people have used native image for successfully?
I probably should not expect this to ever finish, and successfully less so :thinking_face:
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
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
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?
I haven't tried sqlite in a while, it's not trivial but since the postgres example works, I expect it to be possible
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
@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.
right, compiling our whole thing to native image also doesn’t make any sense
but I’ll keep trying every now and then… 😼
if it works the first time, there's probably something wrong.