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/.
borkdude 2021-02-27T14:46:43.023400Z

Slides from babashka talk at GraalVM Workshop 2021

21🎉
ericdallo 2021-02-27T16:05:32.025Z

I'll doing a POC on clojure-lsp to use datalevin , it worked really well, but having issues compiling the clojure-lsp native-image, should I manually compile the datalevin/native/src libs manually? I thought we could have the libs compiled in the classpath just like https://github.com/xerial/sqlite-jdbc/blob/master/src/main/resources/org/sqlite/native/Linux/x86_64/libsqlitejdbc.so

ericdallo 2021-02-28T12:46:19.029900Z

Oh that was fast haha! I'm new too don't worry ;)

ericdallo 2021-02-28T12:46:25.030100Z

Thank you for the quick response

ericdallo 2021-02-28T12:46:56.030300Z

I'll test it with the 0.4.0 as soon you release it, excited for that!

ericdallo 2021-02-28T13:25:41.030500Z

Thanks for the help @huahaiy, with your PR merged I'm getting a

java.lang.IllegalArgumentException: No method in multimethod 'open-kv' for dispatch value: :graal

ericdallo 2021-02-28T13:33:36.030700Z

Does the key-value store lmdb work with graal?

Huahai 2021-02-28T16:11:53.030900Z

you mean when you run the binary?

Huahai 2021-02-28T16:17:38.031100Z

it looks to me that the graal version of the LMDB binding is not compiled in, did you include datalevin’s reflect-config.json?

Huahai 2021-02-28T16:24:07.031300Z

ldd ./clojure-lsp linux-vdso.so.1 (0x00007ffcc5ff9000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f57728c4000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f57728a1000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f577289b000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f577287f000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f577268d000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f577253e000) /lib64/ld-linux-x86-64.so.2 (0x00007f57790e9000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5772521000)

Huahai 2021-02-28T16:24:40.031500Z

so liblmdb.so.0 is missing

ericdallo 2021-02-28T16:34:41.031700Z

Yes, I merged the reflect-config json with datalevin one

Huahai 2021-02-28T16:34:44.031900Z

ok, had this warning, so the release jar doesn’t include graal version

Huahai 2021-02-28T16:34:45.032100Z

WARNING: Could not resolve datalevin.binding.graal.LMDB for reflection configuration. Reason: java.lang.ClassNotFoundException: datalevin.binding.graal.LMDB.

ericdallo 2021-02-28T16:35:09.032300Z

BTW i'm having the same issue with a JVM version, not graal one but the defmethod warn about the :java one

Huahai 2021-02-28T16:35:11.032500Z

let me figure out how to include that jar

Huahai 2021-02-28T16:35:36.032800Z

interesting

ericdallo 2021-02-28T16:35:59.033Z

https://pastebin.com/sJL5yZEL

ericdallo 2021-02-28T16:36:55.033200Z

> WARNING: Could not resolve datalevin.binding.graal.LMDB for reflection configuration. Reason: java.lang.ClassNotFoundException: datalevin.binding.graal.LMDB. I had this one too

ericdallo 2021-02-28T16:37:28.033400Z

But right now the issue seems to be the defmethod not recognizing the defmulti implementations

Huahai 2021-02-28T16:38:30.033600Z

i think i know what’s wrong, hold on, let me fix it

1👍
Huahai 2021-02-28T17:18:23.033900Z

please test the updated PR, i tested locally, it seems to include lmdb.so now

ericdallo 2021-02-28T17:19:43.034100Z

Alright, testing it

ericdallo 2021-02-28T18:44:32.034300Z

Thanks for the help @huahaiy,the issue is fixed and it seems to work properly 🙂 I just needed to add the require [datalevin.binding.graal] as well. But probably clojure-lsp will follow a simpler way persisting the db with spit as we just need to persist things and read on time when clojure-lsp initializes. Anyway, thanks for helping on this POC, datalevin seems really cool!

1🥳
Huahai 2021-02-28T19:44:14.034500Z

Thanks for trying it out. You gave me some ideas on how to improve the packaging

ericdallo 2021-02-28T19:49:22.034700Z

Glad to hear 😄

ericdallo 2021-02-27T16:05:50.025300Z

WDYT @huahaiy?

ericdallo 2021-02-27T16:07:06.025600Z

Otherwise should I need to compile it like https://github.com/juji-io/datalevin/blob/master/native/script/compile#L19-L21 besides the need to install liblmdb-dev?

ericdallo 2021-02-27T16:23:08.025900Z

I mean, I can copy the c files to clojure-lsp, manually gcc them during CI but it seems odd to me, it'd be great to have those libs from datalevin somehow

ericdallo 2021-02-27T17:00:51.026100Z

Even manually compiling and including in my graalvm compile, I get a JNI error:

ericdallo 2021-02-27T17:00:52.026300Z

com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine            PosixJavaThreads.java:  192
                              com.oracle.svm.core.thread.JavaThreads.threadStartRoutine                 JavaThreads.java:  519
                                                                   java.lang.Thread.run                      Thread.java:  834
                                     java.util.concurrent.ThreadPoolExecutor$Worker.run          ThreadPoolExecutor.java:  628
                                      java.util.concurrent.ThreadPoolExecutor.runWorker          ThreadPoolExecutor.java: 1128
                                                    java.util.concurrent.FutureTask.run                  FutureTask.java:  264
                                    java.util.concurrent.Executors$RunnableAdapter.call                   Executors.java:  515
                          org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run  ConcurrentMessageProcessor.java:  113
                            org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen       StreamMessageProducer.java:   94
                     org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage       StreamMessageProducer.java:  194
                                       org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume              RemoteEndpoint.java:  190
                                 org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest              RemoteEndpoint.java:  261
                             org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request             GenericEndpoint.java:  120
                       org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0             GenericEndpoint.java:   65
                                                                                    ...                                       
clojure_lsp.main.proxy$clojure_lsp.ClojureExtensions$LanguageServer$c8d5825a.initialize                                       
                                                                 clojure-lsp.main/fn/fn                         main.clj:  288
                                                                                    ...                                       
                                                        clojure-lsp.handlers/initialize                     handlers.clj:   39
                                                 clojure-lsp.crawler/initialize-project                      crawler.clj:  197
                                                    clojure-lsp.crawler/analyze-project                      crawler.clj:  192
                                                  clojure-lsp.crawler/analyze-classpath                      crawler.clj:  170
                                                               clojure-lsp.db/read-deps                           db.clj:   39
                                                                 clojure-lsp.db/make-db                           db.clj:   25
                                                               datalevin.lmdb/open-lmdb                         lmdb.clj:  841
                                                               datalevin.lmdb/open-lmdb                         lmdb.clj:  851
                                                          org.lmdbjava.Env$Builder.open                         Env.java:  512
                                                          org.lmdbjava.Env$Builder.open                         Env.java:  486
                                     org.lmdbjava.Library$Lmdb$jnr$ffi$0.mdb_env_create                                       
                                                        com.kenai.jffi.Invoker.invokeN1                     Invoker.java:  997
                                                      com.kenai.jffi.Foreign.invokeN1O1                      Foreign.java     
                         com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress   JNIGeneratedMethodSupport.java:   57
                         com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint            JNINativeLinkage.java:  153
java.lang.UnsatisfiedLinkError: com.kenai.jffi.Foreign.invokeN1O1(JJJLjava/lang/Object;III)J [symbol: Java_com_kenai_jffi_Foreign_invokeN1O1 or Java_com_kenai_jffi_Foreign_invokeN1O1__JJJLjava_lang_Object_2III]

borkdude 2021-02-27T17:30:02.026800Z

^ @denik might also know, since he's also working on something native datalevin related

1😉