Skip to content

Commit

Permalink
[LesnyRumcajs#128] add Shared Class Cache (SCC) for OpenJ9.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarwell committed May 11, 2021
1 parent d66b854 commit 33bb527
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions detailed/java_openj9_grpc_balanced_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:balanced"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
3 changes: 3 additions & 0 deletions detailed/java_openj9_grpc_metronome_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:metronome"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
3 changes: 3 additions & 0 deletions detailed/java_openj9_grpc_nogc_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:nogc"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
3 changes: 3 additions & 0 deletions detailed/java_openj9_grpc_optavgpause_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:optavgpause"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
3 changes: 3 additions & 0 deletions detailed/java_openj9_grpc_optthruput_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:optthruput"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
3 changes: 3 additions & 0 deletions java_openj9_grpc_gencon_bench/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ RUN /app/gradlew installDist
ENV GC "-Xpolicy:gencon"
ENV JAVA_OPTS "${GC} -XX:MinRAMPercentage=70 -XX:MaxRAMPercentage=70"

RUN /app/populate_scc.sh
ENV JAVA_OPTS "${JAVA_OPTS} -Xshareclasses:name=grcp,cacheDir=/app/.classCache"

ENTRYPOINT [ "/app/build/install/examples/bin/hello-world-server" ]
41 changes: 41 additions & 0 deletions java_openj9_grpc_gencon_bench/populate_scc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
if [ "$VERBOSE" != "true" ]; then
exec &>/dev/null
fi

set -Eeox pipefail

SCC_SIZE="64m" # Default size of the SCC layer.
ITERATIONS=2 # Number of iterations to run to populate it.

SCC="-Xshareclasses:name=grcp,cacheDir=/app/.classCache"

OPENJ9_JAVA_OPTIONS="${JAVA_OPTS[@]} $SCC"
CREATE_LAYER="$OPENJ9_JAVA_OPTIONS,createLayer,groupAccess"
DESTROY_LAYER="$OPENJ9_JAVA_OPTIONS,destroy"
PRINT_LAYER_STATS="$OPENJ9_JAVA_OPTIONS,printTopLayerStats"

OLD_UMASK=`umask`
umask 002 # 002 is required to provide group rw permission to the cache when `-Xshareclasses:groupAccess` options is used

# Explicity create a class cache layer for this image layer here rather than allowing
# `server start` to do it, which will lead to problems because multiple JVMs will be started.
java $CREATE_LAYER -Xscmx$SCC_SIZE -version

# Populate the newly created class cache layer.
set +e
for ((i=0; i<$ITERATIONS; i++))
do
/app/build/install/examples/bin/hello-world-server &
# this would be much beneficial
#/app/build/install/examples/bin/hello-world-client &
pkill java
done
set -e

# restore umask
umask ${OLD_UMASK}

# Tell the user how full the final layer is.
FULL=`( java $PRINT_LAYER_STATS || true ) 2>&1 | awk '/^Cache is [0-9.]*% .*full/ {print substr($3, 1, length($3)-1)}'`
echo "SCC layer is $FULL% full."

0 comments on commit 33bb527

Please sign in to comment.