Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Parallel native/wasm bb builds. Better messaging around using ci cache. #4766

Merged
merged 34 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1e38125
Build nargo against Ubuntu 20 for better compatability
charlielye Feb 21, 2024
31cf1a9
retry a docker create thing.
charlielye Feb 21, 2024
a99b05d
We don't deploy to ecr anymore, only dockerhub. Use public ecr for bu…
charlielye Feb 21, 2024
60a38d3
bootstrap scripts try to use cache by default. l1-contracts will atte…
charlielye Feb 21, 2024
3af0393
Merge branch 'master' into cl/more_build_cache
charlielye Feb 21, 2024
42d1dea
Merge branch 'master' into cl/more_build_cache
charlielye Feb 22, 2024
97822b1
Remove old cache images.
charlielye Feb 23, 2024
f4d59db
Better retry.
charlielye Feb 23, 2024
6ac2000
Early out if can't use cache.
charlielye Feb 23, 2024
bd3a1bd
fix unbound
charlielye Feb 23, 2024
c52fec8
Remove codegen sol file.
charlielye Feb 23, 2024
ad2659c
Merge branch 'master' into cl/more_build_cache
charlielye Feb 23, 2024
332e1a3
fix
charlielye Feb 23, 2024
e40e51d
avm-transpiler to target ubuntu 20
charlielye Feb 23, 2024
6ece897
fix
charlielye Feb 23, 2024
2465a8d
fix
charlielye Feb 23, 2024
25f3036
Merge branch 'cl/more_build_cache' into cl/public_ecr
charlielye Feb 24, 2024
f7c9978
Merge branch 'master' into cl/public_ecr
charlielye Feb 26, 2024
5adcb50
fix
charlielye Feb 26, 2024
cb8a8e6
[ci rebuild]
charlielye Feb 26, 2024
8d66cea
public ecr needs to be us-east-1
charlielye Feb 26, 2024
8b5b459
[ci rebuild]
charlielye Feb 26, 2024
aaf417a
Use small executor for workflow calcs. Force process pool to 8.
charlielye Feb 26, 2024
92aa9c7
ecr-public
charlielye Feb 26, 2024
ad3cdcb
[ci rebuild]
charlielye Feb 26, 2024
af51314
We can't have lifecycles on public repos. Regretting this. Lets try d…
charlielye Feb 26, 2024
462a4d4
Update amis to have aws that supports ecr-public
charlielye Feb 26, 2024
d82e323
Giving up on public ecr. Too many compromises.
charlielye Feb 26, 2024
6fd63b6
fix and debug.
charlielye Feb 26, 2024
ae51b95
[ci rebuild]
charlielye Feb 27, 2024
f29ea9c
bootstrap requires explicit command. Warnings around caching.
charlielye Feb 27, 2024
b90c770
Add parallelism to cpp builds native/wasm/wasm-threads. Fix undefined…
charlielye Feb 27, 2024
e943d08
Revert change r.e. setup-workflow. Performance seems bad.
charlielye Feb 27, 2024
07f7e14
better msg.
charlielye Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
build-system/scripts/generate_circleci_config.py > .circleci/generated_config.yml
- continuation/continue:
configuration_path: .circleci/generated_config.yml

# Noir
noir-x86_64:
docker:
Expand Down Expand Up @@ -207,7 +208,7 @@ jobs:
name: "Build"
command: cond_spot_run_build barretenberg-x86_64-linux-clang-fuzzing 128
aztec_manifest_key: barretenberg-x86_64-linux-clang-fuzzing

barretenberg-x86_64-linux-clang-assert:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down
2 changes: 1 addition & 1 deletion avm-transpiler/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ if [ -n "$CMD" ]; then
fi

# Attempt to just pull artefacts from CI and exit on success.
./bootstrap_cache.sh && exit
[ -n "${USE_CACHE:-}" ] && ./bootstrap_cache.sh && exit

./scripts/bootstrap_native.sh
2 changes: 0 additions & 2 deletions avm-transpiler/bootstrap_cache.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -eu

[ -z "${NO_CACHE:-}" ] && type docker &> /dev/null && [ -f ~/.aws/credentials ] || exit 1

cd "$(dirname "$0")"
source ../build-system/scripts/setup_env '' '' mainframe_$USER > /dev/null

Expand Down
6 changes: 3 additions & 3 deletions barretenberg/acir_tests/Dockerfile.bb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/barretenberg-x86_64-linux-clang-assert
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-compile-acir-tests as noir-acir-tests
FROM aztecprotocol/barretenberg-x86_64-linux-clang-assert
FROM aztecprotocol/noir-compile-acir-tests as noir-acir-tests

FROM node:18.19.0-alpine
RUN apk update && apk add git bash curl jq coreutils
Expand All @@ -10,7 +10,7 @@ COPY . .
# Run every acir test through native bb build prove_then_verify flow for UltraPlonk.
# This ensures we test independent pk construction through real/garbage witness data paths.
RUN FLOW=prove_then_verify ./run_acir_tests.sh
# This flow is essentially the GoblinUltraHonk equivalent to the UltraPlonk "prove and verify". (This functionality is
# This flow is essentially the GoblinUltraHonk equivalent to the UltraPlonk "prove and verify". (This functionality is
# accessed via the goblin "accumulate" mechanism).
RUN FLOW=accumulate_and_verify_goblin ./run_acir_tests.sh
# This is a "full" Goblin flow. It constructs and verifies four proofs: GoblinUltraHonk, ECCVM, Translator, and merge
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/acir_tests/Dockerfile.bb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/bb.js
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-compile-acir-tests as noir-acir-tests
FROM aztecprotocol/bb.js
FROM aztecprotocol/noir-compile-acir-tests as noir-acir-tests

FROM node:18.19.0
COPY --from=0 /usr/src/barretenberg/ts-build /usr/src/barretenberg/ts
Expand Down
6 changes: 3 additions & 3 deletions barretenberg/acir_tests/Dockerfile.bb.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/barretenberg-x86_64-linux-clang-assert
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/barretenberg-x86_64-linux-clang-sol
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-compile-acir-tests as noir-acir-tests
FROM aztecprotocol/barretenberg-x86_64-linux-clang-assert
FROM aztecprotocol/barretenberg-x86_64-linux-clang-sol
FROM aztecprotocol/noir-compile-acir-tests as noir-acir-tests

FROM node:18.19.0-alpine
RUN apk update && apk add git bash curl jq
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/Dockerfile.noir_acir_tests
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# However, the noir subrepo has no concept of the aztec build pipeline, so the Dockerfile wouldn't make sense there.
# So, it lives here.
# This chains off the nargo build, and creates a container with a compiled set of acir tests.
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir
FROM aztecprotocol/noir
RUN apt update && apt install -y jq && rm -rf /var/lib/apt/lists/* && apt-get clean
ENV PATH="/usr/src/noir/target/release:${PATH}"
WORKDIR /usr/src/noir/test_programs
Expand Down
46 changes: 30 additions & 16 deletions barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ fi
# Download ignition transcripts.
(cd ./srs_db && ./download_ignition.sh 0)

# Install wasi-sdk.
./scripts/install-wasi-sdk.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this after trying to use cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only run once, and i think it makes sense to install it even if we take the output artefacts from the cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although you're making me second guess myself :)


# Attempt to just pull artefacts from CI and exit on success.
./bootstrap_cache.sh && exit
[ -n "${USE_CACHE:-}" ] && ./bootstrap_cache.sh && exit

# Pick native toolchain file.
ARCH=$(uname -m)
Expand All @@ -54,23 +57,34 @@ echo "# Building with preset: $PRESET"
echo "# When running cmake directly, remember to use: --build --preset $PRESET"
echo "#################################"

# Build native.
cmake --preset $PRESET -DCMAKE_BUILD_TYPE=RelWithAssert
cmake --build --preset $PRESET --target bb
function build_native {
cmake --preset $PRESET -DCMAKE_BUILD_TYPE=RelWithAssert
cmake --build --preset $PRESET --target bb
}

function build_wasm {
cmake --preset wasm
cmake --build --preset wasm
}

function build_wasm_threads {
cmake --preset wasm-threads
cmake --build --preset wasm-threads
}

g="\033[32m" # Green
b="\033[34m" # Blue
p="\033[35m" # Purple
r="\033[0m" # Reset

(build_native > >(awk -v g="$g" -v r="$r" '$0=g"native: "r $0')) &
(build_wasm > >(awk -v b="$b" -v r="$r" '$0=b"wasm: "r $0')) &
(build_wasm_threads > >(awk -v p="$p" -v r="$r" '$0=p"wasm_threads: "r $0')) &
Comment on lines +80 to +82
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just one comment/concern: could we potentially have race conditions? Looking at the output, seems that the path of the created objects is either

  • ...file.cpp.o (for native)
  • ...file.cpp.obj (for wasm/wasm-threads)

If that's true, especially the last 2 could overwrite each other. (I haven't looked into full detail.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They have their own independent build dirs.
build/build-wasm/build-wasm-threads


wait

if [ ! -d ./srs_db/grumpkin ]; then
# The Grumpkin SRS is generated manually at the moment, only up to a large enough size for tests
# If tests require more points, the parameter can be increased here.
(cd ./build && cmake --build . --parallel --target grumpkin_srs_gen && ./bin/grumpkin_srs_gen 8192)
cd ./build && cmake --build . --parallel --target grumpkin_srs_gen && ./bin/grumpkin_srs_gen 8192
fi

# Install wasi-sdk.
./scripts/install-wasi-sdk.sh

# Build WASM.
cmake --preset wasm
cmake --build --preset wasm

# Build WASM with new threading.
cmake --preset wasm-threads
cmake --build --preset wasm-threads
2 changes: 0 additions & 2 deletions barretenberg/cpp/bootstrap_cache.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -eu

[ -z "${NO_CACHE:-}" ] && type docker &> /dev/null && [ -f ~/.aws/credentials ] || exit 1

cd "$(dirname "$0")"
source ../../build-system/scripts/setup_env '' '' mainframe_$USER > /dev/null

Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/dockerfiles/Dockerfile.bench
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/barretenberg-x86_64-linux-clang
FROM aztecprotocol/barretenberg-x86_64-linux-clang
WORKDIR /usr/src/barretenberg/cpp
RUN apk update && apk add curl libstdc++ jq
RUN ./scripts/ci/ultra_honk_bench.sh
2 changes: 1 addition & 1 deletion barretenberg/ts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/barretenberg-wasm-linux-clang
FROM aztecprotocol/barretenberg-wasm-linux-clang

FROM node:18.19.0-alpine
COPY --from=0 /usr/src/barretenberg /usr/src/barretenberg
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/ts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ -n "$CMD" ]; then
fi

# Attempt to just pull artefacts from CI and exit on success.
./bootstrap_cache.sh && exit
[ -n "${USE_CACHE:-}" ] && ./bootstrap_cache.sh && exit

yarn install --immutable
echo "Building with command 'yarn $BUILD_CMD'..."
Expand Down
2 changes: 0 additions & 2 deletions barretenberg/ts/bootstrap_cache.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -eu

[ -z "${NO_CACHE:-}" ] && type docker &> /dev/null && [ -f ~/.aws/credentials ] || exit 1

cd "$(dirname "$0")"
source ../../build-system/scripts/setup_env '' '' mainframe_$USER > /dev/null

Expand Down
60 changes: 34 additions & 26 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,47 @@ cd "$(dirname "$0")"

CMD=${1:-}

if [ -n "$CMD" ]; then
if [ "$CMD" = "clean" ]; then
echo "WARNING: This will erase *all* untracked files, including hooks and submodules."
echo -n "Continue? [y/n] "
read user_input
if [ "$user_input" != "y" ] && [ "$user_input" != "Y" ]; then
exit 1
fi
YELLOW="\033[93m"
BOLD="\033[1m"
RESET="\033[0m"

# Remove hooks and submodules.
rm -rf .git/hooks/*
rm -rf .git/modules/*
for SUBMODULE in $(git config --file .gitmodules --get-regexp path | awk '{print $2}'); do
rm -rf $SUBMODULE
done
source ./build-system/scripts/setup_env '' '' '' > /dev/null

# Remove all untracked files, directories, nested repos, and .gitignore files.
git clean -ffdx
if [ "$CMD" = "clean" ]; then
echo "WARNING: This will erase *all* untracked files, including hooks and submodules."
echo -n "Continue? [y/n] "
read user_input
if [ "$user_input" != "y" ] && [ "$user_input" != "Y" ]; then
exit 1
fi

# Remove hooks and submodules.
rm -rf .git/hooks/*
rm -rf .git/modules/*
for SUBMODULE in $(git config --file .gitmodules --get-regexp path | awk '{print $2}'); do
rm -rf $SUBMODULE
done

exit 0
elif [ "$CMD" = "full" ]; then
export NO_CACHE=1
else
echo "Unknown command: $CMD"
# Remove all untracked files, directories, nested repos, and .gitignore files.
git clean -ffdx

exit 0
elif [ "$CMD" = "full" ]; then
if can_use_ci_cache; then
echo -e "${BOLD}${YELLOW}WARNING: Performing a full bootstrap. Consider leveraging './bootstrap.sh fast' to use CI cache.${RESET}"
echo
fi
elif [ "$CMD" = "fast" ]; then
export USE_CACHE=1
if ! can_use_ci_cache; then
echo -e "${BOLD}${YELLOW}WARNING: Either docker or aws credentials are missing. Install docker and request credentials. Note this is for internal aztec devs only.${RESET}"
exit 1
fi
else
echo "usage: $0 <full|fast|clean>"
exit 1
fi

# if [ ! -f ~/.nvm/nvm.sh ]; then
# echo "Nvm not found at ~/.nvm"
# exit 1
# fi

# Install pre-commit git hooks.
HOOKS_DIR=$(git rev-parse --git-path hooks)
echo "(cd barretenberg/cpp && ./format.sh staged)" >$HOOKS_DIR/pre-commit
Expand Down
6 changes: 3 additions & 3 deletions boxes/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Builds the boxes (they were copied into yarn-project-base so the cli can unbox).
# Produces a container that can be run to test a specific box. See docker-compose.yml.
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/aztec AS aztec
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir as noir
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/noir-projects as noir-projects
FROM aztecprotocol/aztec AS aztec
FROM aztecprotocol/noir as noir
FROM aztecprotocol/noir-projects as noir-projects

# We need yarn. Start fresh container.
FROM node:18.19.0
Expand Down
4 changes: 2 additions & 2 deletions build-system/scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ for PARENT_REPO in $(query_manifest dependencies $REPOSITORY); do
# Finally attempt to locate x86_64 image tag, as sometimes we build arch specific images from x86_64 images.
PARENT_IMAGE_TAG=$(calculate_image_tag $PARENT_REPO x86_64)
if ! image_exists $PARENT_REPO $PARENT_IMAGE_TAG; then
echo "Failed to locate multiarch image, arch specific image, or x86_64 image. Aborting."
echo "Failed to locate multiarch image, arch specific image, or x86_64 image for $PARENT_REPO. Aborting."
exit 1
fi
fi
fi

# Substitute references to parent repo, with the relevent built image uri.
DEPLOY_URI=$ECR_DEPLOY_URL/$PARENT_REPO
DEPLOY_URI=aztecprotocol/$PARENT_REPO
PARENT_IMAGE_URI=$ECR_URL/$PARENT_REPO:$PARENT_IMAGE_TAG
awk '{if ($1 == "FROM" && $2 == "'$DEPLOY_URI'") $2 = "'$PARENT_IMAGE_URI'"; print $0}' $DOCKERFILE > _temp && mv _temp $DOCKERFILE
done
Expand Down
6 changes: 1 addition & 5 deletions build-system/scripts/build_local
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ for E in "${PROJECTS[@]}"; do
fi
fi

# TODO: Move everything to aztecprotocol/*
DEPLOY_IMAGE_URI=$ECR_DEPLOY_URL/$REPO:latest
DEPLOY_IMAGE_URI=aztecprotocol/$REPO:latest
CACHE_IMAGE_URI=$(calculate_image_uri $REPO)
ARR=(${CACHE_IMAGE_URI//:/ })
REPO_URI=${ARR[0]}
Expand Down Expand Up @@ -112,9 +111,6 @@ for E in "${PROJECTS[@]}"; do
# Retag with deployment uri.
docker tag $CACHE_IMAGE_URI $DEPLOY_IMAGE_URI

# Retag for aztecprotocol dockerhub.
docker tag $DEPLOY_IMAGE_URI aztecprotocol/$REPO:latest

remove_old_images $REPO

echo -e "${BOLD}Tagged${RESET}: aztecprotocol/$REPO:latest"
Expand Down
3 changes: 3 additions & 0 deletions build-system/scripts/can_use_ci_cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
set -euo pipefail
type docker &> /dev/null && docker ps 2>&1 > /dev/null && [ -f ~/.aws/credentials ] && ecr_login > /dev/null || exit 1
1 change: 0 additions & 1 deletion build-system/scripts/cond_run_compose
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
echo "Pulling $REPO..."
REPO_IMAGE_URI=$(calculate_image_uri $REPO)
retry docker pull $REPO_IMAGE_URI
docker tag $REPO_IMAGE_URI $ECR_DEPLOY_URL/$REPO
docker tag $REPO_IMAGE_URI aztecprotocol/$REPO
done

Expand Down
39 changes: 0 additions & 39 deletions build-system/scripts/deploy_ecr

This file was deleted.

10 changes: 5 additions & 5 deletions build-system/scripts/generate_circleci_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_manifest_job_names():

def is_already_built_circleci_job(circleci_job, already_built_manifest_jobs):
"""
This function checks if a given CircleCI job is associated with a specific already-built manifest job.
This function checks if a given CircleCI job is associated with a specific already-built manifest job.
It does so by checking the job's steps for an 'aztec_manifest_key' that contain references to manifest names.
We want to see at least one such key, and for all such keys to be in 'already_built_manifest_jobs'.
"""
Expand All @@ -43,7 +43,7 @@ def is_already_built_circleci_job(circleci_job, already_built_manifest_jobs):
return False
matching_steps += 1
# All steps have matched - but make sure that's actually more than one step
return matching_steps > 0
return matching_steps > 0

def get_already_built_circleci_job_names(circleci_jobs):
already_built_manifest_jobs = list(get_already_built_manifest_job_names())
Expand Down Expand Up @@ -75,11 +75,11 @@ def get_already_built_manifest_job_names():
def remove_jobs_from_workflow(jobs, to_remove):
"""
Removes jobs from a given CircleCI JSON workflow.

Parameters:
jobs (dict): The JSON object representing the CircleCI workflow jobs dependencies portion.
to_remove (list): The list of jobs to be removed from the workflow.

Returns:
dict: The new JSON object with specified jobs removed.
"""
Expand All @@ -97,7 +97,7 @@ def remove_jobs_from_workflow(jobs, to_remove):

if __name__ == '__main__':
# The CircleCI workflow as a JSON string (Replace this with your actual workflow)

# Convert the JSON string to a Python dictionary
workflow_dict = yaml.safe_load(open('.circleci/config.yml'))

Expand Down
Loading
Loading