Compare commits

...

10 Commits

Author SHA1 Message Date
Alexander Bayandin
62bb054d87 Merge branch 'main' into bayandin/replace-cachepot-with-sccache 2024-07-01 15:14:26 +01:00
Alexander Bayandin
6fca885a86 CI(compute-tools): enable sccache 2024-06-30 13:36:11 +01:00
Alexander Bayandin
0a0e7f3486 CI(check-codestyle-rust): use sccache 2024-06-30 10:31:32 +01:00
Alexander Bayandin
c90f212450 sccache -s -> sccache --show-stats 2024-06-30 09:37:11 +01:00
Alexander Bayandin
31fa86302f CI(neon-build): enable sccache 2024-06-30 00:57:01 +01:00
Alexander Bayandin
61fac26c76 CI(neon-build): print sccache stats 2024-06-30 00:39:39 +01:00
Alexander Bayandin
6921cc84d8 Do not set sccache by default 2024-06-30 00:36:23 +01:00
Alexander Bayandin
08da1327c1 Pass AWS creds to docker build 2024-06-29 23:43:01 +01:00
Alexander Bayandin
b7e72e56f8 Set SCCACHE_IGNORE_SERVER_IO_ERROR=1 2024-06-29 23:08:35 +01:00
Alexander Bayandin
b809391892 Replace cachepot with sccache 2024-06-29 23:08:35 +01:00
7 changed files with 54 additions and 18 deletions

View File

@@ -133,6 +133,11 @@ jobs:
password: ${{ secrets.NEON_DOCKERHUB_PASSWORD }}
options: --init
env:
SCCACHE_BUCKET: neon-github-dev
SCCACHE_REGION: eu-central-1
SCCACHE_S3_KEY_PREFIX: sccache
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -193,6 +198,8 @@ jobs:
if: ${{ !cancelled() }}
run: cargo deny check --hide-inclusion-graph
- run: sccache --show-stats
build-neon:
needs: [ check-permissions, tag, build-build-tools-image ]
runs-on: [ self-hosted, gen3, large ]
@@ -214,6 +221,9 @@ jobs:
BUILD_TYPE: ${{ matrix.build_type }}
GIT_VERSION: ${{ github.event.pull_request.head.sha || github.sha }}
BUILD_TAG: ${{ needs.tag.outputs.build-tag }}
SCCACHE_BUCKET: neon-github-dev
SCCACHE_REGION: eu-central-1
SCCACHE_S3_KEY_PREFIX: sccache
steps:
- name: Fix git ownership
@@ -339,6 +349,8 @@ jobs:
export PQ_LIB_DIR
${cov_prefix} mold -run cargo build $CARGO_FLAGS $CARGO_FEATURES --bins --tests
- run: sccache --show-stats
# Do install *before* running rust tests because they might recompile the
# binaries with different features/flags.
- name: Install rust binaries
@@ -412,6 +424,8 @@ jobs:
export REMOTE_STORAGE_AZURE_REGION="${{ vars.REMOTE_STORAGE_AZURE_REGION }}"
${cov_prefix} cargo nextest run $CARGO_FLAGS $CARGO_FEATURES -E 'package(remote_storage)' -E 'test(test_real_azure)'
- run: sccache --show-stats
- name: Install postgres binaries
run: cp -a pg_install /tmp/neon/pg_install
@@ -765,6 +779,9 @@ jobs:
GIT_VERSION=${{ github.event.pull_request.head.sha || github.sha }}
BUILD_TAG=${{ needs.tag.outputs.build-tag }}
TAG=${{ needs.build-build-tools-image.outputs.image-tag }}
RUSTC_WRAPPER=sccache
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_DEV }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_KEY_DEV }}
provenance: false
push: true
pull: true
@@ -857,6 +874,9 @@ jobs:
PG_VERSION=${{ matrix.version }}
BUILD_TAG=${{ needs.tag.outputs.build-tag }}
TAG=${{ needs.build-build-tools-image.outputs.image-tag }}
RUSTC_WRAPPER=sccache
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_DEV }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_KEY_DEV }}
provenance: false
push: true
pull: true
@@ -897,6 +917,9 @@ jobs:
GIT_VERSION=${{ github.event.pull_request.head.sha || github.sha }}
BUILD_TAG=${{ needs.tag.outputs.build-tag }}
TAG=${{ needs.build-build-tools-image.outputs.image-tag }}
RUSTC_WRAPPER=sccache
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_DEV }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_KEY_DEV }}
provenance: false
push: true
pull: true

View File

@@ -364,7 +364,7 @@ jobs:
env:
BUILD_TYPE: release
# remove the cachepot wrapper and build without crate caches
# remove the sccache wrapper and build without crate caches
RUSTC_WRAPPER: ""
# build with incremental compilation produce partial results
# so do not attempt to cache this build, also disable the incremental compilation

View File

@@ -29,15 +29,14 @@ WORKDIR /home/nonroot
ARG GIT_VERSION=local
ARG BUILD_TAG
# Enable https://github.com/paritytech/cachepot to cache Rust crates' compilation results in Docker builds.
# Set up cachepot to use an AWS S3 bucket for cache results, to reuse it between `docker build` invocations.
# cachepot falls back to local filesystem if S3 is misconfigured, not failing the build
ARG RUSTC_WRAPPER=cachepot
ENV AWS_REGION=eu-central-1
ENV CACHEPOT_S3_KEY_PREFIX=cachepot
ARG CACHEPOT_BUCKET=neon-github-dev
#ARG AWS_ACCESS_KEY_ID
#ARG AWS_SECRET_ACCESS_KEY
# Enable https://github.com/mozilla/sccache to cache Rust crates' compilation results in Docker builds.
# Set up sccache to use an AWS S3 bucket for cache results, to reuse it between `docker build` invocations.
ARG RUSTC_WRAPPER
ARG SCCACHE_BUCKET=neon-github-dev
ARG SCCACHE_REGION=eu-central-1
ARG SCCACHE_S3_KEY_PREFIX=sccache
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
COPY --from=pg-build /home/nonroot/pg_install/v14/include/postgresql/server pg_install/v14/include/postgresql/server
COPY --from=pg-build /home/nonroot/pg_install/v15/include/postgresql/server pg_install/v15/include/postgresql/server
@@ -46,7 +45,7 @@ COPY --from=pg-build /home/nonroot/pg_install/v16/lib pg_i
COPY --chown=nonroot . .
# Show build caching stats to check if it was used in the end.
# Has to be the part of the same RUN since cachepot daemon is killed in the end of this RUN, losing the compilation stats.
# Has to be the part of the same RUN since sccache daemon is killed in the end of this RUN, losing the compilation stats.
RUN set -e \
&& PQ_LIB_DIR=$(pwd)/pg_install/v16/lib RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment" cargo build \
--bin pg_sni_router \
@@ -58,7 +57,7 @@ RUN set -e \
--bin proxy \
--bin neon_local \
--locked --release \
&& cachepot -s
&& sccache --show-stats
# Build final image
#

View File

@@ -183,7 +183,7 @@ RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux
. "$HOME/.cargo/env" && \
cargo --version && rustup --version && \
rustup component add llvm-tools-preview rustfmt clippy && \
cargo install --git https://github.com/paritytech/cachepot && \
cargo install sccache && \
cargo install rustfilt && \
cargo install cargo-hakari && \
cargo install cargo-deny --locked && \
@@ -191,7 +191,9 @@ RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux
cargo install cargo-nextest && \
rm -rf /home/nonroot/.cargo/registry && \
rm -rf /home/nonroot/.cargo/git
ENV RUSTC_WRAPPER=cachepot
ENV RUSTC_WRAPPER=sccache
# Let sscache to fall back to local filesystem if S3 is misconfigured, not failing the build
ENV SCCACHE_IGNORE_SERVER_IO_ERROR=1
# Show versions
RUN whoami \

View File

@@ -868,10 +868,22 @@ FROM $REPOSITORY/$IMAGE:$TAG AS compute-tools
ARG BUILD_TAG
ENV BUILD_TAG=$BUILD_TAG
ARG RUSTC_WRAPPER
ARG SCCACHE_BUCKET=neon-github-dev
ARG SCCACHE_REGION=eu-central-1
ARG SCCACHE_S3_KEY_PREFIX=sccache
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
USER nonroot
# Copy entire project to get Cargo.* files with proper dependencies for the whole project
COPY --chown=nonroot . .
RUN cd compute_tools && mold -run cargo build --locked --profile release-line-debug-size-lto
RUN set -e \
&& RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=mold -Clink-arg=-Wl,--no-rosegment" cargo build \
--bin compute_ctl \
--locked \
--profile release-line-debug-size-lto \
&& sccache --show-stats
#########################################################################################
#

View File

@@ -124,9 +124,9 @@ pub mod poison;
///
/// #############################################################################################
/// TODO this macro is not the way the library is intended to be used, see <https://github.com/neondatabase/neon/issues/1565> for details.
/// We use `cachepot` to reduce our current CI build times: <https://github.com/neondatabase/cloud/pull/1033#issuecomment-1100935036>
/// We use `sccache` to reduce our current CI build times: <https://github.com/neondatabase/cloud/pull/1033#issuecomment-1100935036>
/// Yet, it seems to ignore the GIT_VERSION env variable, passed to Docker build, even with build.rs that contains
/// `println!("cargo:rerun-if-env-changed=GIT_VERSION");` code for cachepot cache invalidation.
/// `println!("cargo:rerun-if-env-changed=GIT_VERSION");` code for sccache cache invalidation.
/// The problem needs further investigation and regular `const` declaration instead of a macro.
#[macro_export]
macro_rules! project_git_version {

View File

@@ -2,7 +2,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate rust code from .proto protobuf.
//
// Note: we previously tried to use deterministic location at proto/ for
// easy location, but apparently interference with cachepot sometimes fails
// easy location, but apparently interference with sccache sometimes fails
// the build then. Anyway, per cargo docs build script shouldn't output to
// anywhere but $OUT_DIR.
tonic_build::compile_protos("proto/broker.proto")