Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit d2702f3

Browse files
author
Hendrik van Antwerpen
committed
Run base and head in seprate jobs
1 parent 3d8544e commit d2702f3

File tree

1 file changed

+123
-37
lines changed

1 file changed

+123
-37
lines changed

.github/workflows/perf.yml

Lines changed: 123 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@ on:
33
pull_request:
44
paths:
55
- 'stack-graphs/**'
6+
env:
7+
TEST_REPO: microsoft/TypeScript
8+
TEST_REF: v4.9.5
9+
TEST_DIR: test
10+
TEST_SRC: src/compiler
11+
BASE_MASSIF_OUT: base-perf.out
12+
BASE_REPORT: base-perf.txt
13+
BASE_ARTIFACT: base-perf-results
14+
HEAD_MASSIF_OUT: head-perf.out
15+
HEAD_REPORT: head-perf.txt
16+
HEAD_ARTIFACT: head-perf-results
17+
TSSG_TS: tree-sitter-stack-graphs-typescript
618

719
jobs:
8-
test-perf:
20+
##
21+
## Base performance
22+
##
23+
base-perf:
924
runs-on: ubuntu-latest
1025
env:
1126
BASE_REPO: ${{ github.event.pull_request.base.repo.owner.login }}/${{ github.event.pull_request.base.repo.name }}
1227
BASE_SHA: ${{ github.event.pull_request.base.sha }}
1328
BASE_DIR: base
14-
BASE_MASSIF_OUT: base-perf.out
15-
BASE_REPORT: base-perf.txt
16-
HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }}
17-
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
18-
HEAD_DIR: head
19-
HEAD_MASSIF_OUT: head-perf.out
20-
HEAD_REPORT: head-perf.txt
21-
TEST_REPO: microsoft/TypeScript
22-
TEST_REF: v4.9.5
23-
TEST_DIR: test
24-
TEST_SRC: src/compiler
25-
TSSG_TS: tree-sitter-stack-graphs-typescript
26-
COMMENT_JSON: perf-summary.json
2729
steps:
2830
#
2931
# Install tools
@@ -43,23 +45,17 @@ jobs:
4345
sudo apt-get update
4446
sudo apt-get install -y valgrind
4547
#
46-
# Checkout test code
47-
#
48-
- name: Checkout test code
49-
uses: actions/checkout@v3
50-
with:
51-
repository: ${{ env.TEST_REPO }}
52-
ref: ${{ env.TEST_REF }}
53-
path: ${{ env.TEST_DIR }}
54-
#
55-
# Test base performance
48+
# Cache results
5649
#
5750
- name: "Cache base result"
5851
id: cache-base-result
5952
uses: actions/cache@v3
6053
with:
6154
path: ${{ env.BASE_MASSIF_OUT }}
6255
key: ${{ runner.os }}-${{ env.BASE_REPO }}@${{ env.BASE_SHA }}-${{ env.TEST_REPO }}@${{ env.TEST_REF }}/${{ env.TEST_SRC }}
56+
#
57+
# Build code
58+
#
6359
- name: "Checkout base code"
6460
if: steps.cache-base-result.outputs.cache-hit != 'true'
6561
uses: actions/checkout@v3
@@ -73,6 +69,16 @@ jobs:
7369
working-directory: ${{ env.BASE_DIR }}
7470
env:
7571
CARGO_PROFILE_RELEASE_DEBUG: true
72+
#
73+
# Test performance
74+
#
75+
- name: Checkout test code
76+
if: steps.cache-base-result.outputs.cache-hit != 'true'
77+
uses: actions/checkout@v3
78+
with:
79+
repository: ${{ env.TEST_REPO }}
80+
ref: ${{ env.TEST_REF }}
81+
path: ${{ env.TEST_DIR }}
7682
- name: Profile base memory
7783
if: steps.cache-base-result.outputs.cache-hit != 'true'
7884
run: |
@@ -81,15 +87,56 @@ jobs:
8187
--massif-out-file=${{ env.BASE_MASSIF_OUT }} \
8288
${{ env.BASE_DIR }}/target/release/${{ env.TSSG_TS }} \
8389
analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }}
90+
ms_print ${{ env.BASE_MASSIF_OUT }} > ${{ env.BASE_REPORT }}
8491
#
85-
# Test head performance
92+
# Upload results
93+
#
94+
- name: Upload results
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: ${{ env.BASE_ARTIFACT }}
98+
path: |
99+
${{ env.BASE_MASSIF_OUT }}
100+
${{ env.BASE_REPORT }}
101+
##
102+
## Head performance
103+
##
104+
head-perf:
105+
runs-on: ubuntu-latest
106+
env:
107+
HEAD_REPO: ${{ github.event.pull_request.head.repo.owner.login }}/${{ github.event.pull_request.head.repo.name }}
108+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
109+
HEAD_DIR: head
110+
steps:
111+
#
112+
# Install tools
113+
#
114+
- name: Install Rust environment
115+
uses: hecrj/setup-rust-action@v1
116+
with:
117+
rust-version: stable
118+
- name: Cache Rust dependencies
119+
uses: actions/cache@v3
120+
with:
121+
path: |
122+
~/.cargo
123+
key: ${{ runner.OS }}-cargo-home
124+
- name: Install valgrind
125+
run: |
126+
sudo apt-get update
127+
sudo apt-get install -y valgrind
128+
#
129+
# Cache results
86130
#
87131
- name: "Cache head result"
88132
id: cache-head-result
89133
uses: actions/cache@v3
90134
with:
91135
path: ${{ env.HEAD_MASSIF_OUT }}
92136
key: ${{ runner.os }}-${{ env.HEAD_REPO }}@${{ env.HEAD_SHA}}-${{ env.TEST_REPO }}@${{ env.TEST_REF }}/${{ env.TEST_SRC }}
137+
#
138+
# Build code
139+
#
93140
- name: "Checkout head code"
94141
if: steps.cache-head-result.outputs.cache-hit != 'true'
95142
uses: actions/checkout@v3
@@ -103,6 +150,16 @@ jobs:
103150
working-directory: ${{ env.HEAD_DIR }}
104151
env:
105152
CARGO_PROFILE_RELEASE_DEBUG: true
153+
#
154+
# Test performance
155+
#
156+
- name: Checkout test code
157+
if: steps.cache-head-result.outputs.cache-hit != 'true'
158+
uses: actions/checkout@v3
159+
with:
160+
repository: ${{ env.TEST_REPO }}
161+
ref: ${{ env.TEST_REF }}
162+
path: ${{ env.TEST_DIR }}
106163
- name: Profile head memory
107164
if: steps.cache-head-result.outputs.cache-hit != 'true'
108165
run: |
@@ -111,6 +168,46 @@ jobs:
111168
--massif-out-file=${{ env.HEAD_MASSIF_OUT }} \
112169
${{ env.HEAD_DIR }}/target/release/${{ env.TSSG_TS }} \
113170
analyze --max-file-time=30 --hide-error-details -- ${{ env.TEST_DIR }}/${{ env.TEST_SRC }}
171+
ms_print ${{ env.HEAD_MASSIF_OUT }} > ${{ env.HEAD_REPORT }}
172+
#
173+
# Upload results
174+
#
175+
- name: Upload results
176+
uses: actions/upload-artifact@v3
177+
with:
178+
name: ${{ env.HEAD_ARTIFACT }}
179+
path: |
180+
${{ env.HEAD_MASSIF_OUT }}
181+
${{ env.HEAD_REPORT }}
182+
##
183+
## Performance summary
184+
##
185+
perf-summary:
186+
runs-on: ubuntu-latest
187+
needs:
188+
- base-perf
189+
- head-perf
190+
env:
191+
COMMENT_JSON: perf-summary.json
192+
steps:
193+
#
194+
# Install tools
195+
#
196+
- name: Install valgrind
197+
run: |
198+
sudo apt-get update
199+
sudo apt-get install -y valgrind
200+
#
201+
# Download results
202+
#
203+
- name: Download base results
204+
uses: actions/download-artifact@v3
205+
with:
206+
name: ${{ env.BASE_ARTIFACT }}
207+
- name: Download head results
208+
uses: actions/download-artifact@v3
209+
with:
210+
name: ${{ env.HEAD_ARTIFACT }}
114211
#
115212
# Create report
116213
#
@@ -120,24 +217,13 @@ jobs:
120217
repository: ${{ env.HEAD_REPO }}
121218
ref: ${{ env.HEAD_SHA }}
122219
path: ${{ env.HEAD_DIR }}
123-
- name: Generate reports and summary
220+
- name: Generate summary
124221
run: |
125-
ms_print ${{ env.BASE_MASSIF_OUT }} > ${{ env.BASE_REPORT }}
126-
ms_print ${{ env.HEAD_MASSIF_OUT }} > ${{ env.HEAD_REPORT }}
127222
${{ env.HEAD_DIR }}/script/ci-perf-summary-md \
128223
${{ env.BASE_MASSIF_OUT }} \
129224
${{ env.HEAD_MASSIF_OUT }} \
130225
'Comparing base ${{ env.BASE_REPO }}@${{ env.BASE_SHA }} with head ${{ env.HEAD_REPO }}@${{ env.HEAD_SHA }} on [${{ env.TEST_REPO }}@${{ env.TEST_REF }}](${{ github.server_url }}/${{ env.TEST_REPO }}/tree/${{ env.TEST_REF }}). For details see [workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) artifacts.' \
131226
| ${{ env.HEAD_DIR }}/script/ci-comment-json > ${{ env.COMMENT_JSON }}
132-
- name: Upload reports
133-
uses: actions/upload-artifact@v3
134-
with:
135-
name: performance-reports
136-
path: |
137-
${{ env.BASE_MASSIF_OUT }}
138-
${{ env.BASE_REPORT }}
139-
${{ env.HEAD_MASSIF_OUT }}
140-
${{ env.HEAD_REPORT }}
141227
- name: Add summary comment to PR
142228
run: |
143229
curl \

0 commit comments

Comments
 (0)