Skip to content

Commit

Permalink
ci/cron/check: low-hanging perf improvement (#9042)
Browse files Browse the repository at this point in the history
Two quick improvements I made while waiting on #9039:
- Avoid loading Java. When looking at the logs flow by this seemed to be
  taking a huge amount of time.
- Isolate the gcloud config files, which allows for running gcloud
  downloads in parallel.

Together these reduce the `check_releases` runtime from about 5 hours to
about 2. There's much more (and smarter) work needed on this, but this
was really easy to do.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
garyverhaegen-da committed Mar 8, 2021
1 parent fb0bd82 commit 121534c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions ci/bash-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ steps:
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
config_dir=$(mktemp -d)
cleanup="rm -rf $key $config_dir"
trap "$cleanup; $restore_trap" EXIT
echo "$cred" > $key
export CLOUDSDK_CONFIG="$config_dir"
gcloud auth activate-service-account --key-file=$key
BOTO_CONFIG=/dev/null gsutil $cmd "${args[@]}"
Expand Down
10 changes: 7 additions & 3 deletions ci/cron/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ verify_signatures :: FilePath -> FilePath -> String -> IO ()
verify_signatures bash_lib tmp version_tag = do
System.callCommand $ unlines ["bash -c '",
"set -euo pipefail",
"export DADE_SKIP_JAVA=1",
"eval \"$(dev-env/bin/dade assist)\"",
"source \"" <> bash_lib <> "\"",
"shopt -s extglob", -- enable !() pattern: things that _don't_ match
Expand All @@ -370,6 +371,7 @@ does_backup_exist :: String -> FilePath -> FilePath -> IO Bool
does_backup_exist gcp_credentials bash_lib path = do
out <- shell $ unlines ["bash -c '",
"set -euo pipefail",
"export DADE_SKIP_JAVA=1",
"eval \"$(dev-env/bin/dade assist)\"",
"source \"" <> bash_lib <> "\"",
"GCRED=$(cat <<END",
Expand All @@ -388,6 +390,7 @@ gcs_cp :: String -> FilePath -> FilePath -> FilePath -> IO ()
gcs_cp gcp_credentials bash_lib local_path remote_path = do
shell_ $ unlines ["bash -c '",
"set -euo pipefail",
"export DADE_SKIP_JAVA=1",
"eval \"$(dev-env/bin/dade assist)\"",
"source \"" <> bash_lib <> "\"",
"GCRED=$(cat <<END",
Expand Down Expand Up @@ -417,8 +420,9 @@ check_releases gcp_credentials bash_lib max_releases = do
IO.withTempDir $ \temp_dir -> do
download_assets temp_dir release
verify_signatures bash_lib temp_dir v
Control.Monad.Extra.whenJust gcp_credentials $ \gcred ->
Directory.listDirectory temp_dir >>= Data.Foldable.traverse_ (\f -> do
Control.Monad.Extra.whenJust gcp_credentials $ \gcred -> do
files <- Directory.listDirectory temp_dir
Control.Concurrent.Async.forConcurrently_ files $ \f -> do
let local_github = temp_dir </> f
let local_gcp = temp_dir </> f <> ".gcp"
let remote_gcp = "gs://daml-data/releases/" <> v <> "/github/" <> f
Expand All @@ -429,7 +433,7 @@ check_releases gcp_credentials bash_lib max_releases = do
True -> putStrLn $ f <> " matches GCS backup."
False -> Exit.die $ f <> " does not match GCS backup."
else do
Exit.die $ remote_gcp <> " does not exist. Aborting."))
Exit.die $ remote_gcp <> " does not exist. Aborting.")

data CliArgs = Docs
| Check { bash_lib :: String,
Expand Down
6 changes: 3 additions & 3 deletions dev-env/bin/dade-assist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DADE_CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DADE_CURRENT_SCRIPT_DIR/../lib/dade-common"

linkTool java out "${DADE_DEVENV_DIR}/jdk"

if [ -z "${DADE_SKIP_JAVA+1}" ]; then
linkTool java out "${DADE_DEVENV_DIR}/jdk"
fi
exec "${DADE_DEVENV_DIR}/lib/dade-dump-profile"

0 comments on commit 121534c

Please sign in to comment.