From b2d58a3304e60d223b1f7924eb6b96267de17374 Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Mon, 14 Sep 2020 20:38:31 +0200 Subject: [PATCH] save daily perf results (#7396) It's a real shame I forgot to do this sooner, but better late than never I suppose. CHANGELOG_BEGIN CHANGELOG_END --- azure-pipelines.yml | 20 ++++++++------------ ci/bash-lib.yml | 20 ++++++++++++++++++++ ci/cron/daily-compat.yml | 21 +++++++++++++++++---- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 921f1f25bb..184bcf9a1e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -712,10 +712,14 @@ jobs: pr.num: $[ variables['System.PullRequest.PullRequestNumber'] ] pr.branch: $[ variables['System.PullRequest.SourceBranch'] ] steps: + - template: ci/bash-lib.yml + parameters: + var_name: bash_lib - bash: | set -euo pipefail eval "$(./dev-env/bin/dade-assist)" + source $(bash_lib) REPORT=$(mktemp) cat >$REPORT < $REPORT_GZ - GCS_KEY=$(mktemp) - cleanup() { - rm -rf $GCS_KEY - } - trap cleanup EXIT # Application credentials will not be set for forks. We give up on # tracking those for now. "Not set" in Azure world means set to the # expression Azure would otherwise substitute, i.e. the literal value # of the string in the `env:` block below. - if [[ "${GOOGLE_APPLICATION_CREDENTIALS_CONTENT:1:${#GOOGLE_APPLICATION_CREDENTIALS_CONTENT}-1}" != '(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)' ]]; then - echo "$GOOGLE_APPLICATION_CREDENTIALS_CONTENT" > $GCS_KEY - gcloud auth activate-service-account --key-file=$GCS_KEY - BOTO_CONFIG=/dev/null gsutil cp $REPORT_GZ gs://daml-data/builds/$(Build.BuildId)_$(date -u +%Y%m%d_%H%M%SZ).json.gz + if [[ "${GCRED:1:${#GCRED}-1}" != '(GOOGLE_APPLICATION_CREDENTIALS_CONTENT)' ]]; then + save_gcp_data "$GCRED" "$REPORT_GZ" "gs://daml-data/builds/$(Build.BuildId)_$(date -u +%Y%m%d_%H%M%SZ).json.gz" else - echo "Could not save build data: no credentials. Data was:" - cat $REPORT + echo "Could not save build data: no credentials." fi # Linux, macOS and Windows are always required and should always @@ -806,7 +802,7 @@ jobs: exit 1 fi env: - GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) + GCRED: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) # Commit message is always set COMMIT_MSG: $(Build.SourceVersionMessage) # Because these variables are always set (in the variables block), diff --git a/ci/bash-lib.yml b/ci/bash-lib.yml index 36a32ad496..0679ffa273 100644 --- a/ci/bash-lib.yml +++ b/ci/bash-lib.yml @@ -29,5 +29,25 @@ steps: jq -n --arg message "$message" '{"text": $message}' \ | curl -XPOST -i -H 'Content-Type: application/json' -d @- $channel } + save_gcp_data() { + local restore_trap cred local_file remote_path key cleanup + + cred="$1" + local_file="$2" + remote_path="$3" + + key=$(mktemp) + # There may already be a trap; this will save it + restore_trap=$(trap -p EXIT) + cleanup="rm -rf $key ~/.config/gcloud" + trap "$cleanup" EXIT + echo "$cred" > $key + gcloud auth activate-service-account --key-file=$key + + BOTO_CONFIG=/dev/null gsutil cp "$local_file" "$remote_path" + eval "$cleanup" + trap - EXIT + eval "$restore_trap" + } END echo "##vso[task.setvariable variable=${{parameters.var_name}}]$TMP" diff --git a/ci/cron/daily-compat.yml b/ci/cron/daily-compat.yml index 23b4cb8ece..dacc9fd8fe 100644 --- a/ci/cron/daily-compat.yml +++ b/ci/cron/daily-compat.yml @@ -69,7 +69,7 @@ jobs: artifactName: 'Bazel Compatibility Logs' - template: ../daily_tell_slack.yml - - job: performance_report + - job: perf_speedy timeoutInMinutes: 120 pool: name: "linux-pool" @@ -84,22 +84,35 @@ jobs: IS_FORK: $(System.PullRequest.IsFork) # to upload to the bazel cache GOOGLE_APPLICATION_CREDENTIALS_CONTENT: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) + - template: ../bash-lib.yml + parameters: + var_name: bash_lib - bash: | set -euo pipefail eval "$(dev-env/bin/dade assist)" + source $(bash_lib) + BASELINE="cebc26af88efef4a7c81c62b0c14353f829b755e" TEST_SHA=$(cat ci/cron/perf/test_sha) OUT="$(Build.StagingDirectory)/perf-results.json" + + START=$(date -u +%Y%m%d_%H%M%SZ) + if git diff --exit-code $TEST_SHA -- daml-lf/scenario-interpreter/src/perf >&2; then # no changes, all good - ci/cron/perf/compare.sh $BASELINE > $OUT - cat $(Build.StagingDirectory)/perf-results.json + ci/cron/perf/compare.sh $BASELINE > "$OUT" + cat "$OUT" else # the tests have changed, we need to figure out what to do with # the baseline. - echo "Baseline no longer valid, needs manual correction." > $OUT + echo "Baseline no longer valid, needs manual correction." > "$OUT" fi + + save_gcp_data "$GCRED" "$OUT" gs://daml-data/perf/speedy/$START.json + displayName: measure perf + env: + GCRED: $(GOOGLE_APPLICATION_CREDENTIALS_CONTENT) - template: ../daily_tell_slack.yml parameters: success-message: '$(cat $(Build.StagingDirectory)/perf-results.json | jq . | jq -sR ''"perf for ''"$COMMIT_LINK"'':```\(.)```"'')'