Init image for SubstrateVM.#156
Conversation
| cd runtime | ||
| docker build -f Dockerfile-jdk9 -t fnproject/fn-java-fdk:jdk9-${BUILD_VERSION} . | ||
| ) | ||
|
|
There was a problem hiding this comment.
Any reason why we wouldn't build this on every release?
Also could you clarify what the deps are for the tools below (I see python 2.7)
There was a problem hiding this comment.
The build of the fnproject/fn-java-native is very expensive.
It needs to build JVMCI enabled JDK and then the SubstrateVM. This is the reason I've made this optional.
The dependency on the python is only in the Docker container during the fnproject/fn-java-native build. The python is required for the mx build system.
| WORKDIR /build | ||
|
|
||
| RUN set -x \ | ||
| && git clone https://github.com/graalvm/mx.git \ |
There was a problem hiding this comment.
Is it preferable to use a released version here rather than master?
I know there is still a bit of build-unpredictability but I wonder if revving the graal version explicitly is the right thing (rather than on every release)
There was a problem hiding this comment.
The mx is a build tool used to build the GraalVM.
It should be backward compatible, using latest should be fine.
| <modelVersion>4.0.0</modelVersion> | ||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <fdk.version>1.0.64</fdk.version> |
There was a problem hiding this comment.
Would prefer it if the init image generated either the current version it was built with (placeholder this to /release.version on init-image build) or (slightly less ideal but what the CLI does now) picked up the latest version from bintray and/or an env var.
There was a problem hiding this comment.
Right.
I will fix it to use the /release.version.
Thanks for pointing me on it!
| WORKDIR /function | ||
| COPY --from=build /function/target/*.jar target/ | ||
| COPY --from=build /function/src/main/conf/reflection.json reflection.json | ||
| RUN /usr/local/graalvm/bin/native-image \ |
There was a problem hiding this comment.
The FDK now has a mandatory JNI dependency to handle the new HTTP-over/unix sockets proto - (http-stream) protocol (we are moving to this over other protocols going forward) - - (build from /runtime/src/main/c/) is there a way we can get this working in Graal ?
The UDS code is fairly vanilla but currently compiled against glibc - will this work by default or do we need to something to make this work better in graal?
There was a problem hiding this comment.
Yes.
There is a support for the JNI in the SubstrateVM. I need to add JNIConfigurationFile similar to ReflectionConfigurationFile listing the native methods.
Regarding using the AF_UNIX socket library in the scratch image I need to try if we can still use the -static compilation or we need to copy some libraries from the build image.
There was a problem hiding this comment.
Yep happy do that in a separate PR after this is merged -
| @@ -0,0 +1,2 @@ | |||
| runtime: docker | |||
| format: http | |||
There was a problem hiding this comment.
FWIW - we are planning to deprecate http in favour of the unix socket proto over the next few weeks.
There was a problem hiding this comment.
It is very hard to merge GraalVM SVM support if we every time run into "will be deprecated and replaced by XY in several weeks" I hope this planned change will not block the merge.
There was a problem hiding this comment.
Understood - and appologies for inconvenience here - let's get back to how we support this after this is merged.
There was a problem hiding this comment.
What is the format name which should be used for AF_UNIX sockets?
I will try to make it work.
|
I demoed SVM support at the Hamburg JUG yesterday using this PR and it worked nicely! 😃 I've got a couple of comments:
|
|
|
||
| RUN set -x \ | ||
| && apt-get -y update \ | ||
| && apt-get -y install gcc g++ git make openjdk-8-doc openjdk-8-source python zlib1g-dev |
There was a problem hiding this comment.
is openjdk-8-doc and source needed here? -these are going to create huge layers - the source package pulls the X-libraries by virtue of pulling openjdk-8-jdk (vs the headless version which pulls a ton of deps)
Can you add a
&& rm -rf /var/lib/apt/lists/* to the end of this layer
There was a problem hiding this comment.
I will try if the headless JDK version is enough to build the SubstrateVM.
I will add rm ...
There was a problem hiding this comment.
Yeah - had a quick play and couldn't get it working - the issue is that the source package in debian seems to be fixed to the non-headless version
The dep footprint for this layer is not too bad for a dev image (119MB) and the Graal Layer is about 288MB
➜ docker history fnproject/fn-java-native
IMAGE CREATED CREATED BY SIZE COMMENT
252228a80443 19 hours ago /bin/sh -c #(nop) WORKDIR /function 0B
dc5e51662e83 19 hours ago /bin/sh -c #(nop) ENV GRAALVM_HOME=/usr/loc… 0B
36207c000987 19 hours ago /bin/sh -c #(nop) COPY dir:2cc8a2aa51ac7cfdf… 288MB
0bb10d5211e4 20 hours ago /bin/sh -c set -x && apt-get -y update … 119MB
8f4317c6c4fa 20 hours ago /bin/sh -c #(nop) LABEL maintainer=tomas.ze… 0B
44e19a16bde1 3 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:e6ca98733431f75e9… 55.3MB
There was a problem hiding this comment.
Fwiw I’m not too bothered about the net size here it’s not great but pretty tolerable imho
There was a problem hiding this comment.
The resulting build image is created below from the debian:stretch-slim and only the SubstrateVM is copied from it.
FROM debian:stretch-slim as final
RUN set -x \
&& apt-get -y update \
&& apt-get -y install gcc zlib1g-dev
COPY --from=build /build/graal/vm/latest_graalvm/graalvm /usr/local/graalvm
|
To @shaunsmith:
|
|
@tzezula You're right, my thinking is wrong here. But I see the class and method name also appears in the For Java, the obvious next step would be for the user to be able to specify the package they want the function class to be in. @mjg123 here's a good use case for supporting additional parameters to init-image! |
|
@shaunsmith I agree that it would be good to allow parametrized package and function name. Unfortunately it's not doable with current |
|
The function name is passed into the init image through the |
|
@shaunsmith Thanks! The |
|
I've updated the PR to resolve the comments.
Questions: The artefacts for the version |
|
the version in release.version is the forthcoming release (next) not the previous version. we had a glitch with our release script which stopped 1.0.65-1.0.69 from being pushed, this is fixed. |
|
the release script (and on each branch) already does the following prior to each build: so any fdk.version properties referenced in pom files should be up-to-date |
|
I'm just testing this with the latest FDK version 1.0.70 and I see an error in run the build works fine but then I see: Is there something I can do to fix this (this code was added recently?) |
|
@zootalures I am just solving it. It was introduced by: |
|
Doh - is that specific API not supported or is it a more general annotations issue? |
|
@zootalures It's a missing SubstrateVM substitution for |
|
Hmm good point - it probably should be repeatable - will take a look at that later, thanks! (we only have one FnFeature today, and that's Flow ;)) |
|
I am now building the SubstrateVM from revision |
|
I’ve Merged the other change I think this can be merged after a rebase/test and we can iterate from there |
Added an init image for SubstrateVM compilation.
The
init --init-image fnproject/fn-java-native-initgenerates a template withdockerruntime building a SubstrateVM image for Java Maven project.