Skip to content

Commit 1a4b9a5

Browse files
authored
feat: remove earthly usage for benchmarks (#654)
* feat: remove earthly usage for benchmarks * chore: remove commited js files * feat: use ephemeral postgres for benchmarks (cause regression error) * feat(benchmarks): use compare recipe instead of run on prs * feat: properly clean postgres servers * fix: create output directory * feat: increase benchmarks timeout * feat: benchmarks and add inputs on workflow dispatch * feat: use nix to setup just * fix: nix usage
1 parent b3eb0cd commit 1a4b9a5

File tree

13 files changed

+129
-286
lines changed

13 files changed

+129
-286
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Benchmark comparison
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
bench:
6+
description: 'Benchmarks to run'
7+
required: false
8+
default: '.'
9+
parallelism:
10+
description: 'Number of parallel benchmarks to run'
11+
required: false
12+
default: 5
13+
duration:
14+
description: 'Duration of each benchmark'
15+
required: false
16+
default: '10s'
17+
count:
18+
description: 'Number of times to run each benchmark '
19+
required: false
20+
default: 1
21+
pull_request:
22+
types: [ assigned, opened, synchronize, reopened, labeled ]
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
BenchmarkCompare:
30+
runs-on: "github-001"
31+
if: contains(github.event.pull_request.labels.*.name, 'benchmarks')
32+
steps:
33+
- uses: 'actions/checkout@v4'
34+
with:
35+
fetch-depth: 0
36+
- name: Setup Env
37+
uses: ./.github/actions/env
38+
with:
39+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
40+
- run: >
41+
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
42+
develop --impure --command just
43+
--justfile ./test/performance/justfile
44+
--working-directory ./test/performance
45+
compare ${{ inputs.bench }} ${{ inputs.parallelism }} ${{ inputs.duration }} ${{ inputs.count }}
46+
- run: >
47+
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
48+
develop --impure --command just
49+
--justfile ./test/performance/justfile
50+
--working-directory ./test/performance
51+
graphs
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: graphs
55+
path: test/performance/report

.github/workflows/benchmark.yml

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
11
name: Benchmark
22
on:
33
workflow_dispatch:
4-
pull_request:
5-
types: [ assigned, opened, synchronize, reopened, labeled ]
4+
inputs:
5+
bench:
6+
description: 'Benchmarks to run'
7+
required: false
8+
default: '.'
9+
parallelism:
10+
description: 'Number of parallel benchmarks to run'
11+
required: false
12+
default: 5
13+
duration:
14+
description: 'Duration of each benchmark'
15+
required: false
16+
default: '10s'
617

718
concurrency:
8-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
group: ${{ github.workflow }}-${{ github.ref }}
920
cancel-in-progress: true
1021

1122
jobs:
1223
Benchmark:
1324
runs-on: "github-001"
14-
if: contains(github.event.pull_request.labels.*.name, 'benchmarks') || github.ref == 'refs/heads/main'
25+
if: github.ref == 'refs/heads/main'
1526
steps:
1627
- uses: 'actions/checkout@v4'
1728
with:
1829
fetch-depth: 0
19-
- run: go build -o /tmp/ledger ./
20-
- run: echo "running actions as ${USER}"
21-
- run: >
22-
/tmp/ledger serve
23-
--postgres-uri=postgres://formance:formance@127.0.0.1/ledger
24-
--postgres-conn-max-idle-time=120s
25-
--postgres-max-open-conns=500
26-
--postgres-max-idle-conns=100
27-
--experimental-features
28-
--otel-metrics-keep-in-memory &
30+
- name: Setup Env
31+
uses: ./.github/actions/env
32+
with:
33+
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
2934
- run: >
30-
earthly
31-
--allow-privileged
32-
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
33-
./test/performance+run --args="-benchtime 10s --ledger.url=http://localhost:3068 --parallelism=5" --locally=yes
35+
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
36+
develop --impure --command just
37+
--justfile ./test/performance/justfile
38+
--working-directory ./test/performance
39+
run ${{ inputs.bench }} ${{ inputs.parallelism }} ${{ inputs.duration }} 1
3440
- run: >
35-
earthly
36-
--allow-privileged
37-
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
38-
./test/performance+generate-graphs
39-
- run: kill -9 $(ps aux | grep "ledger serve"| grep -v "grep" | awk '{print $2}')
40-
if: always()
41+
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
42+
develop --impure --command just
43+
--justfile ./test/performance/justfile
44+
--working-directory ./test/performance
45+
graphs
4146
- uses: actions/upload-artifact@v4
4247
with:
4348
name: graphs

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
just
102102
nodejs_22
103103
self.packages.${system}.speakeasy
104+
goperf
104105
];
105106
};
106107
}

test/performance/Earthfile

Lines changed: 0 additions & 59 deletions
This file was deleted.

test/performance/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ Scripts can be found in directory [scripts](./scripts).
1010
## Run locally
1111

1212
```shell
13-
earthly +run
13+
just run
1414
```
1515

1616
You can pass additional arguments (the underlying command is a standard `go test -bench=.`) using the flag `--args`.
1717
For example:
1818
```shell
19-
earthly +run --args="-benchtime 10s"
19+
just run "-benchtime 10s"
2020
```
2121

2222
## Run on a remote stack
2323

2424
```shell
25-
earthly +run --args="--stack.url=XXX --client.id=XXX --client.secret=XXX"
25+
just run "--stack.url=XXX --client.id=XXX --client.secret=XXX"
2626
```
2727

2828
## Run on a remote ledger
2929

3030
```shell
31-
earthly +run --args="--ledger.url=XXX --auth.url=XXX --client.id=XXX --client.secret=XXX"
31+
just run "--ledger.url=XXX --auth.url=XXX --client.id=XXX --client.secret=XXX"
3232
```
3333

3434
## Results
@@ -37,7 +37,7 @@ TPS is included as a benchmark metrics.
3737

3838
You can generate some graphs using the command:
3939
```
40-
earthly +generate-graphs
40+
just graphs
4141
```
4242

4343
See generated files in `report` directory.

test/performance/charts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.js

test/performance/charts/index.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

test/performance/charts/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const main = async () => {
66
let buffer = fs.readFileSync('../report/report.json', 'utf-8');
77
let reports = JSON.parse(buffer);
88
await exportTPSGraph({
9-
output: 'tps.png',
9+
output: '../report/tps.png',
1010
}, reports);
1111

12-
await exportDatabaseStats('database_connections.png', reports);
12+
await exportDatabaseStats('../report/database_connections.png', reports);
1313

1414
const ps: (keyof MetricsTime)[] = ['P99', 'P95', 'P75', 'Avg']
1515
for (let p of ps) {
1616
await exportLatencyGraph({
17-
output: p.toLowerCase() + '.png'
17+
output: '../report/' + p.toLowerCase() + '.png'
1818
}, p, reports);
1919
}
2020
}

test/performance/charts/src/colors.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)