Skip to content

Commit

Permalink
feature: two modes of capturing memory stats: basic and "detail" with -m
Browse files Browse the repository at this point in the history
flag
Also added basic CPU average usage.
  • Loading branch information
Delawen committed Jul 4, 2024
1 parent 302c31e commit 00079e2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
3 changes: 2 additions & 1 deletion BaselineBootstrap
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM localhost/fedora-with-dev:latest
WORKDIR "/quarkus-boot-measure"
ENV EXTRAPARAMS=$EXTRAPARAMS

EXPOSE 8080
USER 1001

# -Djdk.console=java.basebroken is useful because of https://bugs.openjdk.org/browse/JDK-8333794
# -XX:+UseG1GC because we need to disable ergonomics and consistently use the same GC across CDS archives vs runtime, at any memory size we're testing with.
ENTRYPOINT ["java", "-XX:NativeMemoryTracking=detail", "-Dquarkus.http.host=0.0.0.0", "-Djdk.console=java.basebroken", "-XX:+UseG1GC", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager", "-Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory", "-jar", "target/quarkus-app/quarkus-run.jar"]
ENTRYPOINT java $EXTRAPARAMS -Dquarkus.http.host=0.0.0.0 -Djdk.console=java.basebroken -XX:+UseG1GC -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory -jar target/quarkus-app/quarkus-run.jar
5 changes: 3 additions & 2 deletions LatestJDKBuildContainerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM localhost/fedora-with-dev:latest
ENV EXTRAPARAMS=$EXTRAPARAMS
WORKDIR "/"
# The "rand1" option should have no impact: useful to invalidate this line from various local build caches.
RUN git clone -o rand1 --branch jdk23 --depth 1 https://github.com/openjdk/jdk.git
WORKDIR "/jdk"
RUN bash configure --with-jvm-variants=custom --with-jvm-features=cds,compiler1,compiler2,g1gc,serialgc,jfr,jvmti,services,management,shenandoahgc,link-time-opt --enable-generate-classlist --disable-manpages --with-vendor-name=Experiments --with-debug-level=release --disable-full-docs --disable-warnings-as-errors
RUN make images
WORKDIR "/jdk/build/linux-x86_64-custom-release/images/jdk"
ENTRYPOINT ["/jdk/build/linux-x86_64-custom-release/images/jdk/bin/java", "-version"]

FROM localhost/fedora-with-dev:latest
ENV EXTRAPARAMS=$EXTRAPARAMS
COPY --from=0 /jdk/build/linux-x86_64-custom-release/images/jdk /latest-openjdk
WORKDIR "/quarkus-boot-measure"

Expand All @@ -17,4 +18,4 @@ USER 1001

# -XX:+UseG1GC because we need to disable ergonomics and consistently use the same GC across CDS archives vs runtime, at any memory size we're testing with.
# For diagnostics might want to use also -Xlog:cds -Xlog:scc :
ENTRYPOINT ["/latest-openjdk/bin/java", "-XX:NativeMemoryTracking=detail", "-XX:+UseG1GC", "-Dquarkus.http.host=0.0.0.0", "-Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager", "-jar", "target/quarkus-app/quarkus-run.jar"]
ENTRYPOINT /latest-openjdk/bin/java $EXTRAPARAMS -XX:+UseG1GC -Dquarkus.http.host=0.0.0.0 -Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory -Djava.util.logging.manager=org.jboss.logmanager.LogManager -jar target/quarkus-app/quarkus-run.jar
3 changes: 2 additions & 1 deletion LeydenBuildContainerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WORKDIR "/leyden/build/linux-x86_64-custom-release/images/jdk"
ENTRYPOINT ["/leyden/build/linux-x86_64-custom-release/images/jdk/bin/java", "-version"]

FROM localhost/fedora-with-dev:latest
ENV EXTRAPARAMS=$EXTRAPARAMS
COPY --from=0 /leyden/build/linux-x86_64-custom-release/images/jdk /leyden-openjdk
WORKDIR "/quarkus-standard-warmup"
RUN ./produce-cds-archive.sh
Expand All @@ -22,4 +23,4 @@ USER 1001
# -Djdk.console=java.basebroken is useful because of https://bugs.openjdk.org/browse/JDK-8333794
# -XX:+UseG1GC because we need to disable ergonomics and consistently use the same GC across CDS archives vs runtime, at any memory size we're testing with.
# For diagnostics might want to use also -Xlog:cds -Xlog:scc :
ENTRYPOINT ["/leyden-openjdk/bin/java", "-XX:NativeMemoryTracking=detail", "-Djdk.console=java.basebroken", "-XX:+UseG1GC", "-XX:CacheDataStore=/leyden-openjdk/quarkus-generic-cds.cds", "-Dquarkus.http.host=0.0.0.0", "-Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager", "-jar", "target/quarkus-app/quarkus-run.jar"]
ENTRYPOINT /leyden-openjdk/bin/java $EXTRAPARAMS -Djdk.console=java.basebroken -XX:+UseG1GC -XX:CacheDataStore=/leyden-openjdk/quarkus-generic-cds.cds -Dquarkus.http.host=0.0.0.0 -Djava.util.concurrent.ForkJoinPool.common.threadFactory=io.quarkus.bootstrap.forkjoin.QuarkusForkJoinWorkerThreadFactory -Djava.util.logging.manager=org.jboss.logmanager.LogManager -jar target/quarkus-app/quarkus-run.jar
55 changes: 47 additions & 8 deletions measure-boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,33 @@ measure() {

# Options such as cpuset-mems=0 might require some extra system settings; see: https://fossies.org/linux/podman/troubleshooting.md
#TODO pick specific CPUs
podman run --pull=never --read-only --rm -d -p 8080:8080 --cpus 4 --cpuset-mems=0 --memory 2000m --name $TEMP_INTANCE_NAME $FULLCONTAINERNAME > /dev/null

podman run --env 'EXTRAPARAMS*' --pull=never --read-only --rm -d -p 8080:8080 --cpus 4 --cpuset-mems=0 --memory 2000m --name $TEMP_INTANCE_NAME $FULLCONTAINERNAME > /dev/null

# For experiments:
# podman run --pull=never --read-only --rm -it -p 8080:8080 --cpus 4 --cpuset-mems=0 --memory 2000m --name measurement localhost/leyden-build:latest

#JAVA_PID=$(podman exec -it $TEMP_INTANCE_NAME bash -c "ps -ef | grep java | head -n 1 | awk '{print \$2}'")
#echo "Found Java process with PID: $JAVA_PID"
#Not using this variable because it is always one. To check back later.

podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory baseline scale=MB" > /dev/null
podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory detail scale=MB" >> "$TEMP_INTANCE_NAME"_NMT.log


if [ "$MEMORY_LEVEL" = "detail" ]; then
podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory baseline scale=MB" > /dev/null
fi
until [ -f startedTimestamp ]
do
sleep 1
#Get memory
podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory detail scale=MB" >> "$TEMP_INTANCE_NAME"_NMT.log

if [ "$MEMORY_LEVEL" = "detail" ]; then
podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory detail scale=MB" >> "$TEMP_INTANCE_NAME"_memory.log
else
podman container stats --no-stream --format="Memory limit: {{.MemLimit}}bytes Memory usage: {{.MemUsageBytes}}bytes" $TEMP_INTANCE_NAME >> "$TEMP_INTANCE_NAME"_memory.log
fi
done

podman container stats --no-stream --format="CPU average: {{.AVGCPU}}" $TEMP_INTANCE_NAME >> "$TEMP_INTANCE_NAME"_cpu.log

finishTString=$(cat startedTimestamp)
forceClean $TEMP_INTANCE_NAME
Expand All @@ -47,12 +57,41 @@ measure() {

deltaMilliseconds=$((finishTString - startTimeMilliseconds))
echo "Container '$SHORT_CONTAINERNAME' completed bootstrap in $deltaMilliseconds milliseconds"

echo "It used the following CPU:"
cat "$TEMP_INTANCE_NAME"_cpu.log
rm "$TEMP_INTANCE_NAME"_cpu.log

echo "It used the following native memory:"
#cat "$TEMP_INTANCE_NAME"_NMT.log | head -n 62 | tail -n 56
cat "$TEMP_INTANCE_NAME"_NMT.log | head -n 7 | tail -n 1
rm "$TEMP_INTANCE_NAME"_NMT.log
if [ "$MEMORY_LEVEL" = "detail" ]; then
cat "$TEMP_INTANCE_NAME"_memory.log | head -n 7 | tail -n 1
#cat "$TEMP_INTANCE_NAME"_NMT.log | head -n 62 | tail -n 56
else
cat "$TEMP_INTANCE_NAME"_memory.log
fi
rm "$TEMP_INTANCE_NAME"_memory.log
}

EXTRAPARAMS=""
MEMORY_LEVEL="basic"

while getopts mh flag
do
case "${flag}" in
m)
MEMORY_LEVEL="detail"
EXTRAPARAMS="$EXTRAPARAMS -XX:NativeMemoryTracking=detail"
;;
h)
echo "You can use the flag -m to active more detailed memory statistics."
exit 0
;;
*)
echo "Found an unknown flag '${1}'"
;;
esac
done

measure "jdk23-leyden-build"
measure "fedora-standard"
measure "jdk23-build"

0 comments on commit 00079e2

Please sign in to comment.