-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun-benchmarks.sh
More file actions
209 lines (171 loc) · 6.37 KB
/
Copy pathrun-benchmarks.sh
File metadata and controls
209 lines (171 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# Aether Datafixers - Production Benchmark Suite
# =============================================================================
# Runs all JMH benchmarks with production-quality settings on a dedicated VM.
# Expected total runtime: ~4-8 hours depending on hardware.
#
# Usage:
# chmod +x run-benchmarks.sh
# nohup ./run-benchmarks.sh > benchmark-run.log 2>&1 &
#
# Prerequisites:
# - Java 17+ (JAVA_HOME set or java on PATH)
# - Maven 3.9.5+
# - Git (for commit hash capture)
# =============================================================================
# --- Configuration -----------------------------------------------------------
WARMUP_ITERATIONS=5
MEASUREMENT_ITERATIONS=10
FORKS=3
JVM_ARGS="-Xms4G -Xmx4G -XX:+UseG1GC -XX:+AlwaysPreTouch"
RESULT_DIR="benchmark-results"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
RUN_DIR="${RESULT_DIR}/${TIMESTAMP}"
JAR_PATTERN="aether-datafixers-benchmarks/target/aether-datafixers-benchmarks-*-benchmarks.jar"
COMMON_ARGS="-wi ${WARMUP_ITERATIONS} -i ${MEASUREMENT_ITERATIONS} -f ${FORKS} -jvmArgs \"${JVM_ARGS}\""
# --- Helper Functions --------------------------------------------------------
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
die() {
log "ERROR: $*" >&2
exit 1
}
run_benchmark() {
local name="$1"
local pattern="$2"
local extra_args="${3:-}"
local output_file="${RUN_DIR}/${name}.json"
log "=== Starting: ${name} ==="
log "Pattern: ${pattern}"
log "Output: ${output_file}"
local start_time=$(date +%s)
java -jar "${JAR}" \
"${pattern}" \
-wi ${WARMUP_ITERATIONS} \
-i ${MEASUREMENT_ITERATIONS} \
-f ${FORKS} \
-jvmArgs "${JVM_ARGS}" \
-rf json \
-rff "${output_file}" \
${extra_args} \
2>&1 | tee "${RUN_DIR}/logs/${name}.log"
local exit_code=${PIPESTATUS[0]}
local end_time=$(date +%s)
local duration=$(( end_time - start_time ))
local minutes=$(( duration / 60 ))
local seconds=$(( duration % 60 ))
if [ ${exit_code} -eq 0 ]; then
log "=== Completed: ${name} in ${minutes}m ${seconds}s ==="
else
log "=== FAILED: ${name} after ${minutes}m ${seconds}s (exit code: ${exit_code}) ==="
fi
echo "${name},${exit_code},${duration}" >> "${RUN_DIR}/timing.csv"
return ${exit_code}
}
# --- Pre-flight Checks -------------------------------------------------------
log "============================================="
log "Aether Datafixers Benchmark Suite"
log "============================================="
# Check Java
java -version 2>&1 || die "Java not found. Install Java 17+ and set JAVA_HOME."
JAVA_VERSION=$(java -version 2>&1 | head -1)
log "Java: ${JAVA_VERSION}"
# Check Maven
mvn --version 2>&1 | head -1 || die "Maven not found."
MVN_VERSION=$(mvn --version 2>&1 | head -1)
log "Maven: ${MVN_VERSION}"
# --- Build -------------------------------------------------------------------
log "Building project..."
mvn clean package -DskipTests -q || die "Build failed."
log "Build successful."
# Resolve JAR path
JAR=$(ls ${JAR_PATTERN} 2>/dev/null | head -1)
[ -f "${JAR}" ] || die "Benchmark JAR not found at ${JAR_PATTERN}"
log "JAR: ${JAR}"
# --- Setup Results Directory -------------------------------------------------
mkdir -p "${RUN_DIR}/logs"
# --- Capture System Info -----------------------------------------------------
log "Capturing system info..."
{
echo "=== Benchmark Run: ${TIMESTAMP} ==="
echo ""
echo "--- Java ---"
java -version 2>&1
echo ""
echo "--- OS ---"
uname -a
echo ""
echo "--- CPU ---"
if [ -f /proc/cpuinfo ]; then
grep "model name" /proc/cpuinfo | head -1
echo "Cores: $(nproc)"
else
echo "CPU info not available"
fi
echo ""
echo "--- Memory ---"
if command -v free &> /dev/null; then
free -h
else
echo "Memory info not available"
fi
echo ""
echo "--- Git ---"
echo "Branch: $(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'unknown')"
echo "Commit: $(git rev-parse HEAD 2>/dev/null || echo 'unknown')"
echo "Dirty: $(git status --porcelain 2>/dev/null | wc -l) files"
echo ""
echo "--- JMH Settings ---"
echo "Warmup iterations: ${WARMUP_ITERATIONS}"
echo "Measurement iterations: ${MEASUREMENT_ITERATIONS}"
echo "Forks: ${FORKS}"
echo "JVM args: ${JVM_ARGS}"
} > "${RUN_DIR}/system-info.txt"
# --- Timing CSV Header -------------------------------------------------------
echo "benchmark,exit_code,duration_seconds" > "${RUN_DIR}/timing.csv"
# --- Run Benchmarks ----------------------------------------------------------
SUITE_START=$(date +%s)
FAILED=0
# 1. Core Benchmarks
# SingleFix, MultiFixChain, SchemaLookup across SMALL/MEDIUM/LARGE payloads
run_benchmark "core" ".*benchmarks.core.*" || FAILED=$((FAILED + 1))
# 2. Format Benchmarks
# Gson vs Jackson JSON, SnakeYAML vs Jackson YAML, TOML, XML
run_benchmark "format" ".*benchmarks.format.*" || FAILED=$((FAILED + 1))
# 3. Codec Benchmarks
# Primitive and Collection encode/decode across all formats
run_benchmark "codec" ".*benchmarks.codec.*" || FAILED=$((FAILED + 1))
# 4. Concurrent Benchmarks
# Multi-threaded migration performance and scalability
run_benchmark "concurrent" ".*benchmarks.concurrent.*" || FAILED=$((FAILED + 1))
# --- Summary -----------------------------------------------------------------
SUITE_END=$(date +%s)
SUITE_DURATION=$(( SUITE_END - SUITE_START ))
SUITE_HOURS=$(( SUITE_DURATION / 3600 ))
SUITE_MINUTES=$(( (SUITE_DURATION % 3600) / 60 ))
log "============================================="
log "Benchmark Suite Complete"
log "Total time: ${SUITE_HOURS}h ${SUITE_MINUTES}m"
log "Failed: ${FAILED}/4"
log "Results in: ${RUN_DIR}/"
log "============================================="
# Write summary
{
echo ""
echo "=== Summary ==="
echo "Total duration: ${SUITE_HOURS}h ${SUITE_MINUTES}m (${SUITE_DURATION}s)"
echo "Failed suites: ${FAILED}/4"
echo ""
echo "--- Timing ---"
cat "${RUN_DIR}/timing.csv"
echo ""
echo "--- Result Files ---"
ls -lh "${RUN_DIR}"/*.json 2>/dev/null || echo "No JSON result files found"
} >> "${RUN_DIR}/system-info.txt"
# List result files
log "Result files:"
ls -lh "${RUN_DIR}"/*.json 2>/dev/null
exit ${FAILED}