Skip to content

Commit

Permalink
new(ci): add google benchmarks tests to perf ci.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Aug 27, 2024
1 parent 696c09c commit b8ded59
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/actions/composite-perf/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ outputs:
heaptrack_scap:
description: "Scap file heaptrack data"
value: ${{ steps.store-outputs.outputs.heaptrack_scap }}
gbench_json:
description: "Google benchmarks json data"
value: ${{ steps.store-outputs.outputs.gbench_json }}

runs:
using: "composite"
Expand All @@ -28,8 +31,9 @@ runs:
shell: bash
run: |
mkdir -p build
cd build && cmake -DUSE_BUNDLED_DEPS=False -DCMAKE_BUILD_TYPE=Debug ../
cd build && cmake -DUSE_BUNDLED_DEPS=False -DCMAKE_BUILD_TYPE=Debug -DENABLE_BENCHMARKS=True ../
make unit-test-libsinsp -j4
make bench -j4
make sinsp-example -j4
- name: Download scap file
Expand Down Expand Up @@ -70,6 +74,12 @@ runs:
cd build
sudo heaptrack -o heaptrack_scap.data ./libsinsp/examples/sinsp-example -s traces-positive/falco-event-generator.scap
- name: Run - gbench
shell: bash
run: |
cd build
./benchmark/bench --benchmark_report_aggregates_only --benchmark_out=gbench_data.json --benchmark_out_format=json
- name: Set Outputs
id: store-outputs
shell: bash
Expand All @@ -79,3 +89,4 @@ runs:
echo "perf_scap=$(realpath perf_scap.data)" >> $GITHUB_OUTPUT
echo "heaptrack_tests=$(realpath heaptrack_tests.data.zst)" >> $GITHUB_OUTPUT
echo "heaptrack_scap=$(realpath heaptrack_scap.data.zst)" >> $GITHUB_OUTPUT
echo "gbench_json=$(realpath gbench_data.json)" >> $GITHUB_OUTPUT
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
${{ steps.perf.outputs.perf_scap }}
${{ steps.perf.outputs.heaptrack_tests }}
${{ steps.perf.outputs.heaptrack_scap }}
${{ steps.perf.outputs.gbench_json }}
if-no-files-found: error

- name: Checkout Flamegraph ⤵️
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ jobs:
run: |
sudo heaptrack_print heaptrack_scap.data.zst -d ${{ steps.perf.outputs.heaptrack_scap }} &> heaptrack_scap_diff.txt
- name: Diff from master - gbench
run: |
sudo apt update && sudo apt install -y --no-install-recommends jq
echo "test | master | head | diff | diff %" > gbench_diff.txt
# Load keys from master gbench json
keys=$(jq -r '.benchmarks[] | select(.name | test("_mean")) | .name' gbench_data.json)
for key in $keys; do
# Load master real time value
master_val=$(jq -r '.benchmarks[] | select(.name == "$key") | .real_time' gbench_data.json)
# Load PR head real time value
head_val=$(jq -r '.benchmarks[] | select(.name == "$key") | .real_time' ${{ steps.perf.outputs.gbench_json }})
# Only dump existing keys in current head (ie: if test was renamed/removed, skip it)
if [[ ! -z $head_val ]]; then
diff_val=$(jq -n '$head_val-$master_val')
diff_val_pct=$(jq -n '$diff_val/$master_val*100')
echo "$key | $master_val | $head_val | $diff_val | $diff_val_pct" >> gbench_diff.txt
fi
done
- name: Archive perf diff
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
Expand Down Expand Up @@ -75,6 +94,10 @@ jobs:
echo "\`\`\`" >> ./pr/COMMENT
tail -n3 "heaptrack_scap_diff.txt" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo "# Benchmarks diff from master" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
cat "gbench_diff.txt" >> ./pr/COMMENT
echo "\`\`\`" >> ./pr/COMMENT
echo Uploading PR info...
cat ./pr/COMMENT
echo ""
Expand Down Expand Up @@ -135,3 +158,14 @@ jobs:
if [ -s heaptrack_scap_diff_above_thresh.txt ]; then
exit 2
fi
# Check will fail if there any google benchmark is slowed more than 5%
- name: Check >= 5% slowdown on google benchmarks
if: always() # Even if other threshold checks failed
run: |
tail -n+2 gbench_diff.txt | while read p; do
diff_pct=$(echo $p | awk '{print $NF}')
if (( $(echo "$diff_pct >= 5.0" | bc -l) )); then
exit 1
fi
done

0 comments on commit b8ded59

Please sign in to comment.