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/.
Ashwin Bhaskar 2020-01-24T04:09:50.010900Z

Has anyone been able to successfully generate native image using graalvm for a clojure app that uses postgres? I am using postgres -

[org.postgresql/postgresql "42.2.5"]
On running the agent for native image generation I get this huge list of error. Attaching a file.

mikeb 2020-01-25T02:37:20.025200Z

Perhaps, try this other postgres driver, I'd be curious to know if it compiles with native-client. https://github.com/impossibl/pgjdbc-ng

Ashwin Bhaskar 2020-01-27T03:21:55.027600Z

@mikeb I removed

[org.postgresql/postgresql "42.2.5"]
and added
[com.impossibl.pgjdbc-ng/pgjdbc-ng "0.8.3"]
But I get an exception
Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:583).
org.postgresql.ds.PGSimpleDataSource

borkdude 2020-01-24T07:31:40.011500Z

@ashwinbhskr There is an issue in the postgres jdbc repo here: https://github.com/pgjdbc/pgjdbc/issues/1189

2020-01-24T07:54:09.014100Z

I know not entirely related to GraalVM, but the logo for Babashka is funny: it is written ba-bash-ka, and if you remove bash, it yields baka, which sounds like the Japanese word for β€œstupid” xD

1πŸ˜‚
borkdude 2020-01-24T07:54:54.014300Z

lol

Eamonn Sullivan 2020-01-24T09:32:40.017500Z

So, just fyi (following up on the question above on Graalvm, native-image and the clj-http lib), it looks like I do need the bells and whistles of clj-http and clj-http-lite isn't enough. Client SSL certificate authentication seems to be either a bell or whistle. I still have a useful Clojure program that does what I want -- I was just hoping to make this util an easily distributable binary image. I'll try to find another util to try this out on.

borkdude 2020-01-24T18:41:05.018Z

Excited to see some activity at https://clojure.atlassian.net/browse/CLJ-1472!

lvh 2020-01-24T18:47:03.018600Z

I put it in my Clojure survey comments box, maybe I wasn't the only one πŸ˜›

1πŸ‘
borkdude 2020-01-24T19:03:55.019200Z

I totally forgot mentioning GraalVM in the survey. I'll pay more attention next year

2020-01-24T19:28:45.020Z

darn it i forgot too :(

borkdude 2020-01-24T19:42:51.020800Z

@alexmiller :

(def o (Object.))
(def mut (int-array 1))

(defmacro do-parallel [n]
  (let [fut-bindings
        (for [i (range n)
              sym [(symbol (str "fut_" i))
                   `(future (locking o (aset mut 0 (inc (long (aget mut 0))))))]]
          sym)
        fut-names (vec (take-nth 2 fut-bindings))]
    `(let [~@fut-bindings] ;; start all futures
       (doseq [f# ~fut-names] ;; wait for all futures
         @f#))))

(time (dotimes [_ 10000] (do-parallel 100)))

;; (println (aget mut 0))  ;; for checking correctness
(removed f argument and fixed unquote-splice for fut-bindings)

alexmiller 2020-01-24T19:46:00.021100Z

does this change anything I care about?

borkdude 2020-01-24T19:46:28.021600Z

yeah, it was [@fut-bindings] which wasn't correct

borkdude 2020-01-24T19:46:37.021800Z

(in the issue)

borkdude 2020-01-24T19:48:07.022300Z

it should be [~@fut-bindings]

alexmiller 2020-01-24T19:49:30.022700Z

ah, I think this is the jira editor messing with stuff

alexmiller 2020-01-24T19:49:34.022900Z

I had that

borkdude 2020-01-24T19:50:43.023600Z

ok. yeah, I've had that before. one minor point is that do-parallel had an f arg which is now not used anymore, but that's just cosmetic

alexmiller 2020-01-24T19:50:53.023900Z

fixed, thx

1πŸ‘