benchmarks.yml
1 name: Run snarkVM Benchmarks 2 3 on: 4 push: 5 branches: 6 - 'staging' 7 workflow_dispatch: 8 9 jobs: 10 # Run benchmarks and stores the output to a file 11 benchmark: 12 name: Benchmark 13 runs-on: ubuntu-latest 14 permissions: 15 contents: write 16 steps: 17 - name: Checkout 18 uses: actions/checkout@v5 19 20 - name: Install Rust 21 uses: dtolnay/rust-toolchain@stable 22 23 - name: Install required Debian pacakges 24 run: sudo apt install -y lld 25 26 - uses: actions/cache@v4 27 with: 28 path: | 29 ~/.cargo/registry 30 ~/.cargo/git 31 target 32 key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }} 33 34 - name: Benchmark algorithms 35 run: | 36 cd algorithms 37 cargo bench --locked --bench variable_base -- --output-format bencher | tee -a ../output.txt 38 cargo bench --locked --bench poseidon_sponge -- --output-format bencher | tee -a ../output.txt 39 cargo bench --bench varuna -- --output-format bencher | tee -a ../output.txt 40 cd .. 41 42 - name: Benchmark circuit/environment 43 run: | 44 cd circuit/environment 45 cargo bench --locked --bench linear_combination -- --output-format bencher | tee -a ../../output.txt 46 cd ../.. 47 48 - name: Benchmark console/account 49 run: | 50 cd console/account 51 cargo bench --locked --bench account -- --output-format bencher | tee -a ../../output.txt 52 cd ../.. 53 54 - name: Benchmark console/algorithms 55 run: | 56 cd console/algorithms 57 cargo bench --locked --bench poseidon -- --output-format bencher | tee -a ../../output.txt 58 cargo bench --locked --bench elligator2 -- --output-format bencher | tee -a ../../output.txt 59 cd ../.. 60 61 - name: Benchmark console/collections 62 run: | 63 cd console/collections 64 cargo bench --locked --bench merkle_tree -- --output-format bencher | tee -a ../../output.txt 65 cd ../.. 66 67 - name: Benchmark console/types 68 run: | 69 cd console/types 70 cargo bench --locked --bench group -- --output-format bencher | tee -a ../../output.txt 71 cd ../.. 72 73 - name: Benchmark curves 74 run: | 75 cd curves 76 cargo bench --locked --bench curves -- --output-format bencher | tee -a ../output.txt 77 cd .. 78 79 - name: Benchmark ledger (block) 80 run: | 81 cargo bench --package=snarkvm-ledger --bench block --features=rocks,test-helpers,test -- --output-format bencher | tee -a output.txt 82 83 - name: Benchmark ledger (dag) 84 run: | 85 cargo bench --package=snarkvm-ledger --bench dag -- --output-format bencher | tee -a output.txt 86 87 - name: Benchmark ledger (transaction) 88 run: | 89 cargo bench --package=snarkvm-ledger --bench transaction -- --output-format bencher | tee -a output.txt 90 91 - name: Benchmark ledger (store) 92 run: | 93 cargo bench --package=snarkvm-ledger --bench store -- --output-format bencher | tee -a output.txt 94 95 - name: Benchmark ledger/puzzle 96 run: | 97 cargo bench --package=snarkvm-ledger-puzzle --bench puzzle --features=setup -- --output-format bencher | tee -a output.txt 98 99 # Clean benchmark output to remove unnecessary lines 100 - name: Clean benchmark output 101 run: | 102 sed -n -i '/bench:/p' output.txt 103 104 # Download previous benchmark result from cache (if exists) 105 - name: Download previous benchmark data 106 uses: actions/cache@v4 107 with: 108 path: ./cache 109 key: ${{ runner.os }}-benchmark 110 111 - name: Store benchmark result 112 uses: benchmark-action/github-action-benchmark@v1 113 with: 114 name: snarkVM Benchmarks 115 tool: 'cargo' 116 output-file-path: output.txt 117 github-token: ${{ secrets.GITHUB_TOKEN }} 118 alert-threshold: '150%' 119 comment-on-alert: true 120 fail-on-alert: true 121 alert-comment-cc-users: '@raychu86' 122 # Only push the results on staging (see below) 123 auto-push: false 124 # Enable Job Summary for PRs 125 summary-always: true 126 127 - name: Push benchmark result 128 # Avoid pushing results on pull requests or experimental branches, to reduce noise in the data. 129 # The results for all other runs are still accessible through the workflow summary. 130 if: github.ref_name == 'staging' 131 env: 132 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 133 run: git push origin gh-pages