Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7h4ZNF4BDUpJk3Zou
53 lines
2.6 KiB
Bash
Executable File
53 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Sourced by run-all.sh (or run directly). Measures startup, throughput, latency and RSS for
|
|
# the same endpoints under six configurations. Everything shares two vCPUs, so read the result
|
|
# as "relative cost on this box", not as production numbers.
|
|
set -euo pipefail
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
trap cleanup EXIT
|
|
mkdir -p "$OUT"
|
|
F="$OUT/08-overhead.txt"
|
|
THREADS=4 WARM=5000 N=8000 ROUNDS=3
|
|
AGENT_METHODS='com.ankurm.otelcmp.PricingService[price];com.ankurm.otelcmp.AuditService[write]'
|
|
|
|
{
|
|
echo "# 08 Overhead: same jar family, same endpoints, $THREADS client threads, $WARM warm-up + $N measured requests x $ROUNDS rounds"
|
|
echo "# JDK $(java -version 2>&1 | awk -F'"' '/version/{print $2}'), $(nproc) vCPU shared by app, OTLP sink and load driver. Indicative only."
|
|
} > "$F"
|
|
|
|
# utime+stime of a process, in clock ticks (100 per second)
|
|
cpu_ticks() { awk '{print $14 + $15}' "/proc/$1/stat"; }
|
|
|
|
run_cfg() {
|
|
local label="$1" jar="$2"; shift 2
|
|
curl -s -X POST localhost:$SINK_PORT/reset >/dev/null
|
|
start_app "$jar" "$@"
|
|
sleep 4
|
|
{
|
|
echo; echo "== $label"
|
|
echo "CPU consumed by the JVM from process start to ready (+4 s idle): $(( $(cpu_ticks "$APP_PID") * 10 )) ms"
|
|
grep -o 'Started OrdersApplication in .*' $TMPD/app.log | sed 's/)$//; s/$/)/' | head -1
|
|
for ep in ping orders/1; do
|
|
echo "-- GET /$ep"
|
|
java "$ROOT/driver/LoadDriver.java" "http://localhost:$APP_PORT/$ep" $WARM 0 $THREADS 0 >/dev/null 2>&1
|
|
local c0 c1
|
|
c0=$(cpu_ticks "$APP_PID")
|
|
java "$ROOT/driver/LoadDriver.java" "http://localhost:$APP_PORT/$ep" 0 $N $THREADS $ROUNDS 2>&1 | grep -v 'Picked up'
|
|
c1=$(cpu_ticks "$APP_PID")
|
|
echo "app CPU per request: $(( (c1 - c0) * 10000 / (N * ROUNDS) )) us (utime+stime of the app JVM only, $(( N * ROUNDS )) requests)"
|
|
done
|
|
echo "-- RSS after the run: $(( $(ps -o rss= -p "$APP_PID") / 1024 )) MiB"
|
|
} >> "$F"
|
|
stop_app
|
|
}
|
|
|
|
start_sink
|
|
run_cfg "baseline: plain jar, no instrumentation" plain
|
|
run_cfg "agent, all spans sampled" plain "${AGENT_PROPS[@]}" -Dotel.instrumentation.methods.include="$AGENT_METHODS"
|
|
run_cfg "micrometer starter, all spans sampled" micrometer "${MICROMETER_PROPS[@]}"
|
|
run_cfg "agent, 10% sampling" plain "${AGENT_PROPS[@]}" -Dotel.instrumentation.methods.include="$AGENT_METHODS" -Dotel.traces.sampler=parentbased_traceidratio -Dotel.traces.sampler.arg=0.1
|
|
run_cfg "micrometer starter, 10% sampling" micrometer "${MICROMETER_PROPS[@]}" -Dmanagement.tracing.sampling.probability=0.1
|
|
run_cfg "micrometer starter + JDBC observation, all spans sampled" micrometer-jdbc "${MICROMETER_PROPS[@]}"
|
|
stop_sink
|
|
echo "overhead written to $F"
|