Add crac module: Spring Boot 4.2 started by CRaC checkpoint/restore vs JDK AOT cache vs native image

One service, seven start-up configurations measured over ten interleaved rounds on Temurin 25, Zulu 25 CRaC and Oracle GraalVM 25;
the open-file checkpoint failure and its fix, stale environment values, secrets in the checkpoint, warp and CRIU engines, cold page cache.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b5uEyg58znuchZ8C8i
This commit is contained in:
asmhatre
2026-11-29 13:51:08 +05:30
co-authored by Claude Sonnet 5.5
parent de2660e998
commit c0062ea398
33 changed files with 882 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Interleaved rounds of every start-up configuration; "ready" = spawn -> first HTTP 200 from GET /ping.
# Needs: build.sh, native.sh, checkpoints.sh already run. Usage: ./scripts/bench.sh [rounds]
source "$(dirname "$0")/lib.sh"
R="${1:-10}"
{ echo "rounds: $R load average before: $(cut -d' ' -f1-3 /proc/loadavg) cpus: $(nproc)"; $TOOL bench "$R" 2>/dev/null; echo "load average after: $(cut -d' ' -f1-3 /proc/loadavg)"; } | tee "$OUT/08-bench.txt"
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Build the jar once and extract it to the layout every start-up variant uses.
set -euo pipefail
source "$(dirname "$0")/env.sh"
cd "$ROOT"
JAVA_HOME="$JDK_PLAIN" PATH="$JDK_PLAIN/bin:$PATH" mvn -B -q -DskipTests clean package
rm -rf "$WORK/app"
run_env "$JDK_PLAIN/bin/java" -Djarmode=tools -jar target/crac-demo-1.0.0.jar extract --destination "$WORK/app"
ls -la "$WORK/app"
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Creates the checkpoints and AOT caches the benchmark restores/uses, and records what it cost.
source "$(dirname "$0")/lib.sh"
cd "$WORK"; : > "$OUT/02-create.txt"
say() { echo "$@" | tee -a "$OUT/02-create.txt"; }
say "== CRaC checkpoint at start-up (-Dspring.context.checkpoint=onRefresh)"
rm -rf cp-refresh; t0=$(now_ms)
run_env "$JDK_CRAC/bin/java" -XX:CRaCCheckpointTo="$WORK/cp-refresh" -Dspring.context.checkpoint=onRefresh -jar "$APPJAR" --server.port=$PORT > refresh.log 2>&1 || true
t1=$(now_ms)
say "process exited after $((t1-t0)) ms; checkpoint dir: $(ls cp-refresh | tr '\n' ' ') size: $(du_mb cp-refresh) MB"
grep -E 'Starting CracDemo|Checkpoint|warp: Checkpoint' refresh.log | grep -v 'always available' | scrub | tee -a "$OUT/02-create.txt"
say; say "== CRaC checkpoint after warm-up (300 POST + 300 GET, then jcmd JDK.checkpoint)"
rm -rf cp-warm
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$JDK_CRAC/bin/java" -XX:CRaCCheckpointTo="$WORK/cp-warm" -jar "$APPJAR" --server.port=$PORT > warm.log 2>&1 < /dev/null &
wait_ready || { say "app did not start"; exit 1; }
PID=$(pgrep -f "CRaCCheckpointTo=$WORK/cp-warm" | head -1)
$TOOL traffic "$PORT" 300
t0=$(now_ms); run_env "$JDK_CRAC/bin/jcmd" "$PID" JDK.checkpoint > jcmd.log 2>&1 || true; t1=$(now_ms)
wait_exit "$PID"; t2=$(now_ms)
say "jcmd JDK.checkpoint returned after $((t1-t0)) ms; process gone after $((t2-t0)) ms; checkpoint size: $(du_mb cp-warm) MB"
grep -E 'Spring-managed|Checkpoint|checkpoint|warp: Checkpoint' warm.log | scrub | tee -a "$OUT/02-create.txt"
say; say "== JDK AOT cache (JEP 514), context-only training"
rm -f ctx.aot; t0=$(now_ms)
run_env "$JDK_PLAIN/bin/java" -XX:AOTCacheOutput="$WORK/ctx.aot" -Dspring.context.exit=onRefresh -jar "$APPJAR" --server.port=$PORT > aot-ctx.log 2>&1
say "training took $(( $(now_ms)-t0 )) ms; $(ls -l ctx.aot | awk '{printf "%.0f MB", $5/1048576}')"
say; say "== JDK AOT cache, training with the same 300-request warm-up"
rm -f traffic.aot
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$JDK_PLAIN/bin/java" -XX:AOTCacheOutput="$WORK/traffic.aot" -jar "$APPJAR" --server.port=$PORT > aot-traffic.log 2>&1 < /dev/null &
t0=$(now_ms); wait_ready; PID=$(pgrep -f "AOTCacheOutput=$WORK/traffic.aot" | head -1)
$TOOL traffic "$PORT" 300; kill -TERM "$PID"; wait_exit "$PID"
say "training took $(( $(now_ms)-t0 )) ms; $(ls -l traffic.aot | awk '{printf "%.0f MB", $5/1048576}')"
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# One start per configuration with the Linux page cache emptied first (a freshly pulled container image or a freshly scheduled pod).
# 5 repetitions each, interleaved. Needs root (writes /proc/sys/vm/drop_caches).
source "$(dirname "$0")/lib.sh"
R="${1:-5}"
declare -A res
for r in $(seq 1 "$R"); do
for c in plain-temurin aot-traffic crac-warm native; do
sync; echo 3 > /proc/sys/vm/drop_caches
v=$($TOOL once "$c" | python3 -c 'import json,sys; print(round(json.load(sys.stdin)["ready"]))')
res[$c]="${res[$c]} $v"
done
done
{ echo "ready (ms) after dropping the page cache, $R rounds, interleaved:"; for c in plain-temurin aot-traffic crac-warm native; do echo " $c:${res[$c]}"; done; } | tee "$OUT/09-cold-cache.txt"
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env python3
"""Measurement helper for the CRaC post. Standard library only.
crac_tool.py bench ROUNDS interleaved rounds of every configuration, prints a table
crac_tool.py once LABEL start one configuration, print time to first 200 and first POST
crac_tool.py traffic PORT N send N valid POST /orders and GET /orders/{id} requests (warm-up)
"Ready" = milliseconds from the moment the process is spawned until the first HTTP 200 from GET /ping
(polled every 2 ms from a raw socket, so the poll itself costs almost nothing).
"""
import json, os, signal, socket, statistics, subprocess, sys, time
ENV = {k: v for k, v in os.environ.items() if k not in ("JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS")}
W = os.environ.get("WORK", "/tmp/crac-work")
PORT = int(os.environ.get("PORT", "18771"))
JDK_PLAIN, JDK_CRAC = os.environ["JDK_PLAIN"], os.environ["JDK_CRAC"]
APP = f"{W}/app/crac-demo-1.0.0.jar"
CONFIGS = {
"plain-temurin": [f"{JDK_PLAIN}/bin/java", "-jar", APP, f"--server.port={PORT}"],
"plain-zulu-crac": [f"{JDK_CRAC}/bin/java", "-jar", APP, f"--server.port={PORT}"],
"aot-ctx-only": [f"{JDK_PLAIN}/bin/java", f"-XX:AOTCache={W}/ctx.aot", "-jar", APP, f"--server.port={PORT}"],
"aot-traffic": [f"{JDK_PLAIN}/bin/java", f"-XX:AOTCache={W}/traffic.aot", "-jar", APP, f"--server.port={PORT}"],
"crac-on-refresh": [f"{JDK_CRAC}/bin/java", f"-XX:CRaCRestoreFrom={W}/cp-refresh"],
"crac-warm": [f"{JDK_CRAC}/bin/java", f"-XX:CRaCRestoreFrom={W}/cp-warm"],
"native": [f"{W}/native/crac-demo", f"--server.port={PORT}"],
}
def http(method, path, body=None, timeout=5.0):
s = socket.create_connection(("127.0.0.1", PORT), timeout=timeout)
try:
data = json.dumps(body).encode() if body is not None else b""
hdr = f"{method} {path} HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n"
if body is not None:
hdr += f"Content-Type: application/json\r\nContent-Length: {len(data)}\r\n"
s.sendall(hdr.encode() + b"\r\n" + data)
buf = b""
while True:
c = s.recv(65536)
if not c: break
buf += c
return int(buf.split(b" ", 2)[1]), buf.split(b"\r\n\r\n", 1)[1].decode()
finally:
s.close()
def port_free():
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # TIME_WAIT sockets from the last run must not count as busy
try:
s.bind(("127.0.0.1", PORT)); return True
except OSError:
return False
finally:
s.close()
def session_rss_mb(sid):
best = 0
for pid in os.listdir("/proc"):
if not pid.isdigit(): continue
try:
if os.getsid(int(pid)) != sid: continue
for line in open(f"/proc/{pid}/status"):
if line.startswith("VmRSS:"):
best = max(best, int(line.split()[1]) // 1024)
except (OSError, ProcessLookupError):
pass
return best
def run(label, log=None):
assert port_free(), "port busy"
t0 = time.perf_counter()
p = subprocess.Popen(CONFIGS[label], env=ENV, cwd=W, start_new_session=True,
stdout=open(log or os.devnull, "w"), stderr=subprocess.STDOUT)
ready = None
while time.perf_counter() - t0 < 60:
try:
st, _ = http("GET", "/ping", timeout=1)
if st == 200:
ready = (time.perf_counter() - t0) * 1000; break
except OSError:
time.sleep(0.002)
if ready is None:
kill(p); raise RuntimeError(label + ": not ready")
t1 = time.perf_counter()
st, _ = http("POST", "/orders", {"customer": "ada", "sku": "X-1", "quantity": 2})
first_post = (time.perf_counter() - t1) * 1000
assert st == 201, st
times = []
for i in range(50):
t = time.perf_counter(); http("GET", "/orders/1"); times.append((time.perf_counter() - t) * 1000)
rss = session_rss_mb(p.pid)
kill(p)
return dict(ready=ready, first_post=first_post, next50=statistics.median(times), rss=rss)
def kill(p):
try: os.killpg(p.pid, signal.SIGKILL)
except ProcessLookupError: pass
try: p.wait(5)
except Exception: pass
for _ in range(500):
if port_free(): return
time.sleep(0.01)
def bench(rounds):
res = {k: [] for k in CONFIGS}
for r in range(rounds):
for k in CONFIGS:
res[k].append(run(k)); time.sleep(0.3)
print(f"round {r+1}/{rounds} done", file=sys.stderr)
print(f"{'configuration':<18}{'ready ms (median [min..max])':<34}{'1st POST ms':>12}{'next 50 ms':>12}{'RSS MB':>8}")
for k, rs in res.items():
rd = [x["ready"] for x in rs]
print(f"{k:<18}{statistics.median(rd):>8.0f} [{min(rd):.0f}..{max(rd):.0f}]".ljust(52)
+ f"{statistics.median(x['first_post'] for x in rs):>12.1f}"
+ f"{statistics.median(x['next50'] for x in rs):>12.2f}"
+ f"{statistics.median(x['rss'] for x in rs):>8.0f}")
print("raw ready ms per round:")
for k, rs in res.items():
print(f" {k}: " + " ".join(f"{x['ready']:.0f}" for x in rs))
def traffic(n):
for i in range(n):
st, body = http("POST", "/orders", {"customer": f"c{i%7}", "sku": f"S-{i%13}", "quantity": 1 + i % 5})
assert st == 201, (st, body)
http("GET", f"/orders/{i+1}")
http("POST", "/orders", {"customer": "", "sku": "X", "quantity": 0}) # a 400, so the validation error path is warm
http("GET", "/orders/999999") # a 404
http("GET", "/actuator/health")
if __name__ == "__main__":
cmd = sys.argv[1]
if cmd == "bench": bench(int(sys.argv[2]))
elif cmd == "once": print(json.dumps(run(sys.argv[2], f"{W}/once-{sys.argv[2]}.log")))
elif cmd == "traffic":
PORT = int(sys.argv[2]); traffic(int(sys.argv[3]))
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# The Zulu 25 CRaC JVM ships more than one engine. Which one ran above, and does the CRIU one work in this sandbox?
source "$(dirname "$0")/lib.sh"
cd "$WORK"; J="$JDK_CRAC/bin/java"; : > "$OUT/06-engines.txt"
say() { echo "$@" | tee -a "$OUT/06-engines.txt"; }
say "files in the JDK's lib directory that belong to CRaC:"; ls "$JDK_CRAC/lib" | grep -i -E 'criu|crac|warp|engine' | sed 's/^/ /' | tee -a "$OUT/06-engines.txt"
say; say "== the same flag on the stock Temurin 25 JDK"
run_env "$JDK_PLAIN/bin/java" -XX:CRaCCheckpointTo="$WORK/cp-temurin" -version 2>&1 | head -3 | scrub | tee -a "$OUT/06-engines.txt"
say; say "engine recorded in the default checkpoint (cp-refresh/engine): $(cat cp-refresh/engine 2>/dev/null)"
say "process capabilities (CapEff): $(grep CapEff /proc/self/status | awk '{print $2}'), uid $(id -u)"
for ENG in warp criuengine; do
say; say "== -XX:CRaCEngine=$ENG, checkpoint at start-up then restore"
rm -rf "cp-eng-$ENG"
# CRIU is picky about the process it dumps: a regular file open as stdout must not change size before the restore ("has bad size"),
# a stdin that is a socket fails the dump ("External socket is used"), and a JVM that is not its own session leader cannot be restored
# ("Current gid ... intersects with pid ... in images"). So: new session (setsid), stdin /dev/null, stdout through a pipe (cat).
setsid --wait bash -c "env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS '$J' -XX:CRaCEngine=$ENG -XX:CRaCCheckpointTo='$WORK/cp-eng-$ENG' -Dspring.context.checkpoint=onRefresh -jar '$APPJAR' --server.port=$PORT 2>&1 | cat > 'eng-$ENG-1.log'" < /dev/null
say "checkpoint directory: $(ls cp-eng-$ENG 2>/dev/null | head -3 | tr "\n" " ")($(ls cp-eng-$ENG | wc -l) files); size: $(du -sm cp-eng-$ENG 2>/dev/null | cut -f1) MB"
grep -E 'warp:|criu|CRIU|Error|error:|Checkpoint' "eng-$ENG-1.log" | grep -v 'always available' | scrub | head -8 | tee -a "$OUT/06-engines.txt"
if [ -d "cp-eng-$ENG" ]; then
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$J" -XX:CRaCEngine=$ENG -XX:CRaCRestoreFrom="$WORK/cp-eng-$ENG" > "eng-$ENG-2.log" 2>&1 < /dev/null &
if wait_ready; then say "restored; GET /ping -> $(curl -s localhost:$PORT/ping); $(grep -E 'Restored CracDemo' eng-$ENG-2.log | scrub | sed -E 's/.*: //')"; else say "restore did not become ready"; grep -v '^$' "eng-$ENG-2.log" | scrub | head -6 | tee -a "$OUT/06-engines.txt"; fi
stop_port
fi
done
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Where the JDKs live. Override on the command line, e.g. JDK_CRAC=/opt/zulu-crac ./scripts/run-all.sh
export JDK_PLAIN="${JDK_PLAIN:-/tmp/tools/tem/jdk-25.0.5.1+2}" # Temurin 25.0.5.1 (plain JVM, AOT cache)
export JDK_CRAC="${JDK_CRAC:-/tmp/tools/zulu/zulu25.38.203-ca-crac-jdk25.0.5.1.1-linux_x64}" # Azul Zulu 25 with CRaC
export JDK_GRAAL="${JDK_GRAAL:-/tmp/tools/graal/graalvm-jdk-25.0.4+7.1}" # Oracle GraalVM 25.0.4 (native-image)
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"; export ROOT
export OUT="$ROOT/output"; mkdir -p "$OUT"
export WORK="${WORK:-/tmp/crac-work}"; mkdir -p "$WORK" # checkpoints, caches, logs: not committed
export PORT="${PORT:-18771}"
# The JVM prints "Picked up JAVA_TOOL_OPTIONS" on every launch in some sandboxes; it is noise in a transcript.
# (Maven itself needs the variable in such a sandbox, so only the run scripts clear it, never build.sh.)
run_env() { env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$@"; }
export TOOL="python3 $ROOT/scripts/crac_tool.py"; export JDK_PLAIN JDK_CRAC WORK PORT
+10
View File
@@ -0,0 +1,10 @@
# shared helpers (sourced)
source "$(dirname "${BASH_SOURCE[0]}")/env.sh"
APPJAR="$WORK/app/crac-demo-1.0.0.jar"
wait_ready() { for i in $(seq 1 600); do curl -s -o /dev/null "localhost:$PORT/ping" && return 0; sleep 0.1; done; return 1; }
wait_exit() { for i in $(seq 1 600); do kill -0 "$1" 2>/dev/null || return 0; sleep 0.1; done; return 1; }
now_ms() { echo $(( $(date +%s%N) / 1000000 )); }
du_mb() { du -sm "$1" | cut -f1; }
# keep transcripts free of machine paths and wall-clock dates
scrub() { sed -E "s#$WORK#<work>#g; s#$ROOT#<repo>#g; s#/tmp/tools/[^ /]*/[^ /]*#<jdk>#g; s#^[0-9T:.+-]{29} ##"; }
stop_port() { fuser -k -9 "$PORT/tcp" >/dev/null 2>&1; sleep 0.5; } # kills whatever listens on our (private) port
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Builds the native image with Oracle GraalVM 25 (about 5 to 14 minutes on 2 vCPU; 5 GB peak) and records the build summary.
source "$(dirname "$0")/env.sh"
cd "$ROOT"
S=$(date +%s)
JAVA_HOME="$JDK_GRAAL" PATH="$JDK_GRAAL/bin:$PATH" mvn -B -Pnative -DskipTests native:compile > "$WORK/native-build.log" 2>&1
E=$(( $(date +%s) - S ))
mkdir -p "$WORK/native"; cp target/crac-demo "$WORK/native/"
{ echo "build wall time: ${E} s "; grep -E '^\[[0-9]/8\]|Finished generating|Peak RSS|in .* GCs|types, |Garbage collector|target machine' "$WORK/native-build.log" | sed -E 's/ {3,}/ /g';
echo "binary size: $(du -m "$WORK/native/crac-demo" | cut -f1) MB"; } | tee "$OUT/07-native-build.txt"
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# What happens to open files, environment variables and secrets across a checkpoint.
source "$(dirname "$0")/lib.sh"
cd "$WORK"; stop_port
AUDIT="$WORK/audit.log"
J="$JDK_CRAC/bin/java"
echo "== 1. A file opened in a constructor and never closed (profile 'leaky'), checkpoint at start-up" | tee "$OUT/03-leaky.txt"
rm -rf cp-leaky "$AUDIT"
run_env "$J" -XX:CRaCCheckpointTo="$WORK/cp-leaky" -Dspring.context.checkpoint=onRefresh -jar "$APPJAR" --server.port=$PORT --spring.profiles.active=leaky --demo.audit-file="$AUDIT" > leaky.log 2>&1
echo "java exit code: $?" | tee -a "$OUT/03-leaky.txt"
grep -E 'ERROR|ApplicationContextException|Caused by|CheckpointOpenFileException|Suppressed' leaky.log | scrub | tee -a "$OUT/03-leaky.txt"
echo "checkpoint directory exists: $([ -d cp-leaky ] && echo yes || echo no)" | tee -a "$OUT/03-leaky.txt"
echo | tee -a "$OUT/03-leaky.txt"; echo "== 2. The same mistake, checkpoint requested later with jcmd JDK.checkpoint" | tee -a "$OUT/03-leaky.txt"
rm -rf cp-leaky2 "$AUDIT"
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$J" -XX:CRaCCheckpointTo="$WORK/cp-leaky2" -jar "$APPJAR" --server.port=$PORT --spring.profiles.active=leaky --demo.audit-file="$AUDIT" > leaky2.log 2>&1 < /dev/null &
wait_ready; PID=$(pgrep -f "CRaCCheckpointTo=$WORK/cp-leaky2" | head -1)
run_env "$JDK_CRAC/bin/jcmd" "$PID" JDK.checkpoint 2>&1 | grep -v '^$' | scrub | head -8 | tee -a "$OUT/03-leaky.txt"
sleep 1
echo "application still running and answering: $(curl -s localhost:$PORT/ping)" | tee -a "$OUT/03-leaky.txt"
kill -9 "$PID"; wait_exit "$PID"
echo "== 3. The fix: open in start(), close in stop() (profile 'managed'), checkpoint with jcmd, restore" | tee "$OUT/04-managed.txt"
rm -rf cp-managed "$AUDIT"
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$J" -XX:CRaCCheckpointTo="$WORK/cp-managed" -jar "$APPJAR" --server.port=$PORT --spring.profiles.active=managed --demo.audit-file="$AUDIT" > managed1.log 2>&1 < /dev/null &
wait_ready; PID=$(pgrep -f "CRaCCheckpointTo=$WORK/cp-managed" | head -1)
for i in 1 2 3; do curl -s -o /dev/null -X POST -H 'Content-Type: application/json' -d '{"customer":"ada","sku":"X","quantity":1}' localhost:$PORT/orders; done
echo "orders before checkpoint; audit file has $(wc -l < "$AUDIT") lines" | tee -a "$OUT/04-managed.txt"
run_env "$JDK_CRAC/bin/jcmd" "$PID" JDK.checkpoint > /dev/null 2>&1; wait_exit "$PID"
echo "--- log of the checkpointed process (hooks only)" | tee -a "$OUT/04-managed.txt"
grep -E 'ManagedAuditLog|RestoreTracker|Spring-managed|Stopping|Tomcat' managed1.log | scrub | tee -a "$OUT/04-managed.txt"
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS "$J" -XX:CRaCRestoreFrom="$WORK/cp-managed" > managed2.log 2>&1 < /dev/null &
wait_ready; sleep 0.3
echo "--- log of the restored process (hooks only)" | tee -a "$OUT/04-managed.txt"
grep -E 'ManagedAuditLog|RestoreTracker|Spring-managed|Tomcat|Restored' managed2.log | scrub | tee -a "$OUT/04-managed.txt"
curl -s -o /dev/null -X POST -H 'Content-Type: application/json' -d '{"customer":"ada","sku":"X","quantity":1}' localhost:$PORT/orders
echo "--- after restore: new order (id continues from the checkpointed counter), audit file now has $(wc -l < "$AUDIT") lines:" | tee -a "$OUT/04-managed.txt"
curl -s localhost:$PORT/orders/4 | tee -a "$OUT/04-managed.txt"; echo | tee -a "$OUT/04-managed.txt"
cat "$AUDIT" | tee -a "$OUT/04-managed.txt"
stop_port
echo "== 4. Environment variables and secrets" | tee "$OUT/05-environment.txt"
rm -rf cp-env
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS DEMO_GREETING=value-at-checkpoint-S3CRET-7f3a91 "$J" -XX:CRaCCheckpointTo="$WORK/cp-env" -jar "$APPJAR" --server.port=$PORT > env1.log 2>&1 < /dev/null &
wait_ready; PID=$(pgrep -f "CRaCCheckpointTo=$WORK/cp-env" | head -1)
echo "before checkpoint: $(curl -s localhost:$PORT/info)" | tee -a "$OUT/05-environment.txt"
run_env "$JDK_CRAC/bin/jcmd" "$PID" JDK.checkpoint > /dev/null 2>&1; wait_exit "$PID"
setsid env -u JAVA_TOOL_OPTIONS -u _JAVA_OPTIONS DEMO_GREETING=value-at-restore "$J" -XX:CRaCRestoreFrom="$WORK/cp-env" > env2.log 2>&1 < /dev/null &
wait_ready
echo "restored with DEMO_GREETING=value-at-restore:" | tee -a "$OUT/05-environment.txt"
echo "after restore: $(curl -s localhost:$PORT/info)" | tee -a "$OUT/05-environment.txt"
echo "occurrences of the checkpoint-time value in core.img: $(grep -a -c 'value-at-checkpoint-S3CRET-7f3a91' cp-env/core.img)" | tee -a "$OUT/05-environment.txt"
echo "checkpoint file mode: $(stat -c '%a %U' cp-env/core.img)" | tee -a "$OUT/05-environment.txt"
stop_port
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# Regenerates every file in output/. About 25 minutes on 2 vCPU (the native build alone is 5 to 14 minutes).
# Needs JDK_PLAIN, JDK_CRAC, JDK_GRAAL (see env.sh), Maven, Python 3, curl, and root for cold.sh.
set -euo pipefail
cd "$(dirname "$0")"
./build.sh
./native.sh
./versions.sh
./checkpoints.sh
./resources.sh
./engines.sh
./bench.sh 10
./cold.sh 5
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# What every number in the post was measured on.
source "$(dirname "$0")/lib.sh"
{
echo "== machine"; uname -sr; echo "cpus: $(nproc)"; free -m | awk 'NR==2{print "memory MB: "$2}'
echo; echo "== plain JVM and AOT cache"; run_env "$JDK_PLAIN/bin/java" -version 2>&1 | scrub
echo; echo "== CRaC JVM"; run_env "$JDK_CRAC/bin/java" -version 2>&1 | scrub
echo "engines shipped: $(ls "$JDK_CRAC/lib" | grep -E 'criu|libcriuengine|warp' | tr '\n' ' ')"
echo; echo "== native-image"; run_env "$JDK_GRAAL/bin/native-image" --version 2>&1 | scrub
echo; echo "== Spring"; unzip -p "$WORK/app/lib/spring-boot-4.2.0.jar" META-INF/MANIFEST.MF | grep -E 'Implementation-Version'
ls "$WORK/app/lib" | grep -E '^(spring-(core|context|webmvc|boot)-|crac-|tomcat-embed-core)'
} 2>&1 | tee "$OUT/01-versions.txt"