Skip to content

Commit

Permalink
chore: use sccache (#26376)
Browse files Browse the repository at this point in the history
* chore: remove CARGO_TARGET_CACHE

* chore: prepare sccache env for docker container

* chore: use s3 as sccache backend
  • Loading branch information
yihau authored Jul 18, 2022
1 parent a8be960 commit e69d8ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 46 deletions.
17 changes: 0 additions & 17 deletions .buildkite/hooks/post-command
Original file line number Diff line number Diff line change
@@ -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
#
Expand Down
30 changes: 1 addition & 29 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions ci/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down

0 comments on commit e69d8ae

Please sign in to comment.