Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add YAS benchmark runner on the CI. #1236

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/bench-yas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Bench

on:
pull_request:
branches: [main]
merge_group:
types: [checks_requested]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
bench-yas:
name: YAS benchmark
runs-on: ubuntu-latest
env:
CAIRO_NATIVE_RUNTIME_LIBDIR: ${{ github.workspace }}/target/release
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
MLIR_SYS_170_PREFIX: /usr/lib/llvm-17/
TABLEGEN_170_PREFIX: /usr/lib/llvm-17/
steps:
- uses: actions/checkout@v3
- name: check and free hdd space left
run: |
echo "Listing 20 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 20
df -h
sudo apt-get update
sudo apt-get remove -y '^llvm-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y '^temurin-.*'
sudo apt-get remove -y azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
# deleting 15GB
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/lib/android
df -h
- uses: dtolnay/[email protected]
with:
components: clippy
- name: Python3 Build
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- uses: Swatinem/rust-cache@v2
- name: add llvm deb repository
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main
repo-name: llvm-repo
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
- name: Install LLVM
run: sudo apt-get install llvm-17 llvm-17-dev llvm-17-runtime clang-17 clang-tools-17 lld-17 libpolly-17-dev libmlir-17-dev mlir-17-tools
- name: Install deps
run: make deps
- name: Build project
run: make build
- name: Run benchmarks
run: ./scripts/bench-yas.sh

- name: Find Bench Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Benchmarking
- name: Create or update bench comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: bench-yas.md
edit-mode: replace
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.72.1"
channel = "1.74.1"
components = ["rustfmt", "clippy"]
profile = "minimal"
34 changes: 34 additions & 0 deletions scripts/bench-yas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
run_bench() {
local OUTPUT=$(${*:2})
local NUM_EXECS=$(echo $OUTPUT | cut -d' ' -f3)
local TOTAL_TIME=$(echo $OUTPUT | cut -d' ' -f6)
local EXEC_SPEED=$(echo $OUTPUT | cut -d' ' -f8 | cut -c2-)
local EXEC_TIME=$(echo $OUTPUT | cut -d' ' -f11)

if [[ -z "$NUM_EXECS" || -z "$TOTAL_TIME" || -z "$EXEC_SPEED" || -z "$EXEC_TIME" ]]; then
echo "| $1 | CRASHED | CRASHED | CRASHED | CRASHED |"
else
echo "| $1 | $NUM_EXECS | $TOTAL_TIME | $EXEC_SPEED | $EXEC_TIME |"
fi
}

# Clone cairo native and build the runtime.
git clone https://github.com/lambdaclass/cairo_native.git cairo-native
cd cairo-native/
cargo build --release --package cairo-native-runtime
cd ..

# Run the benches.
export CAIRO_NATIVE_RUNTIME_LIBDIR="$(pwd)/cairo-native/target/release"
BENCH_VM=$(run_bench "VM" cargo bench --bench yas)
BENCH_JIT=$(run_bench "Native JIT" cargo bench --bench yas --features=cairo-native -- jit)
BENCH_AOT=$(run_bench "Native AOT" cargo bench --bench yas --features=cairo-native -- aot)

# Write the results.
echo "# Benchmarking results" > bench-yas.md
echo "" >> bench-yas.md
echo "| Name | Number of runs | Total time (s) | Speed (#/s) | Individual time (s/#) |" >> bench-yas.md
echo "|------|----------------|----------------|-------------|-----------------------|" >> bench-yas.md
echo $BENCH_VM >> bench-yas.md
echo $BENCH_JIT >> bench-yas.md
echo $BENCH_AOT >> bench-yas.md
Loading