Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Adding basic native memory extraction. No parsed summary yet. #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "-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:+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", "-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
54 changes: 52 additions & 2 deletions measure-boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +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.


if [ "$MEMORY_LEVEL" = "detail" ]; then
podman exec -it $TEMP_INTANCE_NAME bash -c "jcmd 1 VM.native_memory baseline scale=MB" > /dev/null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using the jcmd I sent which just focus on RSS?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the idea is to gather more statistics to offer a better summary later.

fi
until [ -f startedTimestamp ]
do
sleep 1
#Get memory

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
#TODO get memory data sleep 100

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 @@ -40,8 +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:"
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"