diff options
Diffstat (limited to 'tcwg_bmk-build.sh')
-rwxr-xr-x | tcwg_bmk-build.sh | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/tcwg_bmk-build.sh b/tcwg_bmk-build.sh new file mode 100755 index 00000000..bd4eb565 --- /dev/null +++ b/tcwg_bmk-build.sh @@ -0,0 +1,206 @@ +#!/bin/bash + +set -euf -o pipefail + +scripts=$(dirname $0) +. $scripts/jenkins-helpers.sh +. $scripts/round-robin.sh + +convert_args_to_variables "$@" + +obligatory_variables rr[ci_config] ssh_host ssh_port + +# Execution mode: baseline, bisect, jenkins-full +rr[mode]="${rr[mode]-baseline}" + +# Set custom revision for one of the projects, and use baseline revisions +# for all other projects. +rr[ci_project]="${rr[ci_project]-tcwg_bmk}" +rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${rr[ci_config]}}" +rr[reset_baseline]="${rr[reset_baseline]-false}" +rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}" + +# {toolchain_name}-{toolchain_ver}-{target}-{bmk}-{cflags} +IFS=- read -a ci_config <<EOF +${rr[ci_config]} +EOF +rr[toolchain]=${rr[toolchain]-${ci_config[0]}} +rr[target]=${rr[target]-${ci_config[2]}} +cflags=${cflags-${ci_config[4]}} + +case "${rr[toolchain]}" in + llvm) rr[components]="binutils gcc glibc llvm" ;; + gnu) rr[components]="binutils gcc glibc" ;; + *) assert false ;; +esac + +# Use baseline branches by default. +for c in ${rr[components]}; do + rr[${c}_branch]=${rr[${c}_branch]-baseline} + obligatory_variables rr[${c}_url] +done + +start_at="${start_at-default}" +finish_at="${finish_at-default}" +verbose="${verbose-true}" +verbose2="${verbose2-false}" + +if $verbose2; then set -x; fi + +trap "eval \"echo ERROR at \${FUNCNAME[0]}:\${BASH_LINENO[0]}\"" EXIT + +# Set start and finish steps for different modes. +default_start_at="" +default_finish_at="" +case "${rr[mode]}" in + "baseline") + default_finish_at="update_baseline" + ;; + "bisect") + case "$(print_single_updated_component)" in + binutils) default_start_at="build_abe-binutils" ;; + gcc) default_start_at="build_abe-stage1" ;; + glibc) default_start_at="build_abe-glibc" ;; + llvm) default_start_at="build_llvm-true" ;; + *) assert false ;; + esac + default_finish_at="check_regression" + ;; + "jenkins-full") ;; +esac +if [ x"$start_at" = x"default" ]; then + start_at="$default_start_at" +fi +if [ x"$finish_at" = x"default" ]; then + finish_at="$default_finish_at" +fi + +run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose" + +benchmark () +{ + ( + set -euf -o pipefail + + rm -rf $(pwd)/bin + mkdir $(pwd)/bin + + local bmk_flags + bmk_flags="$(echo -$cflags | sed -e "s/_/ -/g" -e "s/LTO/flto/g")" + case "$cflags" in + "Os*"|"Oz*") + # Use static linking for size benchmarking to pickup library + # code size increases in the final executable. + bmk_flags="$bmk_flags -static" + ;; + esac + + local bench_list bin cc gnu_target sysroot + gnu_target=$(print_gnu_target ${rr[target]}) + sysroot="$(pwd)/abe/sysroots/$gnu_target" + case "${rr[toolchain]}" in + llvm) + bench_list="c_and_cxx" + bmk_flags="$bmk_flags --target=$gnu_target --sysroot=$sysroot" + bin="$(pwd)/llvm-install/bin" + cc="$bin/" + ;; + gnu) + bench_list="all" + bin="$(pwd)/abe/builds/destdir/x86_64-unknown-linux-gnu/bin" + cc="$bin/$gnu_target-" + ;; + esac + sysroot="ssh://$ssh_host:$ssh_port:$sysroot" + + local hw results_id + case "${rr[target]}" in + arm*) hw=tk1 ;; + *) hw=tx1 ;; + esac + local results_id="@hw_type@/${rr[ci_project]}/${rr[ci_config]}-@build_num@" + + remote_exec "ci.linaro.org:2222::-l $USER@linaro.org" \ + build tcwg-benchmark -s -v \ + -p bench_list="$bench_list" \ + -p cflags="$bmk_flags" \ + -p testmode=benchmark \ + -p displaytag="${rr[mode]}-${rr[ci_config]}" \ + -p toolchain_url=ssh://$ssh_host:$ssh_port:$cc \ + -p toolchain_type=${rr[toolchain]} \ + -p sysroot="$sysroot" \ + -p results_id="$results_id" \ + -p target_list="$hw" \ + ${scripts_branch+-p scripts_branch="$scripts_branch"} \ + ${bmk_branch+-p bmk_branch="$bmk_branch"} \ + | tee $run_step_artifacts/benchmark.log + local build_num + build_num=$(tail -n1 $run_step_artifacts/benchmark.log \ + | grep SUCCESS \ + | sed -e "s/.*#\([0-9]\+\)-.*/\1/") + + echo "$results_id" | sed -e "s/@build_num@/$build_num/g" \ + > "${rr[top_artifacts]}/results_id" + ) +} + +# Exit with code 0 if no regression compared to base-artifacts/results. +no_regression_p () +{ + ( + set -euf -o pipefail + + if ! [ -f base-artifacts/results ]; then + return 0 + fi + + local build_result_ref build_result_new + build_result_ref=$(tail -n1 base-artifacts/results) + build_result_new=$(tail -n1 ${rr[top_artifacts]}/results) + + if [ $build_result_new -lt $build_result_ref ]; then + return 1 + fi + + if ! [ -f base-artifacts/results_id ]; then + return 0 + elif ! [ -f ${rr[top_artifacts]}/results_id ]; then + return 1 + fi + + local results_ref results_new + results_ref=$(cat base-artifacts/results_id) + results_new=$(cat ${rr[top_artifacts]}/results_id) + + $scripts/tcwg-benchmark-results.sh --results_ref $results_ref --results_id $results_new --top_artifacts "${rr[top_artifacts]}" --verbose $verbose + + # Skip header line + tail -n +2 ${rr[top_artifacts]}/results.csv | \ + while IFS=, read -r bmk symbol speed size; do + # Skip case where we have no info ("n/a") + if [ "$size" != "n/a" ]; then + if [ "$size" -gt 100 ]; then + echo "Regression in bench $bmk, symbol $symbol size increased ($size vs 100)" + return 1 + fi + fi + done + ) +} + +run_step stop_on_fail -10 reset_artifacts +run_step stop_on_fail x prepare_abe +run_step skip_on_fail -9 build_abe binutils +run_step skip_on_fail -8 build_abe stage1 +run_step skip_on_fail -7 build_abe linux +run_step skip_on_fail -6 build_abe glibc +run_step skip_on_fail -5 build_abe stage2 +case "${rr[toolchain]}" in + llvm) run_step skip_on_fail -1 build_llvm true ;; +esac +run_step skip_on_fail 0 benchmark +run_step reset_on_fail x check_regression +run_step stop_on_fail x update_baseline +run_step stop_on_fail x push_baseline + +trap "" EXIT |