A simple JITaaS demo on Docker containers

JIT as a Service (JITaaS) is a fascinating feature that is being developed for the OpenJ9 JVM. The design separates the JIT compilation process from the JVM, enabling distributed JIT compilation, which provides many advantages. This post provides a simple method to try out JITaaS, based on docker containers. So let’s get started!

You can use your laptop or set up a VM for this demo: let’s call it Node1. Please ensure Docker is installed in the Node1 or on your laptop if you wanto directly run docker on it.

JITaaS serving multiple JVM/Applications

Step 1: Pull the docker image on Node1

From Node1 run the following command to pull the docker image. This docker image has a JDK that includes JITaaS support which we can use when create containers using this image in the next steps.

docker pull raguks/ragustry:jitasv2

Step 2: Start JITaaS Server on Node1

The following command creates a new container and starts a JIT server in it. The port 38400 the server is running on is exposed as well. Run the following command to start the JITaaS server in a container:

docker run -p 38400:38400 raguks/ragustry:jitasv2 /jdk/bin/java -XX:JITaaSServer -Xjit:verbose

Step 3: Start JITaaS Clients and apps on Node1

Run the following command to start the client and the app (a small Java program) in a container on the same node:

docker run raguks/ragustry:jitasv2 /jdk/bin/Pattern.sh

If you only wish to run both the JIT server and the client on single node, your demo is now complete! You will see the output of the Java program run using JIT compilation done on the JITaaS server running on a separate docker container on Node1.

If you wish to try a demo of JITaaS server running on a remote node, you need to setup the second Node2, install docker on it and follow Step1 and Step2 as well (i.e pull the docker image and run the JITaaS server on Node2). Once you have completed Step1 and Step2 on Node2, you can follow the next step4.

Step 4: Start JITaaS Client on Node1 to run remote JIT compilation on Node2

Run the following command to start the client and app in a container on Node1, pointing to the remote JIT server for compilation.

docker run raguks/ragustry:jitasv2 /jdk/bin/java -XX:JITaaSClient:server=<Node2 IP address> -version

This following picture shows how the Server and the Client components look on Nodes/VMs. Each blue component in picture is a container running either a JIT server or Client/App.

Expected Output

The Java program runs successfully!

How to update the container with latest JDK

To demo the latest JDK you can replace the existing JDK (/jdk) with the latest version of your choice and commit the container. You can do that using following commands.

docker cp <latestjitaas jdk dir> <containername>:.
docker commit <containername> ragustry:jaasv1

Your local docker image is now updated!

To speed up preparing the JITaaS latest JDK, you can take the latest OpenJDK with Openj9 and compile and replace the JITaaS shared library by following the steps in JITaas Build Instructions.

Credits: Thanks to Harry Yu for his help during compiling jitaas latest code.

OpenJ9 is the faster and better open alternative to other JVMs out there.

3 Replies to “A simple JITaaS demo on Docker containers”

Leave a Reply