Skip to content

Commit 0efeb58

Browse files
jbachorikclaude
andcommitted
Fix Java process termination during perf record
Run benchmark in infinite loop to ensure process stays alive for both perf stat and perf record measurements. Add process health checks before each perf operation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 23fcefc commit 0efeb58

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

ddprof-lib/benchmarks/branch-prediction/test_branch_prediction_perf.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ start_benchmark() {
8989
log_info "Starting Renaissance benchmark: ${benchmark}"
9090

9191
# Disable DD Java agent injection to avoid conflicts
92-
# Run many iterations to keep benchmark running during perf measurement
92+
# Run in infinite loop to ensure process stays alive during all perf measurements
93+
# The benchmark will be killed by cleanup when tests complete
9394
env -u JAVA_TOOL_OPTIONS \
94-
java -agentpath:"${PROFILER_LIB}=start,cpu,file=/tmp/test.jfr" \
95+
bash -c "while true; do java -agentpath:\"${PROFILER_LIB}=start,cpu,file=/tmp/test.jfr\" \
9596
-Xmx2g \
9697
-Xms2g \
97-
-jar "${RENAISSANCE_JAR}" \
98-
"${benchmark}" \
99-
-r 9999 \
98+
-jar \"${RENAISSANCE_JAR}\" \
99+
\"${benchmark}\" \
100+
-r 100; done" \
100101
&> /tmp/renaissance_${benchmark}.log &
101102

102103
JAVA_PID=$!
@@ -137,13 +138,25 @@ run_perf_stat() {
137138
2>&1 | tee "${output_file}"
138139

139140
log_info "perf stat results saved to ${output_file}"
141+
142+
# Verify process is still alive
143+
if ! kill -0 ${pid} 2>/dev/null; then
144+
log_error "Process ${pid} died during perf stat. Check /tmp/renaissance_*.log"
145+
return 1
146+
fi
140147
}
141148

142149
# Run perf record for detailed analysis
143150
run_perf_record() {
144151
local pid=$1
145152
local output_file="${2:-perf_record.data}"
146153

154+
# Verify process is still alive before starting
155+
if ! kill -0 ${pid} 2>/dev/null; then
156+
log_error "Process ${pid} is not running, skipping perf record"
157+
return 1
158+
fi
159+
147160
log_info "Running perf record for ${DURATION} seconds..."
148161

149162
perf record -e L1-icache-load-misses,branch-misses \

0 commit comments

Comments
 (0)