From 1bfa845a1309b3c09f63741b5202a1f54b3e31d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Marie=20P=C3=A9drot?= Date: Sat, 5 Dec 2026 00:19:03 +0100 Subject: [PATCH 1/2] Recover per-file timings from profiles in dune-based bench packages. Packages built with dune do not print the TIMED=1 lines that make-both-time-files.py expects, so their perfile_timings logs were empty. Compute the real time of each file from the process event of the .vo.prof.json files written thanks to ROCQ_PROFILE_FILE, after each iteration, and feed it to the per-file comparison. --- dev/bench/bench.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/dev/bench/bench.sh b/dev/bench/bench.sh index c9b898fb6476..47a8e063099e 100755 --- a/dev/bench/bench.sh +++ b/dev/bench/bench.sh @@ -479,6 +479,12 @@ format_vosize() { echo "$1 $old $new $diff $diffpercent%" } +prof_json_timings() { + find "$1" -name '*.vo.prof.json' | while read -r prof; do + awk -v vo="${prof%.prof.json}" '/"name": "process"/ { t = $0; sub(/.*"ts": /, "", t); sub(/,.*/, "", t); if (/"ph": "B"/) b = t; else if (/"ph": "E"/) e = t } END { if (b != "" && e != "") printf "%s (real: %.2f)\n", vo, (e - b) / 1e6 }' "$prof" + done +} + # -------------------------------------------------------------------------------- # Measure the compilation times of the specified OPAM packages in both switches @@ -601,6 +607,13 @@ $coq_opam_package (dependency install failed in $RUNNER)" echo $_RES > $log_dir/$coq_opam_package.$RUNNER.opam_install.$iteration.exit_status # "opam install" was successful. + prof_timings=$log_dir/$coq_opam_package.$RUNNER.opam_install.$iteration.prof_timings.log + if grep -q ' (real: ' $log_dir/$coq_opam_package.$RUNNER.opam_install.$iteration.stdout.log; then + : > "$prof_timings" + else + prof_json_timings "$(echo "$OPAMROOT/ocaml-$RUNNER/.opam-switch/build/${coq_opam_package%%.*}".*/)" > "$prof_timings" + fi + # Remove the benchmarked OPAM-package, unless this is the # very last iteration (we want to keep this OPAM-package # because other OPAM-packages we will benchmark later @@ -680,8 +693,8 @@ $skipped_packages" # opam logs prefix the printing with "- " so remove that # remove the base path for nicer printing and so the script can identify common files "$program_path"/../../tools/make-both-time-files.py --real \ - <(sed -e 's/^- //' -e "s:$new_base_path::" "$log_dir/$coq_opam_package.NEW.opam_install.$iteration.stdout.log") \ - <(sed -e 's/^- //' -e "s:$old_base_path::" "$log_dir/$coq_opam_package.OLD.opam_install.$iteration.stdout.log") \ + <(sed -e 's/^- //' -e "s:$new_base_path::" "$log_dir/$coq_opam_package.NEW.opam_install.$iteration.stdout.log" "$log_dir/$coq_opam_package.NEW.opam_install.$iteration.prof_timings.log") \ + <(sed -e 's/^- //' -e "s:$old_base_path::" "$log_dir/$coq_opam_package.OLD.opam_install.$iteration.stdout.log" "$log_dir/$coq_opam_package.OLD.opam_install.$iteration.prof_timings.log") \ > "$log_dir/$coq_opam_package.BOTH.perfile_timings.$iteration.log" done @@ -752,8 +765,8 @@ new_base_path=$new_opam_root/ocaml-NEW/.opam-switch/build/ old_base_path=$old_opam_root/ocaml-OLD/.opam-switch/build/ for iteration in $(seq $num_of_iterations); do "$program_path"/../../tools/make-both-time-files.py --real \ - <(sed -e 's/^- //' -e "s:$new_base_path::" "$log_dir/"*".NEW.opam_install.$iteration.stdout.log") \ - <(sed -e 's/^- //' -e "s:$old_base_path::" "$log_dir/"*".OLD.opam_install.$iteration.stdout.log") \ + <(sed -e 's/^- //' -e "s:$new_base_path::" "$log_dir/"*".NEW.opam_install.$iteration.stdout.log" "$log_dir/"*".NEW.opam_install.$iteration.prof_timings.log") \ + <(sed -e 's/^- //' -e "s:$old_base_path::" "$log_dir/"*".OLD.opam_install.$iteration.stdout.log" "$log_dir/"*".OLD.opam_install.$iteration.prof_timings.log") \ > "$log_dir/ALL.BOTH.perfile_timings.$iteration.log" done From 7b16b5c905b3e4c010a463a3f466641474c21da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Marie=20P=C3=A9drot?= Date: Sat, 5 Dec 2026 12:47:11 +0100 Subject: [PATCH 2/2] Use jq rather than awk to read bench profiles. --- dev/bench/bench.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/bench/bench.sh b/dev/bench/bench.sh index 47a8e063099e..06d0cc917b1b 100755 --- a/dev/bench/bench.sh +++ b/dev/bench/bench.sh @@ -481,7 +481,7 @@ format_vosize() { prof_json_timings() { find "$1" -name '*.vo.prof.json' | while read -r prof; do - awk -v vo="${prof%.prof.json}" '/"name": "process"/ { t = $0; sub(/.*"ts": /, "", t); sub(/,.*/, "", t); if (/"ph": "B"/) b = t; else if (/"ph": "E"/) e = t } END { if (b != "" && e != "") printf "%s (real: %.2f)\n", vo, (e - b) / 1e6 }' "$prof" + jq -r --arg vo "${prof%.prof.json}" '[.traceEvents[] | select(.name == "process") | {(.ph): .ts}] | add | ((.E - .B) / 1e4 | round) as $cs | "\($vo) (real: \($cs / 100 | floor).\($cs % 100 | tostring | if length < 2 then "0" + . else . end))"' "$prof" || true done }