|
| 1 | +name: Benchmark |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + RUST_BACKTRACE: 1 |
| 10 | + ENTRY_COUNT: 4000000 |
| 11 | + |
| 12 | +jobs: |
| 13 | + benchmark_qmdb: |
| 14 | + name: QMDB Benchmark |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - uses: actions/cache@v4 |
| 21 | + with: |
| 22 | + path: | |
| 23 | + ~/.cargo/bin/ |
| 24 | + ~/.cargo/registry/index/ |
| 25 | + ~/.cargo/registry/cache/ |
| 26 | + ~/.cargo/git/db/ |
| 27 | + target/ |
| 28 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}-${{ github.sha }}-bench |
| 29 | + restore-keys: | |
| 30 | + ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}-${{ github.sha }} |
| 31 | + ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }} |
| 32 | + ${{ runner.os }}-cargo- |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + sudo apt-get install g++ linux-libc-dev libclang-dev unzip libjemalloc-dev make -y |
| 37 | + sudo apt-get install -y time |
| 38 | +
|
| 39 | + - name: Build Release (QMDB) |
| 40 | + run: cargo build --bin speed --release |
| 41 | + |
| 42 | + - name: Generate randsrc.dat |
| 43 | + run: head -c 10M </dev/urandom > randsrc.dat |
| 44 | + |
| 45 | + - name: Log runner stats |
| 46 | + run: | |
| 47 | + echo "Runner stats:" |
| 48 | + echo "CPU: $(nproc)" |
| 49 | + echo "RAM: $(echo "scale=2; $(free -m | awk '/^Mem:/{print $2}') / 1024" | bc) GB" |
| 50 | + echo "Disk space: $(df -h . | awk 'NR==2{print $4}')" |
| 51 | +
|
| 52 | + - name: Run QMDB benchmark |
| 53 | + run: | |
| 54 | + set -o pipefail |
| 55 | + ulimit -n 65535 |
| 56 | + /usr/bin/time -v cargo run --bin speed --release -- --entry-count $ENTRY_COUNT --hover-interval 1 --hover-recreate-block 1 --hover-write-block 1 --tps-blocks 1 --output-filename qmdb_results.json 2> >(tee qmdb_results.txt) |
| 57 | +
|
| 58 | + - name: Parse and store QMDB benchmark results |
| 59 | + run: | |
| 60 | + parse_results() { |
| 61 | + local results_file="qmdb_results.txt" |
| 62 | + local json_file="qmdb_benchmark.json" |
| 63 | +
|
| 64 | + local peak_mem_kb=$(grep "Maximum resident set size" $results_file | awk '{print $6}') |
| 65 | + local peak_mem_gb=$(echo "scale=2; $peak_mem_kb / 1048576" | bc) |
| 66 | + local user_time=$(grep "User time" $results_file | awk '{print $4}') |
| 67 | + local sys_time=$(grep "System time" $results_file | awk '{print $4}') |
| 68 | +
|
| 69 | + echo "{ |
| 70 | + \"peak_memory_gb\": $peak_mem_gb, |
| 71 | + \"user_time_seconds\": $user_time, |
| 72 | + \"system_time_seconds\": $sys_time |
| 73 | + }" > $json_file |
| 74 | + } |
| 75 | +
|
| 76 | + parse_results |
| 77 | +
|
| 78 | + - name: Upload QMDB benchmark results as artifact |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: qmdb-benchmark-results |
| 82 | + path: qmdb_results.json |
| 83 | + |
| 84 | + - name: Parse results.json for benchmark-action |
| 85 | + run: | |
| 86 | + python3 bench/results2benchmark.py qmdb_results.json benchmark-data.json |
| 87 | +
|
| 88 | + - name: Store benchmark result |
| 89 | + uses: benchmark-action/github-action-benchmark@v1 |
| 90 | + if: github.event_name != 'pull_request' |
| 91 | + with: |
| 92 | + tool: 'customBiggerIsBetter' |
| 93 | + output-file-path: benchmark-data.json |
| 94 | + fail-on-alert: true |
| 95 | + # GitHub API token to make a commit comment |
| 96 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + # Enable alert commit comment |
| 98 | + comment-on-alert: true |
| 99 | + # alert-comment-cc-users: '@USER' |
0 commit comments