From 4b9b05a46d459146b4e12d19764363cc9452bfb3 Mon Sep 17 00:00:00 2001 From: Dylan Socolobsky Date: Mon, 2 Dec 2024 10:34:38 -0300 Subject: [PATCH] Run flamegraph reporting in Github CI --- .github/scripts/flamegraph.sh | 26 +++++++++++++++++ .github/workflows/flamegraph_reporter.yaml | 34 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/scripts/flamegraph.sh create mode 100644 .github/workflows/flamegraph_reporter.yaml diff --git a/.github/scripts/flamegraph.sh b/.github/scripts/flamegraph.sh new file mode 100644 index 0000000000..23eb075cc7 --- /dev/null +++ b/.github/scripts/flamegraph.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +account=0x33c6b73432B3aeA0C1725E415CC40D04908B85fd +end_val=$((172 * 1000 * 10000000)) + +cd ../../ + +echo "Running ethrex..." +CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --bin ethrex --features dev -- --network test_data/genesis-l2.json --http.port 1729 & +echo "Sleeping 10s before running test..." +sleep 10 +echo "Sending to account $account" +ethrex_l2 test load --path ./test_data/private_keys.txt -i 1000 -v --value 10000000 --to $account + +echo "Monitoring..." +output=$(cast balance $account --rpc-url=http://localhost:1729 2>&1) +echo "ini $output" +echo "end $end_val" +while [[ $output -le $end_val ]]; do + sleep 5 + output=$(cast balance $account --rpc-url=http://localhost:1729 2>&1) + echo "out $output" +done +echo "Balance of $output reached, killing process ethrex" + +sudo pkill ethrex && while pgrep -l cargo flamegraph; do sleep 1;done; diff --git a/.github/workflows/flamegraph_reporter.yaml b/.github/workflows/flamegraph_reporter.yaml new file mode 100644 index 0000000000..c864298835 --- /dev/null +++ b/.github/workflows/flamegraph_reporter.yaml @@ -0,0 +1,34 @@ +name: Daily Flamegraph Reporter + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "**" ] + workflow_dispatch: + +env: + RUST_VERSION: 1.81.0 + +jobs: + flamegraph: + name: Generate Flamegraph for load test + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Rustup toolchain install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_VERSION }} + + - name: Install flamegraph + run: cargo install flamegraph + + - name: Caching + uses: Swatinem/rust-cache@v2 + + - name: Generate Flamegraph for Ethrex + run: | + sh .github/scripts/flamegraph.sh