Skip to content

Commit

Permalink
Dockerized example with warmup
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
  • Loading branch information
rvansa authored and danielkec committed Jun 14, 2024
1 parent 30514e4 commit 73b0abd
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
9 changes: 7 additions & 2 deletions examples/crac/Dockerfile.crac
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ ENV JDK_NAME=zulu22.30.13-ca-crac-jdk22.0.1-linux_x64
ENV JAVA_HOME=/usr/share/$JDK_NAME
ENV CR_DIR=${CONT_IMG_VER:-/crac-checkpoint/cr}

# Install wrk
RUN microdnf -y update && microdnf -y install perl wget tar gzip curl git openssl-devel
RUN git clone https://github.com/wg/wrk.git && cd wrk && make && cp wrk /usr/local/bin/

# Install CRaC
RUN microdnf -y update && microdnf -y install wget tar gzip
RUN wget -O crac-jdk.tar.gz "https://cdn.azul.com/zulu/bin/${JDK_NAME}.tar.gz"
RUN tar zxf ./crac-jdk.tar.gz -C /usr/share && ln -s $JAVA_HOME/bin/java /bin/
RUN ln -s $JAVA_HOME/bin/jcmd /bin/ && ln -s $JAVA_HOME/bin/jps /bin/
Expand All @@ -35,7 +38,9 @@ WORKDIR /helidon
ADD target/*.jar .
ADD target/libs libs
ADD runtimeCRaC.sh .
RUN chmod +x ./runtimeCRaC.sh
ADD warmUp.sh .
ADD measure.sh .
RUN chmod +x ./*.sh

CMD ["sh","./runtimeCRaC.sh"]

Expand Down
2 changes: 1 addition & 1 deletion examples/crac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ therefore CRaC checkpoint needs to be created in runtime.

```bash
mvn clean package
docker build --build-arg CR_DIR=~/cr -t crac-helloworld . -f Dockerfile.crac
docker build -t crac-helloworld . -f Dockerfile.crac
# First time ran, checkpoint is created, stop with Ctrl-C
docker run --privileged --network host --name crac-helloworld crac-helloworld
# Second time starting from checkpoint, stop with Ctrl-C
Expand Down
21 changes: 21 additions & 0 deletions examples/crac/measure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001
printf "\nMeasuring ..."
wrk -c 16 -t 16 -d 10s http://localhost:7001
6 changes: 4 additions & 2 deletions examples/crac/runtimeCRaC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ then
ldd --version | grep ldd
# Workaround for https://github.com/checkpoint-restore/criu/issues/1696
# see https://github.com/checkpoint-restore/criu/pull/1706
export GLIBC_TUNABLES=glibc.pthread.rseq=0
# export GLIBC_TUNABLES=glibc.pthread.rseq=0

echo "=== Pre-starting Helidon MP app ==="
set +e
mkdir -p "/crac-checkpoint/cr"
$JAVA_HOME/bin/java -XX:CRaCCheckpointTo=/crac-checkpoint/cr -jar ./*.jar
./warmUp.sh &
$JAVA_HOME/bin/java -XX:CRaCCheckpointTo=$CR_DIR -jar ./*.jar
set -e

echo "=== CRaC checkpoint created, checking log dump for errors ==="
cat $CR_DIR/dump*.log | grep "Warn\|Err\|succ"
else
echo "==== Starting directly from CRaC checkpoint ===="
./measure.sh &
exec $JAVA_HOME/bin/java -XX:CRaCRestoreFrom=$CR_DIR
fi

Expand Down
25 changes: 25 additions & 0 deletions examples/crac/warmUp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#


curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001
printf "\n==== Warming up ...\n"
wrk -c 16 -t 16 -d 10s http://localhost:7001
printf "\n==== Warmup complete, creating checkpoint\n"
jcmd helidon-examples-microprofile-hello-world-implicit.jar JDK.checkpoint
#kill $(jps | grep jar | awk '{print $1}')

0 comments on commit 73b0abd

Please sign in to comment.