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: run benchmarks for ACIR proving #6155

Merged
merged 62 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
539b23c
feat: run benchmarks for ACIR proving
PhilWindle May 1, 2024
bce6863
chore: run benchmarks locally
TomAFrench May 2, 2024
47ff339
chore: dedupe log upload function
TomAFrench May 2, 2024
2631727
chore: fix reference to `+scripts` target
TomAFrench May 2, 2024
1326502
chore: run `yarn format`
TomAFrench May 2, 2024
ddb0800
Merge branch 'master' into tf/benchmarking
TomAFrench May 2, 2024
edebac7
chore: one too many levels
TomAFrench May 2, 2024
08579b6
chore: remove temp arg
TomAFrench May 2, 2024
b13f5cd
chore: dumb hack
TomAFrench May 2, 2024
c23ca99
chore: re-add env var
TomAFrench May 2, 2024
8639d31
chore: stop doing earthly badly
TomAFrench May 2, 2024
ba1f18c
chore: remove leftover code
TomAFrench May 2, 2024
b82aae4
chore: add necessary args
TomAFrench May 2, 2024
8510e09
Merge branch 'master' into tf/benchmarking
TomAFrench May 14, 2024
7dcf5a3
Merge branch 'master' into tf/benchmarking
TomAFrench May 14, 2024
88149ac
chore: fix merge
TomAFrench May 14, 2024
11dd243
wip
TomAFrench May 14, 2024
7eb8e09
wip
TomAFrench May 14, 2024
7fe2fa5
wip
TomAFrench May 14, 2024
cedd028
wip
TomAFrench May 14, 2024
6313163
chore: avoid waiting for e2e build
TomAFrench May 14, 2024
683aa7d
chore: switch over to isolated runner
TomAFrench May 14, 2024
61b495f
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
9ac0bec
chore: small fixes
TomAFrench May 15, 2024
f769124
chore: update `UPLOAD_LOGS`
TomAFrench May 15, 2024
312715b
chore: run acir-bench benchmarking inside of docker
TomAFrench May 15, 2024
773de3d
chore: set `TEST_SRC` env var
TomAFrench May 15, 2024
94a1882
test
TomAFrench May 15, 2024
b39137d
temp
TomAFrench May 15, 2024
103d02a
Update noir/Earthfile
TomAFrench May 15, 2024
e416d9e
chore: update path
TomAFrench May 15, 2024
675d850
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
e676aa4
chore: fix path to `UPLOAD_LOGS`
TomAFrench May 15, 2024
82ee3e0
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
9b1fe33
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
8f071ae
chore: change `builder_command`
TomAFrench May 15, 2024
3d6dc59
chore: update
TomAFrench May 15, 2024
3b77ead
chore: fix
TomAFrench May 15, 2024
584362e
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
8f2f2f8
foo
TomAFrench May 15, 2024
0d5bdd7
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
f8fa03b
chore: foo
TomAFrench May 15, 2024
bad5c1c
wip
TomAFrench May 15, 2024
17f3df8
chore: remove foo
TomAFrench May 15, 2024
cd73efe
chore: replace hardcoded list with `builder_images_to_copy`
TomAFrench May 15, 2024
a52ecbb
Update .github/workflows/ci.yml
TomAFrench May 15, 2024
6b66a88
run benchmarks `LOCALLY`
TomAFrench May 15, 2024
7f5fff8
chore: revert change to ensure-images pending other PR
TomAFrench May 15, 2024
27fcfbc
chore: fix
TomAFrench May 15, 2024
3335bf8
chore: fix
TomAFrench May 15, 2024
d8db3ca
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
4d1969e
Merge branch 'master' into tf/benchmarking
TomAFrench May 15, 2024
cf872d2
Merge branch 'master' into tf/benchmarking
TomAFrench May 16, 2024
bfef604
chore: acir benchmark use slim image (#6456)
ludamad May 16, 2024
5a7b951
Merge branch 'master' into tf/benchmarking
TomAFrench May 16, 2024
a630b1e
wip
TomAFrench May 16, 2024
5df247e
chore: rename log file
TomAFrench May 16, 2024
223c90e
chore: turn off other benches
TomAFrench May 16, 2024
134a0a1
chore: rename `name` to `eventName` in bb benchmarks
TomAFrench May 17, 2024
3448cd2
Merge branch 'master' into tf/benchmarking
TomAFrench May 17, 2024
f609e21
chore: reactivate other benchmarks
TomAFrench May 17, 2024
b9fbe76
Update yarn-project/scripts/src/benchmarks/aggregate.ts
TomAFrench May 20, 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
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,25 @@ jobs:
timeout-minutes: 25
run: earthly-ci -P --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} --no-output +${{ matrix.test }}

acir-bench:
runs-on: ${{ inputs.username || github.actor }}-bench-x86
needs: setup-bench
steps:
- {
uses: actions/checkout@v4,
with: { ref: "${{ github.event.pull_request.head.sha }}" },
}
- uses: ./.github/ci-setup-action
with:
dockerhub_password: "${{ secrets.DOCKERHUB_PASSWORD }}"
concurrency_key: acir-bench-${{ inputs.username || github.actor }}-bench-x86
- name: ACIR Proving Bench
working-directory: ./noir/
timeout-minutes: 15
run: earthly-ci -P --secret AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} --secret AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} --no-output +barretenberg-acir-benches-bb

# bench-summary:
# needs: e2e
# needs: [e2e, acir-bench]
# runs-on: ${{ inputs.username || github.actor }}-x86
# steps:
# - uses: actions/checkout@v4
Expand Down Expand Up @@ -265,12 +282,14 @@ jobs:
timeout-minutes: 15
run: earthly-ci --no-output +bench-ultra-honk --bench_mode=cache


merge-check:
runs-on: ubuntu-latest
needs:
- e2e
- bb-native-tests
- bb-bench
- acir-bench
- yarn-project-formatting
- yarn-project-test
- prover-client-test
Expand Down
7 changes: 7 additions & 0 deletions barretenberg/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VERSION 0.8

acir-tests:
FROM ../build-images+build
WORKDIR /usr/src/barretenberg
COPY ./acir_tests .
SAVE ARTIFACT ./*
10 changes: 8 additions & 2 deletions barretenberg/acir_tests/bench_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

TEST_NAMES=("$@")
THREADS=(1 4 16 32 64)
BENCHMARKS=$(mktemp)
BENCHMARKS=$LOG_FILE

if [[ -z "${LOG_FILE}" ]]; then
BENCHMARKS=$(mktemp)
fi

if [ "${#TEST_NAMES[@]}" -eq 0 ]; then
TEST_NAMES=(sha256 ecdsa_secp256k1 ecdsa_secp256r1 schnorr double_verify_proof)
Expand Down Expand Up @@ -64,4 +68,6 @@ function genthreadheaders(t, len, res) {
}
'

rm $BENCHMARKS
if [[ -z "${LOG_FILE}" ]]; then
rm $BENCHMARKS
fi
40 changes: 40 additions & 0 deletions noir/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,46 @@ build:
BUILD +nargo
BUILD +packages

build-acir-tests:
FROM +nargo
ENV PATH="/usr/src/noir-repo/target/release:${PATH}"
WORKDIR /usr/src/noir-repo/test_programs
COPY . .
RUN ./rebuild.sh
SAVE ARTIFACT /usr/src/noir-repo/test_programs/acir_artifacts/*

# This is ripped from end-to-end's Earthfile, need to pull from there directly.
UPLOAD_LOGS:
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
FUNCTION
ARG PULL_REQUEST
ARG BRANCH
ARG COMMIT_HASH
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
ARG LOG_FILE=./log
LOCALLY
LET COMMIT_HASH="${COMMIT_HASH:-$(git rev-parse HEAD)}"
FROM ../+scripts
COPY ./log /usr/var/log
ENV PULL_REQUEST=$PULL_REQUEST
ENV BRANCH=$BRANCH
ENV COMMIT_HASH=$COMMIT_HASH
RUN --secret AWS_ACCESS_KEY_ID --secret AWS_SECRET_ACCESS_KEY /usr/src/scripts/logs/upload_logs_to_s3.sh /usr/var/log

barretenberg-acir-benches-bb:
FROM ../build-images/+build
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /usr/src/barretenberg

COPY ../barretenberg/cpp/+preset-clang-assert/bin/bb /usr/src/barretenberg/cpp/build/bin/bb
COPY +build-acir-tests/ /usr/src/acir_artifacts
COPY ../barretenberg/+acir-tests/ /usr/src/barretenberg/acir_tests

WORKDIR /usr/src/barretenberg/acir_tests

ENV TEST_SRC /usr/src/acir_artifacts
ENV LOG_FILE=./log
RUN ./bench_acir_tests.sh sha256

SAVE ARTIFACT ./log AS LOCAL ./log
DO +UPLOAD_LOGS --PULL_REQUEST=$PULL_REQUEST --BRANCH=$BRANCH --COMMIT_HASH=$COMMIT_HASH
# TOOD
# test-packages
# FROM aztecprotocol/noir AS noir
Expand Down
7 changes: 7 additions & 0 deletions yarn-project/circuit-types/src/stats/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type StatsEventName } from './stats.js';

/** How a metric is grouped in benchmarks: by block size, by length of chain processed, or by circuit name. */
export type MetricGroupBy =
| 'threads'
| 'block-size'
| 'chain-length'
| 'circuit-name'
Expand All @@ -24,6 +25,12 @@ export interface Metric {

/** Metric definitions to track from benchmarks. */
export const Metrics = [
{
name: 'proof_construction_time_sha256',
groupBy: 'threads',
description: 'Time needed to generate a proof of an ACIR program.',
events: ['proof_construction_time'],
},
{
name: 'l1_rollup_calldata_size_in_bytes',
groupBy: 'block-size',
Expand Down
13 changes: 13 additions & 0 deletions yarn-project/circuit-types/src/stats/stats.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/** Stats associated with an ACIR proof generation.*/
export type ProofConstructed = {
/** Name of the event for metrics purposes */
eventName: 'proof_construction_time';
/** Name of the program being proven */
acir_test: string;
/** Number of threads used for proving */
threads: number;
/** Time spent proving */
value: number;
};
spalladino marked this conversation as resolved.
Show resolved Hide resolved

/** Stats associated with an L2 block. */
export type L2BlockStats = {
/** Number of txs in the L2 block. */
Expand Down Expand Up @@ -235,6 +247,7 @@ export type TxAddedToPoolStats = {

/** Stats emitted in structured logs with an `eventName` for tracking. */
export type Stats =
| ProofConstructed
| L1PublishStats
| NodeSyncedChainHistoryStats
| CircuitSimulationStats
Expand Down
1 change: 1 addition & 0 deletions yarn-project/end-to-end/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ UPLOAD_LOGS:
ARG PULL_REQUEST
ARG BRANCH
ARG COMMIT_HASH
ARG LOG_FILE=./log
LOCALLY
LET COMMIT_HASH="${COMMIT_HASH:-$(git rev-parse HEAD)}"
FROM ../../+scripts
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/scripts/src/benchmarks/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// And then run this script from the yarn-project/scripts folder
// LOG_FOLDER=../end-to-end/log yarn bench-aggregate
import {
type ProofConstructed,
BENCHMARK_BLOCK_SIZES,
BENCHMARK_HISTORY_BLOCK_SIZE,
BENCHMARK_HISTORY_CHAIN_LENGTHS,
Expand Down Expand Up @@ -66,6 +67,13 @@ function append(
results[metric]![bucket].push(numeric);
}

/** Processes an entry with event name 'acir-proof-generated' and updates results */
function processAcirProofGenerated(entry: ProofConstructed, results: BenchmarkCollectedResults) {
if (entry.acir_test == 'sha256') {
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
append(results, `proof_construction_time_sha256`, entry.threads, entry.value);
}
}

/** Processes an entry with event name 'rollup-published-to-l1' and updates results */
function processRollupPublished(entry: L1PublishStats, results: BenchmarkCollectedResults) {
const bucket = entry.txCount;
Expand Down Expand Up @@ -218,6 +226,8 @@ function processTreeInsertion(entry: TreeInsertionStats, results: BenchmarkColle
/** Processes a parsed entry from a log-file and updates results */
function processEntry(entry: Stats, results: BenchmarkCollectedResults, fileName: string) {
switch (entry.eventName) {
case 'proof_construction_time':
return processAcirProofGenerated(entry, results);
case 'rollup-published-to-l1':
return processRollupPublished(entry, results);
case 'l2-block-handled':
Expand Down
6 changes: 6 additions & 0 deletions yarn-project/scripts/src/benchmarks/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export function getMarkdown(prNumber: number) {
const benchmark = JSON.parse(fs.readFileSync(inputFile, 'utf-8'));
const baseBenchmark = getBaseBenchmark();

const metricsByThreads = Metrics.filter(m => m.groupBy === 'threads').map(m => m.name);
const metricsByBlockSize = Metrics.filter(m => m.groupBy === 'block-size').map(m => m.name);
const metricsByChainLength = Metrics.filter(m => m.groupBy === 'chain-length').map(m => m.name);
const metricsByCircuitName = Metrics.filter(m => m.groupBy === 'circuit-name').map(m => m.name);
Expand Down Expand Up @@ -217,6 +218,11 @@ All benchmarks are run on txs on the \`Benchmarking\` contract on the repository
${prSourceDataText}
${baseCommitText}

### Proof generation

Each column represents the number of threads used in proof generation.
${getTableContent(pick(benchmark, metricsByThreads), baseBenchmark, 'threads')}

### L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.
Expand Down
Loading