Fork me on GitHub
#graalvm
<
2021-04-30
>
seancorfield04:04:22

Hi folks! Thanks to @delaguardo I am adding GraalVM to next.jdbc’s test matrix and I went with the example set of versions and Java bases that he provided — see https://github.com/seancorfield/next-jdbc/blob/develop/.github/workflows/test.yml#L28-L29 — but I was wondering what is common / reasonable at this point in terms of both GraalVM versions and Java bases?

👍 4
borkdude06:04:52

@seancorfield usually I’m using the latest jdk11

borkdude06:04:10

And thanks for doing this :)

lread15:04:43

@seancorfield, for rewrite-clj, I was testing with GraalVM latest JDK8 and JDK11, but am currently dropping JDK8 GraalVM tests (I never tested JDK8 on on Windows because it was too cumbersome to install, and JDK8 is no longer available for macOS with the current GraalVM release). I find GitHub Actions is nice in that it lets me run my tests on Windows, macOS and Ubuntu. GitHub Actions also has a relatively generous 7gb of RAM which can come in handy if your native-image compile happens to be RAM-hungry.

lread15:04:31

Note also that the current GraalVM release is 21.1.0 which I don’t see in the code snippit you provided.

borkdude15:04:31

On the other hand, a library like next.jdbc should be able to compile with only 4gb, so giving it 7gb might prevent you from detecting weird problems 🙃

lread15:04:32

Also GraalVM 21.1.0 includes an experimental JDK16 release. I won’t bother with this and will wait for their JDK17 release.

borkdude15:04:03

I think it would be sane to test JDK11 + GraalVM LTS and GraalVM latest

borkdude15:04:22

(but I would be perfectly happy with only JDK11 + latest)

lread15:04:33

Ya @borkdude, I am going with your perfectly happy route. simple_smile

seancorfield16:04:50

Thanks @lee @borkdude Is there any value in testing against those intermediate versions, rather than just the three that are easily available for d/l from http://graalvm.org?

graalvm: [ '19.3.6', '20.3.2', '21.1.0' ]
        base: [ 'java8', 'java11' ]

borkdude16:04:32

of those arrays, take the last values

lread16:04:26

that’s my approach too, just GraalVM 21.1.0 java11.

borkdude16:04:27

oh I see you are going to test the JVM version with graal, this isn't about native?

lread16:04:56

oh I assumed native-image testing too…

seancorfield16:04:47

I have no idea — which is why I’m here asking 🙂 — I just followed @delaguardo’s notes.

lread16:04:59

So my GraalVM tests for rewrite-clj are to verify that that rewrite-clj still works after being compiled to a native binary by GraalVM’s native-image. GraalVM is more that just native-image though, but that’s what we typically talk about here and cover on https://github.com/lread/clj-graal-docs.

seancorfield16:04:14

@lee Do you have a GH Actions file for that?

lread16:04:12

Yup! https://github.com/clj-commons/rewrite-clj/blob/main/.github/workflows/native-image-test.yml, it reaches out to scripts written in Babashka. You might want to ignore my sci tests and focus on pure tests, but I did describe both testing strategies up on https://github.com/lread/clj-graal-docs/blob/master/doc/testing-strategies.md

lread16:04:05

Sci = test intepretation, pure = test compilation

lread16:04:32

@borkdude’s projects are also great references.

borkdude16:04:59

@seancorfield I usually make CLIs with graalvm and those a pretty easy to test by just making a clojure function which shell out to that CLI and then test for the correctly printed value. I then use normal clojure.test to run tests. This is how I can re-use tests for both the JVM and native. Both combinations can be then run on each OS including Windows. This is how I do it for clj-kondo, babashka, and jet.

lread16:04:43

We call that testing strategy “conditional spawing” up on clj-graal-docs.

borkdude16:04:44

Rewrite-clj is a library so that is obviously a bit different and can be tested like @lee described it.

borkdude16:04:17

FWIW I am testing next.jdbc in one of my projects natively as well by using it as a library, against various databases

lread16:04:10

Cool, are the jdbc drivers sometimes a challenge?

borkdude16:04:52

yes, they are the main challenge, because they often rely on reflection

seancorfield16:04:01

I don’t know enough about GraalVM to follow what’s going on in rewrite-clj’s GH Actions file and the supporting .clj for the native test so at this point I think I’ll just have next.jdbc run tests against the various versions like @delaguardo suggested and leave it up to users of next.jdbc to do native image tests if that’s what they are building (as @borkdude does).

seancorfield16:04:02

So now I have:

build-graalvm-old:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        graalvm: [ '19.3.6', '20.3.2' ]
        base: [ 'java8', 'java11' ]
      ...

  build-graalvm-new:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        graalvm: [ '21.1.0' ]
        base: [ 'java11', 'java16' ]

lread16:04:13

That seems reasonable, but I’m not sure there is huge value to JVM testing against GraalVM JDKs. (Someone tell me I’m wrong, I am ok with being wrong simple_smile). I don’t think it hurts, but it might be just as good as testing against various AdoptOpenJDK versions (8, 11, 16)?

lread16:04:26

Also: it was not a minor effort for me to setup GraalVM native-image testing for rewrite-clj, those were earlier days, but still, it took time. You could consider just pointing to @borkdude’s project from your docs as an example of it being possible to run next.jdbc when compiled by GraalVM native-image.

2