From 13091e0de4fe5b1d0487f3e441f9e892b12b8843 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 26 May 2025 12:02:48 +0200 Subject: [PATCH 1/3] ci: add cdp-bench The cdp bench is run on self host machine. --- .github/workflows/e2e-test.yml | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index a8b115fd5..b5bd20143 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -135,3 +135,84 @@ jobs: ./lightpanda serve & echo $! > LPD.pid go run runner/main.go --verbose kill `cat LPD.pid` + + cdp-bench: + name: cdp-bench + needs: zig-build-release + + # use a self host runner. + runs-on: lpd_bench_m5.large + timeout-minutes: 15 + + steps: + - uses: actions/checkout@v4 + with: + repository: 'lightpanda-io/demo' + fetch-depth: 0 + + - run: npm install + + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: lightpanda-build-release + + - run: chmod a+x ./lightpanda + + - name: run puppeteer + run: | + go run ws/main.go & echo $! > WS.pid + ./lightpanda serve & echo $! > LPD.pid + RUNS=100 npm run bench-puppeteer-cdp > puppeteer.out || exit 1 + cat /proc/`cat LPD.pid`/status |grep VmHWM|grep -oP '\d+' > LPD.VmHWM + kill `cat LPD.pid` `cat WS.pid` + + - name: puppeteer result + run: cat puppeteer.out + + - name: json output + run: | + export AVG_DURATION=`cat puppeteer.out|grep 'avg run'|sed 's/avg run duration (ms) //'` + export TOTAL_DURATION=`cat puppeteer.out|grep 'total duration'|sed 's/total duration (ms) //'` + export LPD_VmHWM=`cat LPD.VmHWM` + echo "{\"duration_total\":${TOTAL_DURATION},\"duration_avg\":${AVG_DURATION},\"mem_peak\":${LPD_VmHWM}}" > bench.json + cat bench.json + + - name: write commit + run: | + echo "${{github.sha}}" > commit.txt + + - name: upload artifact + uses: actions/upload-artifact@v4 + with: + name: bench-results + path: | + bench.json + commit.txt + retention-days: 10 + + + cpd-bench-fmt: + name: perf-fmt + needs: cdp-bench + + # Don't execute on PR + if: github.event_name != 'pull_request' + + runs-on: ubuntu-latest + timeout-minutes: 15 + + container: + image: ghcr.io/lightpanda-io/perf-fmt:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + steps: + - name: download artifact + uses: actions/download-artifact@v4 + with: + name: bench-results + + - name: format and send json result + run: /perf-fmt cdp ${{ github.sha }} bench.json From 8c1f38f74d0ef16f8ffbc54052ce055d01c977f3 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 26 May 2025 12:15:16 +0200 Subject: [PATCH 2/3] ci: e2e: build release w/ -Dcpu=x86_64 option --- .github/workflows/e2e-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b5bd20143..59ebc7a54 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -48,7 +48,7 @@ jobs: - uses: ./.github/actions/install - name: zig build release - run: zig build -Doptimize=ReleaseSafe + run: zig build --release=safe -Doptimize=ReleaseSafe -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: upload artifact uses: actions/upload-artifact@v4 From 087d23269b44a86e35d9aa36240f3e521b841e44 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 26 May 2025 17:48:30 +0200 Subject: [PATCH 3/3] ci: add hyperfine test --- .github/workflows/e2e-test.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 59ebc7a54..f8e930d39 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -136,8 +136,8 @@ jobs: go run runner/main.go --verbose kill `cat LPD.pid` - cdp-bench: - name: cdp-bench + cdp-and-hyperfine-bench: + name: cdp-and-hyperfine-bench needs: zig-build-release # use a self host runner. @@ -178,6 +178,12 @@ jobs: echo "{\"duration_total\":${TOTAL_DURATION},\"duration_avg\":${AVG_DURATION},\"mem_peak\":${LPD_VmHWM}}" > bench.json cat bench.json + - name: run hyperfine + run: | + go run ws/main.go & echo $! > WS.pid + hyperfine --export-json=hyperfine.json --warmup 3 --runs 20 --shell=none "./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/" + kill `cat WS.pid` + - name: write commit run: | echo "${{github.sha}}" > commit.txt @@ -188,11 +194,12 @@ jobs: name: bench-results path: | bench.json + hyperfine.json commit.txt retention-days: 10 - cpd-bench-fmt: + perf-fmt: name: perf-fmt needs: cdp-bench @@ -216,3 +223,6 @@ jobs: - name: format and send json result run: /perf-fmt cdp ${{ github.sha }} bench.json + + - name: format and send json result + run: /perf-fmt hyperfine ${{ github.sha }} hyperfine.json