From e69d8ae7d75703ed2d05d19e3a334b344694416b Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Mon, 18 Jul 2022 15:39:21 +0800 Subject: [PATCH] chore: use sccache (#26376) * chore: remove CARGO_TARGET_CACHE * chore: prepare sccache env for docker container * chore: use s3 as sccache backend --- .buildkite/hooks/post-command | 17 ----------------- .buildkite/hooks/pre-command | 30 +----------------------------- ci/docker-run.sh | 9 +++++++++ 3 files changed, 10 insertions(+), 46 deletions(-) diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index 675afca95ed7f4..513b1b1f89b1a0 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -1,22 +1,5 @@ #!/bin/bash -e -# -# Save target/ for the next CI build on this machine -# -if [[ -z $CARGO_TARGET_CACHE ]]; then - echo "+++ CARGO_TARGET_CACHE not defined" # pre-command should have defined it -else - ( - set -x - mkdir -p "$CARGO_TARGET_CACHE" - set -x - rsync -a --delete --link-dest="$PWD" target "$CARGO_TARGET_CACHE" - du -hs "$CARGO_TARGET_CACHE" - read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE") - echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE" - ) -fi - # # Add job_stats data point # diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index fd898e8d345404..7a394a609f8b82 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -18,32 +18,4 @@ HOST_RUST_VERSION="$rust_stable" pattern='^[0-9]+\.[0-9]+\.[0-9]+$' if [[ ${HOST_RUST_VERSION} =~ ${pattern} ]]; then HOST_RUST_VERSION="${rust_stable%.*}" -fi -export CARGO_TARGET_CACHE=$HOME/cargo-target-cache/"$CHANNEL"-"$BUILDKITE_LABEL"-"$SBF_TOOLS_VERSION"-"$HOST_RUST_VERSION" -( - set -x - MAX_CACHE_SIZE=18 # gigabytes - - if [[ -d $CARGO_TARGET_CACHE ]]; then - du -hs "$CARGO_TARGET_CACHE" - read -r cacheSizeInGB _ < <(du -s --block-size=1800000000 "$CARGO_TARGET_CACHE") - echo "--- ${cacheSizeInGB}GB: $CARGO_TARGET_CACHE" - if [[ $cacheSizeInGB -gt $MAX_CACHE_SIZE ]]; then - echo "--- $CARGO_TARGET_CACHE is too large, removing it" - rm -rf "$CARGO_TARGET_CACHE" - fi - else - echo "--- $CARGO_TARGET_CACHE not present" - fi - - mkdir -p "$CARGO_TARGET_CACHE"/target - rsync -a --delete --link-dest="$CARGO_TARGET_CACHE" "$CARGO_TARGET_CACHE"/target . - - # Don't reuse BPF target build artifacts due to incremental build issues with - # `std: - # "found possibly newer version of crate `std` which `xyz` depends on - rm -rf target/bpfel-unknown-unknown - if [[ $BUILDKITE_LABEL = "stable-perf" ]]; then - rm -rf target/release - fi -) +fi \ No newline at end of file diff --git a/ci/docker-run.sh b/ci/docker-run.sh index dbe30b96bfdb13..542b2f04296af9 100755 --- a/ci/docker-run.sh +++ b/ci/docker-run.sh @@ -83,6 +83,15 @@ ARGS+=( --env CRATES_IO_TOKEN ) +# sccache +ARGS+=( + --env "RUSTC_WRAPPER=/home/.cargo/bin/sccache" + --env AWS_ACCESS_KEY_ID + --env AWS_SECRET_ACCESS_KEY + --env SCCACHE_BUCKET + --env SCCACHE_REGION +) + # Also propagate environment variables needed for codecov # https://docs.codecov.io/docs/testing-with-docker#section-codecov-inside-docker # We normalize CI to `1`; but codecov expects it to be `true` to detect Buildkite...