#!/usr/bin/env bash # The training runs: one per cache flavour. Prints how long each took, how big the artifact is, and what the # JVM logged at warning level while writing it. Needs scripts/prepare.sh to have run. source "$(dirname "$0")/lib.sh" exercise() { # the traffic a "real" training run sends: success, validation failure, 404, actuator for i in 1 2 3 4 5; do post_order >/dev/null; done get_order >/dev/null curl -s -o /dev/null -H 'Content-Type: application/json' -d '{"customer":"bad","sku":"x","quantity":0}' "localhost:$PORT/orders" curl -s -o /dev/null "localhost:$PORT/orders/99" curl -s -o /dev/null "localhost:$PORT/actuator/health" } report() { # label file t0 printf '%-34s %6d ms %s (%s MB)\n' "$1" $(( $(now_ms) - $3 )) "$(basename "$2")" "$(( $(stat -c %s "$2") / 1048576 ))" } echo "# training runs (JDK 25.0.4.1 unless noted); wall time includes JVM start, context start and cache creation" t0=$(now_ms) ( cd "$WORK/ext" && "$JDK25/bin/java" -XX:ArchiveClassesAtExit="$WORK/appcds.jsa" -Dspring.context.exit=onRefresh -jar app.jar ) > "$WORK/train-appcds.log" 2>&1 report "AppCDS (ArchiveClassesAtExit)" "$WORK/appcds.jsa" $t0 t0=$(now_ms) "$JDK25/bin/java" -XX:AOTCacheOutput="$WORK/fat.aot" -Dspring.context.exit=onRefresh -jar "$WORK/app.jar" > "$WORK/train-fat.log" 2>&1 report "AOT cache, fat jar, context-only" "$WORK/fat.aot" $t0 t0=$(now_ms) ( cd "$WORK/ext" && "$JDK25/bin/java" -XX:AOTCacheOutput="$WORK/refresh.aot" -Dspring.context.exit=onRefresh -jar app.jar ) > "$WORK/train-refresh.log" 2>&1 report "AOT cache, context-only training" "$WORK/refresh.aot" $t0 t0=$(now_ms) start_app "$WORK/ext" "$WORK/train-traffic.log" "$JDK25/bin/java" -XX:AOTCacheOutput="$WORK/traffic.aot" -jar app.jar --server.port=$PORT wait_ready && exercise kill -TERM "$APP_PID"; wait "$APP_PID" 2>/dev/null report "AOT cache, traffic training" "$WORK/traffic.aot" $t0 t0=$(now_ms) ( cd "$WORK/ext-springaot" && "$JDK25/bin/java" -Dspring.aot.enabled=true -XX:AOTCacheOutput="$WORK/springaot.aot" -Dspring.context.exit=onRefresh -jar app.jar ) > "$WORK/train-springaot.log" 2>&1 report "AOT cache + Spring AOT, context-only" "$WORK/springaot.aot" $t0 t0=$(now_ms) start_app "$WORK/ext-springaot" "$WORK/train-springaot-traffic.log" "$JDK25/bin/java" -Dspring.aot.enabled=true -XX:AOTCacheOutput="$WORK/springaot-traffic.aot" -jar app.jar --server.port=$PORT wait_ready && exercise kill -TERM "$APP_PID"; wait "$APP_PID" 2>/dev/null report "AOT cache + Spring AOT, traffic" "$WORK/springaot-traffic.aot" $t0 t0=$(now_ms) ( cd "$WORK/ext" && "$JDK27/bin/java" -XX:AOTCacheOutput="$WORK/refresh27.aot" -Dspring.context.exit=onRefresh -jar app.jar ) > "$WORK/train-refresh27.log" 2>&1 report "AOT cache on JDK 27, context-only" "$WORK/refresh27.aot" $t0 t0=$(now_ms) ( cd "$WORK/ext" && "$JDK27/bin/java" -XX:+UseZGC -XX:AOTCacheOutput="$WORK/zgc27.aot" -Dspring.context.exit=onRefresh -jar app.jar ) > "$WORK/train-zgc27.log" 2>&1 report "AOT cache on JDK 27, trained under ZGC" "$WORK/zgc27.aot" $t0 echo echo "# what the JVM said at warning level while writing the context-only AOT cache (count, then the distinct kinds)" grep -c '\[warning\]\[aot\]' "$WORK/train-refresh.log" | sed 's/^/warning lines: /' grep '\[warning\]\[aot\]' "$WORK/train-refresh.log" | sed -E 's/^\[[0-9.]+s\]//; s/(Skipping) [^ ]+:/\1 :/' | sort | uniq -c | sort -rn | head -5