Skip to content

Commit 4278024

Browse files
committed
feat: add sync-v2 benchmark to CI
1 parent 7c7c261 commit 4278024

File tree

5 files changed

+162
-19
lines changed

5 files changed

+162
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: setup-hathor-env
2+
description: Setup Hathor node environment
3+
inputs:
4+
python:
5+
description: The python version
6+
os:
7+
description: The OS name
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Install Poetry
12+
shell: bash
13+
run: pipx install poetry
14+
15+
- name: Set up Python ${{ inputs.python }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ inputs.python }}
19+
cache: 'poetry'
20+
21+
- name: Install Ubuntu dependencies
22+
if: startsWith(inputs.os, 'ubuntu')
23+
run: |
24+
sudo apt-get -qy update
25+
sudo apt-get -qy install graphviz librocksdb-dev libsnappy-dev liblz4-dev
26+
shell: bash
27+
28+
- name: Install macOS dependencies
29+
if: startsWith(inputs.os, 'macos')
30+
run: |
31+
brew cleanup -q
32+
# brew update -q
33+
brew install -q graphviz rocksdb pkg-config
34+
shell: bash
35+
36+
- name: Install Poetry dependencies
37+
run: poetry install -n --no-root
38+
shell: bash

.github/workflows/base_benchmarks.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# yamllint disable rule:line-length
2+
name: benchmarking
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
benchmark_base_branch:
10+
name: Continuous Benchmarking base branch
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: bencherdev/bencher@main
15+
- name: Install hyperfine
16+
run: |
17+
wget https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_amd64.deb
18+
sudo dpkg -i hyperfine_1.12.0_amd64.deb
19+
- uses: ./.github/actions/setup-hathor-env
20+
name: Setup Hathor node environment
21+
with:
22+
python: 3.11
23+
os: ubuntu-22.04
24+
- name: Track base branch benchmarks with Bencher
25+
run: |
26+
bencher run \
27+
--project hathor-core \
28+
--token '${{ secrets.BENCHER_API_TOKEN }}' \
29+
--branch master \
30+
--testbed ubuntu-22.04 \
31+
--adapter shell_hyperfine \
32+
--err \
33+
--file bench_results.json \
34+
'./extras/benchmarking/benchmark_sync_v2.sh'

.github/workflows/main.yml

+4-19
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,11 @@ jobs:
6363
steps:
6464
- name: Checkout
6565
uses: actions/checkout@v3
66-
- name: Install Poetry
67-
run: pipx install poetry
68-
- name: Set up Python ${{ matrix.python }}
69-
uses: actions/setup-python@v4
66+
- uses: ./.github/actions/setup-hathor-env
67+
name: Setup Hathor node environment
7068
with:
71-
python-version: ${{ matrix.python }}
72-
cache: 'poetry'
73-
- name: Install Ubuntu dependencies
74-
if: startsWith(matrix.os, 'ubuntu')
75-
run: |
76-
sudo apt-get -qy update
77-
sudo apt-get -qy install graphviz librocksdb-dev libsnappy-dev liblz4-dev
78-
- name: Install macOS dependencies
79-
if: startsWith(matrix.os, 'macos')
80-
run: |
81-
brew cleanup -q
82-
# brew update -q
83-
brew install -q graphviz rocksdb pkg-config
84-
- name: Install Poetry dependencies
85-
run: poetry install -n --no-root
69+
python: ${{ matrix.python }}
70+
os: ${{ matrix.os }}
8671
- name: Cache mypy
8772
uses: actions/cache@v3
8873
with:

.github/workflows/pr_benchmarks.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# yamllint disable rule:line-length
2+
name: benchmarking
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
benchmark_pr_branch:
10+
name: Continuous Benchmarking PRs
11+
# DO NOT REMOVE: For handling Fork PRs see Pull Requests from Forks
12+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
13+
permissions:
14+
pull-requests: write
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: bencherdev/bencher@main
19+
- name: Install hyperfine
20+
run: |
21+
wget https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_amd64.deb
22+
sudo dpkg -i hyperfine_1.12.0_amd64.deb
23+
- uses: ./.github/actions/setup-hathor-env
24+
name: Setup Hathor node environment
25+
with:
26+
python: 3.11
27+
os: ubuntu-22.04
28+
- name: Track PR Benchmarks with Bencher
29+
run: |
30+
bencher run \
31+
--project hathor-core \
32+
--token '${{ secrets.BENCHER_API_TOKEN }}' \
33+
--branch '${{ github.head_ref }}' \
34+
--branch-start-point '${{ github.base_ref }}' \
35+
--branch-start-point-hash '${{ github.event.pull_request.base.sha }}' \
36+
--testbed ubuntu-22.04 \
37+
--adapter shell_hyperfine \
38+
--err \
39+
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
40+
--file bench_results.json \
41+
'./extras/benchmarking/benchmark_sync_v2.sh'
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
N_BLOCKS=100
2+
CACHE_SIZE=100000
3+
TESTNET_DATA_DIR=server-data
4+
TCP_PORT=40403
5+
AWAIT_INIT_DELAY=10
6+
N_RUNS=2
7+
BENCH_FILE=bench_results.json
8+
BENCH_DATA_DIR=bench-data
9+
10+
BLUE='\033[0;34m'
11+
NO_COLOR='\033[0m'
12+
13+
echo "${BLUE}Downloading testnet data...${NC}"
14+
mkdir $TESTNET_DATA_DIR
15+
poetry run hathor-cli quick_test --testnet --data $TESTNET_DATA_DIR --quit-after-n-blocks $N_BLOCKS > /dev/null 2>&1
16+
17+
echo "${BLUE}Running server node in the background...${NC}"
18+
poetry run hathor-cli run_node \
19+
--testnet \
20+
--data $TESTNET_DATA_DIR \
21+
--cache \
22+
--cache-size $CACHE_SIZE \
23+
--x-localhost-only \
24+
--listen tcp:$TCP_PORT \
25+
> /dev/null 2>&1 &
26+
27+
# Await initialization
28+
sleep $AWAIT_INIT_DELAY
29+
30+
echo "${BLUE}Running benchmark...${NC}"
31+
hyperfine \
32+
--runs $N_RUNS \
33+
--export-json $BENCH_FILE \
34+
--command-name "sync-v2 (up to $N_BLOCKS blocks)" \
35+
--prepare "rm -rf $BENCH_DATA_DIR && mkdir $BENCH_DATA_DIR" \
36+
"
37+
poetry run hathor-cli quick_test \
38+
--testnet \
39+
--data $BENCH_DATA_DIR \
40+
--cache \
41+
--cache-size $CACHE_SIZE \
42+
--x-localhost-only \
43+
--bootstrap tcp://localhost:$TCP_PORT \
44+
--quit-after-n-blocks $N_BLOCKS
45+
"

0 commit comments

Comments
 (0)