-
Notifications
You must be signed in to change notification settings - Fork 0
258 lines (238 loc) · 9.18 KB
/
reth-benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: "Reth Benchmark"
on:
workflow_dispatch:
inputs:
# Default runner is not big enough for this
# https://aws.amazon.com/ec2/instance-types/
instance_family:
type: string
required: false
description: The family of the instance, can be multiple ones concat with "+" e.g. r8g+r7g
default: m7a.48xlarge
memory_allocator:
type: string
required: false
description: Memory allocator to use (mimalloc or jemalloc)
default: mimalloc
block_number:
type: number
required: false
description: Block number to run the benchmark on
default: 21000000
app_log_blowup:
type: number
required: false
description: Application level log blowup
default: 2
agg_log_blowup:
type: number
required: false
description: Aggregation (leaf) level log blowup
default: 2
root_log_blowup:
type: number
required: false
description: Root level log blowup (only for e2e)
default: 3
internal_log_blowup:
type: number
required: false
description: Internal level log blowup (only for e2e)
default: 2
mode:
type: choice
required: false
description: Running mode, one of execute, prove, or prove-e2e
options:
- execute
- prove
- prove-e2e
default: prove
collect_metrics:
type: boolean
required: false
description: Whether to collect metrics for flamegraphs
default: false
max_segment_length:
type: number
required: false
description: Max segment length for continuations, must be larger than 524288
default: 8388508 # 2**23 - 100
env:
S3_PATH: s3://axiom-public-data-sandbox-us-east-1/benchmark/github/results
S3_METRICS_PATH: s3://axiom-public-data-sandbox-us-east-1/benchmark/github/metrics
PUBLIC_S3_PATH: s3://axiom-public-data-sandbox-us-east-1/benchmark/github/flamegraphs
FEATURE_FLAGS: "bench-metrics,parallel,nightly-features"
CMD_ARGS: ""
INPUT_ARGS: ""
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
jobs:
run-reth:
name: Run Reth benchmark
runs-on:
- runs-on
- run-id=${{ github.run_id }}
- family=${{ inputs.instance_family }}
- disk=large
- tag=bench-reth-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Display workflow inputs
run: echo "${{ toJSON(github.event.inputs) }}"
# - name: Load SSH key
# uses: webfactory/[email protected]
# with:
# ssh-private-key: |
# ${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }}
- name: Install cargo-openvm
run: |
cargo install --git https://github.com/openvm-org/openvm.git cargo-openvm
- name: Install openvm-prof
run: |
cargo install --git https://github.com/openvm-org/openvm.git --profile=dev openvm-prof
- name: Checkout openvm (for scripts)
run: |
git clone https://github.com/openvm-org/openvm.git
- name: Install architecture specific tools
run: |
rustup install nightly-2024-10-30
source openvm/ci/scripts/utils.sh
install_s5cmd
- name: Setup halo2
if: ${{ github.event.inputs.mode == 'prove-e2e' }}
run: |
bash openvm/extensions/native/recursion/trusted_setup_s3.sh
export PARAMS_DIR=$(pwd)/params
- name: Set metric name
run: |
input_json_str="${{ toJSON(github.event.inputs) }}"
input_hash=$(echo $input_json_str | sha256sum | cut -d' ' -f1)
METRIC_NAME=reth-${input_hash}
echo "METRIC_NAME=${METRIC_NAME}" >> $GITHUB_ENV
METRIC_PATH=".bench_metrics/${METRIC_NAME}.json"
echo "METRIC_PATH=${METRIC_PATH}" >> $GITHUB_ENV
- name: Build ELF
working-directory: bin/client-eth
run: |
PROFILE="release"
if [[ "${{ inputs.collect_metrics }}" == "true" ]]; then
PROFILE="profiling"
fi
cargo openvm build --no-transpile --profile=$PROFILE
mkdir -p ../host/elf
cp target/riscv32im-risc0-zkvm-elf/release/openvm-client-eth ../host/elf/
- name: Run Reth
run: |
mkdir -p rpc-cache
mkdir -p .bench_metrics # TODO: remove this
RPC_1=${{ secrets.RPC_URL_1 }}
MODE=${{ inputs.mode }}
BLOCK_NUMBER=${{ inputs.block_number }}
OPTIONAL_ARGS=""
PROFILE="release"
FEATURES="bench-metrics,${{ inputs.memory_allocator }}"
if [[ "${{ inputs.collect_metrics }}" == "true" ]]; then
OPTIONAL_ARGS="--collect-metrics"
PROFILE="profiling"
FEATURES="${FEATURES},profiling"
fi
arch=$(uname -m)
case $arch in
arm64|aarch64)
RUSTFLAGS="-Ctarget-cpu=native"
;;
x86_64|amd64)
RUSTFLAGS="-Ctarget-cpu=native -C target-feature=+avx512f"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
RUSTFLAGS=$RUSTFLAGS cargo build --bin openvm-reth-benchmark --profile=$PROFILE --no-default-features --features=$FEATURES
OUTPUT_PATH=${METRIC_PATH} ./target/$PROFILE/openvm-reth-benchmark \
--$MODE --block-number $BLOCK_NUMBER --rpc-url $RPC_1 --cache-dir rpc-cache \
--app-log-blowup ${{ inputs.app_log_blowup }} \
--agg-log-blowup ${{ inputs.agg_log_blowup }} \
--root-log-blowup ${{ inputs.root_log_blowup }} \
--max-segment-length ${{ inputs.max_segment_length }} $OPTIONAL_ARGS
- name: Upload Benchmark Metrics
run: |
current_sha=$(git rev-parse HEAD)
echo "Current SHA: $current_sha"
echo "current_sha=${current_sha}" >> $GITHUB_ENV
s5cmd cp ${METRIC_PATH} ${{ env.S3_METRICS_PATH }}/${current_sha}-${METRIC_NAME}.json
- name: Generate markdown # result path is hardcoded results.md
run: |
openvm-prof --json-paths $METRIC_PATH
MD_PATH=${METRIC_PATH%.json}.md
echo "MD_PATH=${MD_PATH}" >> $GITHUB_ENV
# - name: Install inferno-flamegraph
# run: cargo install inferno
# - name: Generate flamegraphs
# run: |
# if [[ -f $METRIC_PATH ]]; then
# python3 openvm/ci/scripts/metric_unify/flamegraph.py $METRIC_PATH
# s5cmd cp '.bench_metrics/flamegraphs/*.svg' "${{ env.PUBLIC_S3_PATH }}/${current_sha}/"
# echo "UPLOAD_FLAMEGRAPHS=1" >> $GITHUB_ENV
# fi
- name: Add benchmark metadata to markdown, and upload
run: |
COMMIT_URL=https://github.com/${{ github.repository }}/commit/${current_sha}
BENCHMARK_WORKFLOW_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
source openvm/ci/scripts/utils.sh
add_metadata $MD_PATH \
${{ inputs.max_segment_length }} \
${{ inputs.instance_family }} \
${{ inputs.memory_allocator }} \
$COMMIT_URL \
$BENCHMARK_WORKFLOW_URL
- name: Upload markdown
run: |
s5cmd cp $MD_PATH "${{ env.S3_PATH }}/${current_sha}-${METRIC_NAME}.md"
### Update gh-pages
- uses: actions/checkout@v4
with:
ref: gh-pages
- name: Set up git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Commit to gh-pages branch
run: |
GH_PAGES_PATH="benchmarks-dispatch/${{ github.head_ref || github.ref }}"
echo "GH_PAGES_PATH=${GH_PAGES_PATH}" >> $GITHUB_ENV
mkdir -p ${GH_PAGES_PATH}
s5cmd cp "${{ env.S3_PATH }}/${current_sha}-${METRIC_NAME}.md" "${GH_PAGES_PATH}/${METRIC_NAME}.md"
git add ${GH_PAGES_PATH}/${METRIC_NAME}.md
git commit --allow-empty -m "Update benchmark result at ${GH_PAGES_PATH}/${METRIC_NAME}.md"
MAX_RETRIES=10
RETRY_DELAY=5
ATTEMPT=0
SUCCESS=false
while [ $ATTEMPT -lt $MAX_RETRIES ]; do
echo "Attempt $((ATTEMPT + 1)) to push of $MAX_RETRIES..."
git fetch origin gh-pages
git merge origin/gh-pages --no-edit
if git push origin gh-pages; then
SUCCESS=true
break
else
echo "Push failed. Retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
ATTEMPT=$((ATTEMPT + 1))
fi
done
if [ "$SUCCESS" = false ]; then
echo "PUSH_FAILED"
exit 1
fi
- name: Path to result
run: |
echo "https://github.com/axiom-crypto/openvm-reth-benchmark/blob/gh-pages/${GH_PAGES_PATH}/${METRIC_NAME}.md"