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: bench bb in pr's, docker shell utils #3561

Merged
merged 61 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
938066e
feat: bench bb in pr's
ludamad0 Dec 4, 2023
e019f68
fix: core count first
ludamad0 Dec 4, 2023
a079fe8
fix: core count first
ludamad0 Dec 4, 2023
00abec4
fix script run
ludamad0 Dec 4, 2023
24bc448
Bench
ludamad0 Dec 4, 2023
50629e3
fix: change to /bin/bash
ludamad0 Dec 4, 2023
7cb52d4
fix: change to /bin/bash
ludamad0 Dec 4, 2023
1090a98
meh.
ludamad0 Dec 5, 2023
3fdbd14
Janky attempts
ludamad0 Dec 5, 2023
bcfaecc
Janky attempts
ludamad0 Dec 5, 2023
a263c0a
Janky attempts
ludamad0 Dec 5, 2023
a8d5e21
Add script for ultra_honk_bench.sh
ludamad0 Dec 5, 2023
b47c911
executable flag
ludamad0 Dec 5, 2023
791a492
reqs
ludamad0 Dec 5, 2023
df03cd2
fix: include scripts/ci in ci build
ludamad0 Dec 5, 2023
94fefdc
reqs
ludamad0 Dec 5, 2023
643696c
Build ultra honk in linux clang
ludamad0 Dec 5, 2023
0a4f491
Update
ludamad0 Dec 5, 2023
0f2e89a
fix path
ludamad0 Dec 5, 2023
2792b63
fix reqs
ludamad0 Dec 5, 2023
b0b4c8c
Build grumpkin srs gen in linux clang
ludamad0 Dec 5, 2023
8f25213
Try a simple benchmark
ludamad0 Dec 5, 2023
1a16e10
temporary simple docker sanity test
ludamad0 Dec 5, 2023
4f653d3
temporary simple docker sanity test
ludamad0 Dec 5, 2023
2a31a93
timing
ludamad0 Dec 5, 2023
9aec742
Merge github.com:AztecProtocol/aztec-packages into feat/bench-bb-in-prs
ludamad0 Dec 6, 2023
9758fa6
Merge github.com:AztecProtocol/aztec-packages into feat/bench-bb-in-prs
ludamad0 Dec 6, 2023
0bc1011
Temp instrumenting
ludamad0 Dec 6, 2023
bd3be20
Merge branch 'master' into feat/bench-bb-in-prs
ludamad Dec 15, 2023
70be4ab
Merge branch 'master' into feat/bench-bb-in-prs
ludamad Dec 15, 2023
9db75ae
get_all work
ludamad0 Dec 15, 2023
636cb77
Merge remote-tracking branch 'origin/master' into feat/bench-bb-in-prs
ludamad0 Jan 4, 2024
8b7b4ae
Docker interactive
ludamad0 Jan 5, 2024
345979f
Merge branch 'master' into feat/bench-bb-in-prs
ludamad Jan 5, 2024
b394a25
chore: reverts
ludamad0 Jan 5, 2024
13794f8
Merge remote-tracking branch 'origin/master' into feat/bench-bb-in-prs
ludamad0 Jan 9, 2024
817aa13
Benchmark progress
ludamad0 Jan 9, 2024
de8907f
Merge branch 'feat/bench-bb-in-prs' of github.com:AztecProtocol/aztec…
ludamad0 Jan 9, 2024
3e511e6
fix docs deploy
ludamad0 Jan 9, 2024
4b5e707
Revert partial changes to barretenberg/cpp/dockerfiles/Dockerfile.x86…
ludamad0 Jan 9, 2024
9eae745
Revert
ludamad0 Jan 9, 2024
9f28f18
Merge branch 'master' into feat/bench-bb-in-prs
ludamad Jan 9, 2024
7f1ef07
diff
ludamad0 Jan 9, 2024
7472c30
Merge remote-tracking branch 'origin/feat/bench-bb-in-prs' into feat/…
ludamad0 Jan 9, 2024
45b7fb7
Copy ci scripts into docker container
ludamad0 Jan 9, 2024
e47075c
Need curl
ludamad0 Jan 9, 2024
af6526b
copy grumpkin srs gen
ludamad0 Jan 9, 2024
e0eb0f0
Expose binaries properly
ludamad0 Jan 9, 2024
5736db5
Expose jq
ludamad0 Jan 9, 2024
a30d3eb
Benchmark shebang fix?
ludamad0 Jan 9, 2024
24df8e0
Tinkering, stinkering
ludamad0 Jan 9, 2024
9bc28fc
fix: script path [ci debug]
ludamad0 Jan 9, 2024
addf73d
fix: benchmark-docs uploading
ludamad0 Jan 10, 2024
9d0dc7e
Merge github.com:AztecProtocol/aztec-packages into feat/bench-bb-in-prs
ludamad0 Jan 10, 2024
8d75cb6
Try different image [ci debug]
ludamad0 Jan 10, 2024
14b7eef
Try different image [ci debug]
ludamad0 Jan 10, 2024
9df4e63
Merge branch 'master' into feat/bench-bb-in-prs
ludamad Jan 10, 2024
5d14416
Update config.yml
ludamad Jan 10, 2024
188984b
[ci rebuild barretenberg-bench]
ludamad0 Jan 10, 2024
831c934
Merge remote-tracking branch 'origin/master' into feat/bench-bb-in-prs
ludamad0 Jan 10, 2024
72ee001
Merge remote-tracking branch 'origin/feat/bench-bb-in-prs' into feat/…
ludamad0 Jan 10, 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
24 changes: 23 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ jobs:
- run:
name: "Deploy barretenberg docs"
command: |
barretenberg/cpp/docs/deploy_doxygen.sh
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just trying to keep a pattern here with ci helper scripts in scripts/ci

barretenberg/cpp/scripts/ci/upload_doxygen_to_s3.sh

barretenberg-stdlib-tests:
docker:
Expand Down Expand Up @@ -240,6 +240,23 @@ jobs:
name: "Test"
command: cond_spot_run_test barretenberg-x86_64-linux-clang-assert 32 ./scripts/bb-tests.sh

barretenberg-bench:
machine:
# NOTE: we usually use alpine build image when making spot images, but
# we are not able to upload to S3 with it
image: ubuntu-2204:2023.07.2
resource_class: medium
steps:
- *checkout
- *setup_env
- run:
name: "Benchmark"
command: cond_spot_run_build barretenberg-bench 32
- run:
name: "Upload"
command: |
barretenberg/cpp/scripts/ci/upload_benchmarks_to_s3.sh

barretenberg-honk-tests:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down Expand Up @@ -1108,6 +1125,10 @@ workflows:
- barretenberg-x86_64-linux-clang-fuzzing: *defaults
- barretenberg-wasm-linux-clang: *defaults
- barretenberg-x86_64-linux-clang-sol: *defaults
- barretenberg-bench:
requires:
- barretenberg-x86_64-linux-clang
<<: *defaults
- barretenberg-proof-system-tests: *bb_test
- barretenberg-honk-tests: *bb_test
- barretenberg-dsl-tests: *bb_test
Expand Down Expand Up @@ -1271,6 +1292,7 @@ workflows:
- bench-process-history: *e2e_test
- bench-summary:
requires:
- barretenberg-bench
- bench-publish-rollup
- bench-process-history
<<: *defaults
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Needed scripts.
!scripts/install-wasi-sdk.sh
!scripts/strip-wasm.sh
!scripts/ci
!./.clang-format
!./format.sh

Expand Down
4 changes: 4 additions & 0 deletions barretenberg/cpp/dockerfiles/Dockerfile.bench
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/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
12 changes: 9 additions & 3 deletions barretenberg/cpp/dockerfiles/Dockerfile.x86_64-linux-clang
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ RUN apk update \
perl
WORKDIR /usr/src/barretenberg/cpp
COPY . .
# Build bb binary. Everything else is built as part linux-clang-assert.
RUN cmake --preset default && cmake --build --preset default --target bb
# Build bb binary and targets needed for benchmarking.
# Everything else is built as part linux-clang-assert.
# Benchmark targets want to run without asserts, so get built alongside bb.
RUN cmake --preset default
RUN cmake --build --preset default --target ultra_honk_rounds_bench --target bb --target grumpkin_srs_gen

FROM alpine:3.18
WORKDIR /usr/src/barretenberg/cpp
COPY . .
COPY --from=builder /usr/src/barretenberg/cpp/scripts/ci /usr/src/barretenberg/cpp/scripts/ci
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/bb /usr/src/barretenberg/cpp/build/bin/bb
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/ultra_honk_rounds_bench /usr/src/barretenberg/cpp/build/bin/ultra_honk_rounds_bench
COPY --from=builder /usr/src/barretenberg/cpp/build/bin/grumpkin_srs_gen /usr/src/barretenberg/cpp/build/bin/grumpkin_srs_gen
# Copy libs for consuming projects.
COPY --from=builder /usr/src/barretenberg/cpp/build/lib/libbarretenberg.a /usr/src/barretenberg/cpp/build/lib/libbarretenberg.a
COPY --from=builder /usr/src/barretenberg/cpp/build/lib/libenv.a /usr/src/barretenberg/cpp/build/lib/libenv.a
COPY --from=builder /usr/src/barretenberg/cpp/build/lib/libenv.a /usr/src/barretenberg/cpp/build/lib/libenv.a
20 changes: 20 additions & 0 deletions barretenberg/cpp/dockerfiles/interactive/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use Alpine 3.18 as the base image
FROM alpine:3.18

# Install necessary packages
RUN apk update && apk add \
bash \
build-base \
clang16 \
cmake \
ninja \
git \
curl \
perl \
libstdc++

# Set the working directory in the container
WORKDIR /usr/src/barretenberg/cpp

# Set bash as the default command to keep the container running interactively
CMD ["/bin/bash"]
24 changes: 24 additions & 0 deletions barretenberg/cpp/dockerfiles/interactive/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:lunar

RUN apt update && apt install -y \
build-essential \
curl \
git \
cmake \
lsb-release \
wget \
software-properties-common \
gnupg \
ninja-build \
npm \
\
libssl-dev \
jq \
bash \
libstdc++6

WORKDIR /usr/src/barretenberg/cpp

RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 16

CMD ["/bin/bash"]
14 changes: 14 additions & 0 deletions barretenberg/cpp/scripts/ci/ultra_honk_bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env sh
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

# enter script folder
cd "$(dirname $0)"
cd ../../srs_db
./download_ignition.sh 1
./download_grumpkin.sh
cd ../build
./bin/ultra_honk_rounds_bench --benchmark_format=json | tee ultra_honk_rounds_bench.json
echo "Testing if we have created valid JSON."
cat ultra_honk_rounds_bench.json | jq empty
echo "JSON is valid. Continuing."
19 changes: 19 additions & 0 deletions barretenberg/cpp/scripts/ci/upload_benchmarks_to_s3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Uploads to S3 a recent barretenberg benchmark run.
#!/usr/bin/env bash
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

extract_repo barretenberg-bench /usr/src extracted-repo

BUCKET_NAME="aztec-ci-artifacts"
COMMIT_HASH="${COMMIT_HASH:-$(git rev-parse HEAD)}"

if [ "${BRANCH:-}" = "master" ]; then
TARGET_FOLDER="barretenberg-bench-v1/master/$COMMIT_HASH/"
elif [ -n "${PULL_REQUEST:-}" ]; then
TARGET_FOLDER="barretenberg-bench-v1/pulls/${PULL_REQUEST##*/}"
else
echo Skipping upload since no target folder was defined
fi
echo "Uploading to s3://$BUCKET_NAME/$TARGET_FOLDER"
aws s3 cp extracted-repo/src/barretenberg/cpp/build/ultra_honk_rounds_bench.json "s3://$BUCKET_NAME/$TARGET_FOLDER/ultra_honk_rounds_bench.json"
16 changes: 16 additions & 0 deletions barretenberg/cpp/scripts/docker_interactive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Script to enter a docker shell.
# This comes in two flavors, ubuntu and alpine.
# This mounts the current folder into the image, allowing for in-docker development.
# You then need to run cmake commands fresh to build.
# Ideally you can combine with a fresh clone of the repo to keep it persistently around, or move around build dirs as needed.
# This is useful for debugging issues like bb being slow on alpine or running into errors on a specific version of gcc.
# usage: ./docker_interactive.sh ubuntu or ./docker_interactive.sh alpine

# Enter script directory.
set -eu
cd $(dirname $0)
# allows for 'alpine' or 'ubuntu'
ENVIRONMENT_KIND="${1:-alpine}"
DOCKERFILE="../dockerfiles/interactive/Dockerfile.$ENVIRONMENT_KIND"
docker build -t "env-$ENVIRONMENT_KIND" -f "$DOCKERFILE" .
docker run -it --mount type=bind,source=$(pwd)/..,target=/usr/src/barretenberg/cpp "env-$ENVIRONMENT_KIND"
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include "barretenberg/ecc/scalar_multiplication/scalar_multiplication.hpp"
#include "barretenberg/polynomials/polynomial_arithmetic.hpp"
#include "barretenberg/srs/factories/file_crs_factory.hpp"

#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp"
#include "barretenberg/ultra_honk/ultra_composer.hpp"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This hasn't ran in a long time, fixes


#include <chrono>
#include <cstdlib>

Expand Down Expand Up @@ -42,8 +46,6 @@ constexpr size_t NUM_POINTS = 1 << 16;
std::vector<fr> scalars;
static barretenberg::evaluation_domain small_domain;
static barretenberg::evaluation_domain large_domain;
auto reference_string =
std::make_shared<barretenberg::srs::factories::FileProverCrs<curve::BN254>>(NUM_POINTS, "../srs_db/ignition");

const auto init = []() {
small_domain = barretenberg::evaluation_domain(NUM_POINTS);
Expand All @@ -63,6 +65,9 @@ const auto init = []() {
};
// constexpr double add_to_mixed_add_complexity = 1.36;

auto reference_string =
std::make_shared<barretenberg::srs::factories::FileProverCrs<curve::BN254>>(NUM_POINTS, "../srs_db/ignition");

int pippenger()
{
scalar_multiplication::pippenger_runtime_state<curve::BN254> state(NUM_POINTS);
Expand Down Expand Up @@ -98,6 +103,7 @@ int coset_fft_regular()

int main()
{
barretenberg::srs::init_crs_factory("../srs_db/ignition");
std::cout << "initializing" << std::endl;
init();
std::cout << "executing normal fft" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ static void construct_proof_standard_power_of_2(State& state) noexcept
}

BENCHMARK(construct_proof_standard_power_of_2)
// 2**13 gates to 2**18 gates
->DenseRange(13, 18)
// 2**15 gates to 2**20 gates
->DenseRange(15, 20)
->Unit(::benchmark::kMillisecond);
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ BENCHMARK_CAPTURE(construct_proof_ultrahonk,
->Unit(kMillisecond);

BENCHMARK(construct_proof_ultrahonk_power_of_2)
// 2**13 gates to 2**18 gates
->DenseRange(13, 18)
// 2**15 gates to 2**20 gates
->DenseRange(15, 20)
->Unit(kMillisecond);
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ BENCHMARK_CAPTURE(construct_proof_ultraplonk,
->Unit(kMillisecond);

BENCHMARK(construct_proof_ultraplonk_power_of_2)
// 2**13 gates to 2**18 gates
->DenseRange(13, 18)
// 2**15 gates to 2**20 gates
->DenseRange(15, 20)
->Unit(kMillisecond);
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ void compute_grand_product(const size_t circuit_size,
parallel_for(num_threads, [&](size_t thread_idx) {
const size_t start = thread_idx * block_size;
const size_t end = (thread_idx + 1) * block_size;
typename Flavor::AllValues evaluations;
auto evaluations_view = evaluations.get_all();
for (size_t i = start; i < end; ++i) {
typename Flavor::AllValues evaluations;
for (auto [eval, full_poly] : zip_view(evaluations.get_all(), full_polynomials_view)) {
for (auto [eval, full_poly] : zip_view(evaluations_view, full_polynomials_view)) {
eval = full_poly.size() > i ? full_poly[i] : 0;
}
numerator[i] = GrandProdRelation::template compute_grand_product_numerator<Accumulator>(
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/srs_db/download_grumpkin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
# TODO(https://github.com/AztecProtocol/barretenberg/issues/813) We don't *actually* download grumpkin yet.
# this just generates grumpkin points and puts in a place where run_acir_tests.sh expects it.
# this just generates grumpkin points and links in a place where run_acir_tests.sh expects it.
# The above issue tracks the final pieces here.
set -eu

Expand Down
2 changes: 1 addition & 1 deletion build-system/scripts/upload_logs_to_s3
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ ! -d "$LOG_FOLDER" ] || [ -z "$(ls -A "$LOG_FOLDER")" ]; then
exit 0
fi

# Duplicated in scripts/ci/assemble_e2e_benchmark.sh
# Paths used in scripts/ci/assemble_e2e_benchmark.sh
if [ "${BRANCH:-}" = "master" ]; then
TARGET_FOLDER="logs-v1/master/$COMMIT_HASH/"
elif [ -n "${PULL_REQUEST:-}" ]; then
Expand Down
6 changes: 6 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ barretenberg-acir-tests-bb.js:
- bb.js
- noir-compile-acir-tests

barretenberg-bench:
buildDir: barretenberg/cpp
dockerfile: dockerfiles/Dockerfile.bench
dependencies:
- barretenberg-x86_64-linux-clang

barretenberg-docs:
buildDir: barretenberg/cpp
dockerfile: docs/Dockerfile
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/assemble_e2e_benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Grabs the log files uploaded in yarn-project/end-to-end/scripts/upload_logs_to_s3.sh
# Grabs the log files uploaded in build-system/scripts/upload_logs_to_s3
# that contain representative benchmarks, extracts whatever metrics are interesting,
# and assembles a single file that shows the current state of the repository.

Expand All @@ -14,7 +14,7 @@ BASE_COMMIT_HASH=""
BENCHMARK_FILE_JSON="${BENCH_FOLDER}/benchmark.json"
BASE_BENCHMARK_FILE_JSON="${BENCH_FOLDER}/base-benchmark.json"

# Adapted from yarn-project/end-to-end/scripts/upload_logs_to_s3.sh
# Paths from build-system/scripts/upload_logs_to_s3
if [ "${CIRCLE_BRANCH:-}" = "master" ]; then
LOG_SOURCE_FOLDER="logs-v1/master/$COMMIT_HASH"
BENCHMARK_TARGET_FILE="benchmarks-v1/master/$COMMIT_HASH.json"
Expand Down