Slides from babashka talk at GraalVM Workshop 2021
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
Oh that was fast haha! I'm new too don't worry ;)
Thank you for the quick response
I'll test it with the 0.4.0 as soon you release it, excited for that!
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
Does the key-value store lmdb work with graal?
you mean when you run the binary?
it looks to me that the graal version of the LMDB binding is not compiled in, did you include datalevin’s reflect-config.json?
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)
so liblmdb.so.0 is missing
Yes, I merged the reflect-config json with datalevin one
ok, had this warning, so the release jar doesn’t include graal version
WARNING: Could not resolve datalevin.binding.graal.LMDB for reflection configuration. Reason: java.lang.ClassNotFoundException: datalevin.binding.graal.LMDB.
BTW i'm having the same issue with a JVM version, not graal one but the defmethod warn about the :java
one
let me figure out how to include that jar
interesting
> WARNING: Could not resolve datalevin.binding.graal.LMDB for reflection configuration. Reason: java.lang.ClassNotFoundException: datalevin.binding.graal.LMDB. I had this one too
But right now the issue seems to be the defmethod not recognizing the defmulti implementations
i think i know what’s wrong, hold on, let me fix it
please test the updated PR, i tested locally, it seems to include lmdb.so now
Alright, testing it
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!
Thanks for trying it out. You gave me some ideas on how to improve the packaging
Glad to hear 😄
WDYT @huahaiy?
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
?
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
Even manually compiling and including in my graalvm compile, I get a JNI error:
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]
^ @denik might also know, since he's also working on something native datalevin related