-
Notifications
You must be signed in to change notification settings - Fork 166
135 lines (120 loc) · 5.1 KB
/
perf.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
name: Perf CI
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
# Checks if any concurrent jobs under the same pull request or branch are being executed
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-perf
cancel-in-progress: true
jobs:
perf-libs-linux-amd64:
runs-on: [ "self-hosted", "linux", "X64" ]
steps:
- name: Checkout Libs ⤵️
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Install deps ⛓️
run: |
sudo apt update && sudo apt install -y --no-install-recommends ca-certificates cmake build-essential git clang llvm pkg-config autoconf automake libtool libelf-dev wget libc-ares-dev libcurl4-openssl-dev libssl-dev libtbb-dev libjq-dev libjsoncpp-dev libgrpc++-dev protobuf-compiler-grpc libgtest-dev libprotobuf-dev
sudo .github/install-deps.sh
- name: Build
run: |
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=False ../
make unit-test-libsinsp -j4
make sinsp-example -j4
- name: Run Perf - unit tests
shell: bash
run: |
cd build
sudo perf record --call-graph dwarf -o perf_tests.data -q libsinsp/test/unit-test-libsinsp
- name: Run Perf - scap file
shell: bash
run: |
cd build
wget https://download.falco.org/fixtures/trace-files/traces-positive.zip
unzip traces-positive.zip
sudo perf record --call-graph dwarf -o perf_scap.data -q ./libsinsp/examples/sinsp-example -s traces-positive/falco-event-generator.scap
- name: Archive master perf report
if: github.event_name == 'push'
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: perf_report
retention-days: 30 # 30 days because this is the artifact on master; we need to retain it to be able to properly diff it
path: build/perf_*.data
if-no-files-found: error
- name: Download latest master report
if: github.event_name == 'pull_request'
uses: dawidd6/action-download-artifact@v6
with:
workflow: perf.yml
branch: master
event: push
name: perf_report
- name: Diff from master - unit tests
if: github.event_name == 'pull_request'
run: |
sudo perf diff perf_tests.data build/perf_tests.data -d unit-test-libsinsp -b -o 1 --percentage relative -q &> perf_tests_diff.txt
- name: Diff from master - scap file
if: github.event_name == 'pull_request'
run: |
sudo perf diff perf_scap.data build/perf_scap.data -d sinsp-example -b -o 1 --percentage relative -q &> perf_scap_diff.txt
- name: Archive perf diff
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: perf_diff
path: perf_*_diff.txt
if-no-files-found: error
# Check will fail if there is any function slowed down >2%
# But we will always comment with the perf diff from master
- name: Check > 2% threshold - unit tests
if: github.event_name == 'pull_request'
id: compare_tests
run: |
echo "diff=perf_tests_diff.txt" >> $GITHUB_OUTPUT
awk '{if (substr($2,RSTART+RLENGTH)+0 > 2) print }' perf_tests_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi
# Check will fail if there is any function slowed down >2%
# But we will always comment with the perf diff from master
- name: Check > 2% threshold - scap file
if: github.event_name == 'pull_request'
id: compare_scap
run: |
echo "diff=perf_scap_diff.txt" >> $GITHUB_OUTPUT
awk '{if (substr($2,RSTART+RLENGTH)+0 > 2) print }' perf_scap_diff.txt &> perf_diff_above_thresh.txt
if [ -s perf_diff_above_thresh.txt ]; then
exit 1
fi
- name: Save PR info
if: always() && github.event_name == 'pull_request'
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
touch ./pr/COMMENT
echo "# Perf diff from master - unit tests" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
head -n10 "${{ steps.compare_tests.outputs.diff }}" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo "" >> ./pr/COMMENT
echo "# Perf diff from master - scap file" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
head -n10 "${{ steps.compare_scap.outputs.diff }}" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo Uploading PR info...
cat ./pr/COMMENT
echo ""
- name: Upload PR info as artifact
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: pr
path: pr/
retention-days: 1
if-no-files-found: warn