-
-
Notifications
You must be signed in to change notification settings - Fork 356
146 lines (123 loc) · 4.54 KB
/
hotpath-profile.yml
File metadata and controls
146 lines (123 loc) · 4.54 KB
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
name: Hotpath profile
on:
pull_request:
paths-ignore:
- '**.md'
- 'demo/**'
- 'docs/**'
defaults:
run:
shell: bash
permissions:
contents: read
jobs:
profile:
runs-on: ubuntu-latest
env:
PGDATABASE: test
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
services:
postgres:
image: postgis/postgis:18-3.6
ports:
- 5432/tcp
options: >-
-e POSTGRES_DB=test
-e POSTGRES_USER=postgres
-e POSTGRES_PASSWORD=postgres
-e PGDATABASE=test
-e PGUSER=postgres
-e PGPASSWORD=postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- run: rustup update stable && rustup default stable
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- uses: taiki-e/install-action@cf525cb33f51aca27cd6fa02034117ab963ff9f1 # v2.75.22
with: { tool: 'just,oha' }
- name: Install rendering dependencies
run: just install-dependencies
- name: Init database
run: tests/fixtures/initdb.sh
env:
PGPORT: ${{ job.services.postgres.ports[5432] }}
- name: Create metrics directory
run: mkdir -p /tmp/metrics
- name: Build head
run: just build-hotpath
- name: Benchmark head
env:
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/head_timing.json
HOTPATH_ALLOC_SELF: true
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGPASSWORD }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}
run: |
set -euo pipefail
just bench-server-hotpath &
MARTIN_PID=$!
for i in {1..1000}; do
if curl -sf http://localhost:3000/health > /dev/null 2>&1; then break; fi
sleep 1
done
curl -sf http://localhost:3000/health > /dev/null 2>&1 || { echo "::error::Martin failed to start"; kill $MARTIN_PID 2>/dev/null; exit 1; }
just bench-http 1m 100k
kill $MARTIN_PID 2>/dev/null || true
wait $MARTIN_PID || true
- name: Checkout base
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Clean slate to not have codegen cache artefact bias
run: cargo clean
- name: Check base has hotpath support
id: base-check
run: |
if grep -q '__hotpath' martin/Cargo.toml; then
echo "supported=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::Base branch does not have __hotpath feature, skipping base benchmark"
echo '{}' > /tmp/metrics/base_timing.json
echo "supported=false" >> "$GITHUB_OUTPUT"
fi
- name: Build base
if: steps.base-check.outputs.supported == 'true'
run: just build-hotpath
- name: Benchmark base
if: steps.base-check.outputs.supported == 'true'
env:
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/base_timing.json
HOTPATH_ALLOC_SELF: true
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGPASSWORD }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}
run: |
set -euo pipefail
just bench-server-hotpath &
MARTIN_PID=$!
for i in {1..1000}; do
if curl -sf http://localhost:3000/health > /dev/null 2>&1; then break; fi
sleep 1
done
curl -sf http://localhost:3000/health > /dev/null 2>&1 || { echo "::error::Martin failed to start"; kill $MARTIN_PID 2>/dev/null; exit 1; }
just bench-http 1m 100k
kill "$MARTIN_PID" 2>/dev/null || true
wait "$MARTIN_PID" || true
- name: Save PR metadata
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
BASE_REF: ${{ github.base_ref }}
HEAD_REF: ${{ github.head_ref }}
run: |
echo "$PR_NUMBER" > /tmp/metrics/pr_number.txt
echo "$BASE_REF" > /tmp/metrics/base_ref.txt
echo "$HEAD_REF" > /tmp/metrics/head_ref.txt
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: profile-metrics
path: /tmp/metrics/
retention-days: 1