Skip to content

Commit df592fe

Browse files
committed
fix: resolve profiler baseline args and improve failure logs
1 parent 9732c4e commit df592fe

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

ci/run_single_test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ case ${TEST_TYPE} in
113113
pip install -e .
114114

115115
PACKAGE_NAME=$(basename $(pwd))
116-
PROFILER_SCRIPT="../../scripts/import_profiler/profiler.py"
116+
# Save the new profiler script to /tmp so we don't lose it during HEAD^1 checkout
117+
cp ../../scripts/import_profiler/profiler.py /tmp/profiler.py
118+
PROFILER_SCRIPT="/tmp/profiler.py"
117119

118120
rm -f /tmp/baseline.csv
119121
if [ -n "${TARGET_BRANCH}" ]; then

scripts/import_profiler/profiler.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,15 @@ def run_master(iterations, target_module, cpu=0, csv_path=None, clear_cache=True
229229
rss_memories, p50_rss, p90_rss, p99_rss
230230
)
231231

232+
exit_code = 0
233+
final_messages = []
234+
232235
if fail_threshold is not None:
233236
if p99_time > fail_threshold:
234-
print(f"\nFAILURE: P99 import time ({p99_time:.2f} ms) exceeds the failure threshold ({fail_threshold} ms).", file=sys.stderr)
235-
sys.exit(1)
237+
final_messages.append(f"FAILURE: P99 import time ({p99_time:.2f} ms) exceeds the failure threshold ({fail_threshold} ms).")
238+
exit_code = 1
236239
else:
237-
print(f"\nSUCCESS: P99 import time ({p99_time:.2f} ms) is within the failure threshold ({fail_threshold} ms).")
240+
final_messages.append(f"SUCCESS: P99 import time ({p99_time:.2f} ms) is within the failure threshold ({fail_threshold} ms).")
238241

239242
if diff_baseline:
240243
if os.path.exists(diff_baseline):
@@ -246,18 +249,32 @@ def run_master(iterations, target_module, cpu=0, csv_path=None, clear_cache=True
246249
baseline_times.append(float(row[1]))
247250
_, _, baseline_p99 = _calculate_percentiles(baseline_times)
248251
diff = p99_time - baseline_p99
249-
print("\n--- Diff vs Baseline ---")
250-
print(f"Baseline P99: {baseline_p99:.2f} ms")
251-
print(f"Current P99: {p99_time:.2f} ms")
252-
print(f"Difference: {diff:+.2f} ms")
252+
253+
diff_msg = (
254+
f"--- Diff vs Baseline ---\n"
255+
f"Baseline P99: {baseline_p99:.2f} ms\n"
256+
f"Current P99: {p99_time:.2f} ms\n"
257+
f"Difference: {diff:+.2f} ms"
258+
)
259+
final_messages.append(diff_msg)
253260

254261
if diff > diff_threshold:
255-
print(f"FAILURE: Import time regression of {diff:.2f} ms exceeds the allowed threshold of {diff_threshold} ms.", file=sys.stderr)
256-
sys.exit(1)
262+
final_messages.append(f"FAILURE: Import time regression of {diff:.2f} ms exceeds the allowed threshold of {diff_threshold} ms.")
263+
exit_code = 1
257264
else:
258-
print("SUCCESS: Import time diff is within acceptable thresholds.")
265+
final_messages.append("SUCCESS: Import time diff is within acceptable thresholds.")
259266
else:
260-
print(f"WARNING: Baseline CSV {diff_baseline} not found. Skipping diff check.")
267+
final_messages.append(f"WARNING: Baseline CSV {diff_baseline} not found. Skipping diff check.")
268+
269+
if final_messages:
270+
print("\n" + "\n".join(final_messages))
271+
272+
if exit_code == 0:
273+
print("\nSession import_profiler was successful.")
274+
sys.exit(0)
275+
else:
276+
print("\nSession import_profiler was failed.")
277+
sys.exit(1)
261278

262279

263280
def run_trace(target_module):

0 commit comments

Comments
 (0)