Files
jfr/scripts/run-all.sh
T
asmhatre c7eccd1db5 Add jfr-demo: JFR + Mission Control profiling of a live Spring Boot app
Custom OrderProcessed event, CPU/allocation/lock workloads, a diagnostic
endpoint over the JVM's live FlightRecorder state, a JUnit test using the
jdk.jfr.Recording API, and nine captured recordings (flagship, mid-flight
snapshot, isolated vs concurrent threshold comparisons, and a real
dump+stop duplication bug) with their docs/output/*.txt transcripts.
2026-10-01 04:37:26 +00:00

55 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regenerates every file under docs/output/.
#
# 01 comes from the JUnit test suite (jdk.jfr.Recording API, in-process).
# 02-10 come from starting the real app and driving it with jcmd + curl,
# exactly as described in the post. 11 comes from a standalone driver class.
#
# This script assumes JAVA_HOME points at a JDK with jfr/jcmd on PATH, and
# that no other jfr-demo.jar is already running on port 8080.
set -euo pipefail
cd "$(dirname "$0")/.."
echo "== 01: in-process custom-event test =="
mvn -q -B test
echo "== 11: broken-event-pattern standalone demo =="
mvn -q -B -DskipTests package
java -cp target/classes com.ankurm.jfr.events.BrokenEventPatternDemo \
| tee /tmp/broken-event-output.txt
# docs/output/11-broken-event-pattern.txt is written by hand from this run's
# output plus commentary; regenerate it manually if the numbers change.
echo "== starting app for the live jcmd-driven captures =="
scripts/run.sh -d
PID=$(ps -eo pid,cmd | grep '[j]fr-demo.jar' | awk '{print $1}' | head -1)
echo "app pid: $PID"
echo "== 02-10: live recording capture =="
scripts/capture-jfr.sh "$PID"
# docs/output/02 through 10 are written by hand from the jfr print/summary
# output of recordings/live-demo.jfr and the comparison recordings below;
# regenerate them manually if the workload or JDK version changes.
echo "== threshold-comparison recordings (docs/output/07, 08) =="
jcmd "$PID" JFR.start name=soloDefault settings=default
for i in $(seq 1 40); do curl -s "localhost:8080/api/lock/contend?workers=2&holdMillis=12" -o /dev/null; done
jcmd "$PID" JFR.stop name=soloDefault filename="$(pwd)/recordings/solo-default.jfr"
jcmd "$PID" JFR.start name=soloProfile settings=profile
for i in $(seq 1 40); do curl -s "localhost:8080/api/lock/contend?workers=2&holdMillis=12" -o /dev/null; done
jcmd "$PID" JFR.stop name=soloProfile filename="$(pwd)/recordings/solo-profile.jfr"
jcmd "$PID" JFR.start name=soloDefault2 settings=default
for i in $(seq 1 10); do curl -s "localhost:8080/api/lock/contend?workers=2&holdMillis=35" -o /dev/null; done
jcmd "$PID" JFR.stop name=soloDefault2 filename="$(pwd)/recordings/solo-default-longhold.jfr"
jcmd "$PID" JFR.start name=cmpA settings=default
jcmd "$PID" JFR.start name=cmpB settings=profile
for i in $(seq 1 40); do curl -s "localhost:8080/api/lock/contend?workers=2&holdMillis=12" -o /dev/null; done
jcmd "$PID" JFR.stop name=cmpA filename="$(pwd)/recordings/compare-default.jfr"
jcmd "$PID" JFR.stop name=cmpB filename="$(pwd)/recordings/compare-profile.jfr"
for p in $(ps -eo pid,cmd | grep '[j]fr-demo.jar' | awk '{print $1}'); do kill -9 "$p"; done
echo "all recordings regenerated under recordings/"