Skip to content

Commit

Permalink
mac debug; temporarily disable other ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyong1997 committed Aug 27, 2024
1 parent 8c66e75 commit 7606d38
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 174 deletions.
76 changes: 38 additions & 38 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: Run Benchmarks
# name: Run Benchmarks

on:
push:
pull_request:
# on:
# push:
# pull_request:

jobs:
benchmark:
runs-on: 7950x3d
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
run: python3 --version
- name: update toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Install criterion
run: cargo install cargo-criterion
- name: Run benchmark
run: RUSTFLAGS="-C target-cpu=native" cargo criterion --message-format=json > benchmark_results.json
- name: Clean benchmark results
run: |
wget https://raw.githubusercontent.com/PolyhedraZK/Expander-rs/main/scripts/parse_benchmark_result.py
python3 parse_benchmark_result.py benchmark_results.json benchmark_results_clean.json
- name: Upload benchmark results to Google Cloud Storage
run: |
commit_hash=$(git rev-parse HEAD)
repo_name="${GITHUB_REPOSITORY#*/}"
gsutil cp benchmark_results_clean.json gs://github_micro_bench/${repo_name}/benchmark_${commit_hash}.json
# jobs:
# benchmark:
# runs-on: 7950x3d
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Set up Python
# run: python3 --version
# - name: update toolchain
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# - name: 'Authenticate to Google Cloud'
# uses: 'google-github-actions/auth@v1'
# with:
# credentials_json: '${{ secrets.GCP_SA_KEY }}'
# - name: Set up Google Cloud SDK
# uses: google-github-actions/setup-gcloud@v1
# with:
# project_id: ${{ secrets.GCP_PROJECT_ID }}
# - name: Install criterion
# run: cargo install cargo-criterion
# - name: Run benchmark
# run: RUSTFLAGS="-C target-cpu=native" cargo criterion --message-format=json > benchmark_results.json
# - name: Clean benchmark results
# run: |
# wget https://raw.githubusercontent.com/PolyhedraZK/Expander-rs/main/scripts/parse_benchmark_result.py
# python3 parse_benchmark_result.py benchmark_results.json benchmark_results_clean.json
# - name: Upload benchmark results to Google Cloud Storage
# run: |
# commit_hash=$(git rev-parse HEAD)
# repo_name="${GITHUB_REPOSITORY#*/}"
# gsutil cp benchmark_results_clean.json gs://github_micro_bench/${repo_name}/benchmark_${commit_hash}.json
76 changes: 38 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: build-expander-exec
on:
release:
types: [released]
# name: build-expander-exec
# on:
# release:
# types: [released]

env:
RUSTFLAGS: "-Dwarnings"
RUST_BACKTRACE: 1
# env:
# RUSTFLAGS: "-Dwarnings"
# RUST_BACKTRACE: 1

jobs:
build:
strategy:
matrix:
platform: [macos, linux-avx2]
include:
- platform: macos
ci_image: macos-latest
flags: ''
- platform: linux-avx2
ci_image: ubuntu-latest
flags: 'RUSTFLAGS="-C target-feature=+avx2"'
runs-on: ${{ matrix.ci_image }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Prepare binary
run: ${{ matrix.flags }} cargo build --release --bin expander-exec
- name: Upload release asset
uses: actions/github-script@v6
with:
script: |
const fs = require('fs').promises;
github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: 'expander-exec-${{ matrix.platform }}',
data: await fs.readFile('target/release/expander-exec')
});
# jobs:
# build:
# strategy:
# matrix:
# platform: [macos, linux-avx2]
# include:
# - platform: macos
# ci_image: macos-latest
# flags: ''
# - platform: linux-avx2
# ci_image: ubuntu-latest
# flags: 'RUSTFLAGS="-C target-feature=+avx2"'
# runs-on: ${{ matrix.ci_image }}
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - name: Prepare binary
# run: ${{ matrix.flags }} cargo build --release --bin expander-exec
# - name: Upload release asset
# uses: actions/github-script@v6
# with:
# script: |
# const fs = require('fs').promises;
# github.rest.repos.uploadReleaseAsset({
# owner: context.repo.owner,
# repo: context.repo.repo,
# release_id: ${{ github.event.release.id }},
# name: 'expander-exec-${{ matrix.platform }}',
# data: await fs.readFile('target/release/expander-exec')
# });
146 changes: 73 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,76 +41,76 @@ jobs:
- run: cargo test -p bi-kzg --release
- run: cargo test --no-default-features --release
- run: cargo test --all-features --release
Bench-mac-m31-ext3:
name: Bench-mac-m31-ext3
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
- run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f m31ext3
Bench-mac-BN254:
name: Bench-mac-BN254
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
- run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f fr
Bench-mac-gf2-ext128:
name: Bench-mac-gf2ext128
runs-on: macos-latest
steps:
- uses: styfle/[email protected]
with:
all_but_latest: true
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: wget -P data https://storage.googleapis.com/expander-compiled-circuits/keccak-ci/gf2/circuit.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f gf2ext128
Test-linux:
name: Test-linux
runs-on: 7950x3d
steps:
- uses: actions/checkout@v4
- run: . "$HOME/.cargo/env"
- run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
- run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo test -p arith --release
- run: RUSTFLAGS="-C target-cpu=native" cargo test -p bi-kzg --release
- run: RUSTFLAGS="-C target-cpu=native" cargo test --no-default-features --release
- run: RUSTFLAGS="-C target-cpu=native" cargo test --all-features --release
Bench-linux-m31-ext3:
name: Bench-linux-m31-ext3
runs-on: 7950x3d
steps:
- uses: actions/checkout@v4
- run: . "$HOME/.cargo/env"
- run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
- run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f m31ext3
Bench-linux-BN254:
name: Bench-linux-BN254
runs-on: 7950x3d
steps:
- uses: actions/checkout@v4
- run: . "$HOME/.cargo/env"
- run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
- run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f fr
Bench-linux-gf2-ext128:
name: Bench-linux-gf2-ext128
runs-on: 7950x3d
steps:
- uses: styfle/[email protected]
with:
all_but_latest: true
- uses: actions/checkout@v4
- run: . "$HOME/.cargo/env"
- run: wget -P data https://storage.googleapis.com/expander-compiled-circuits/keccak-ci/gf2/circuit.txt
- run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f gf2ext128
# Bench-mac-m31-ext3:
# name: Bench-mac-m31-ext3
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
# - run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f m31ext3
# Bench-mac-BN254:
# name: Bench-mac-BN254
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
# - run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f fr
# Bench-mac-gf2-ext128:
# name: Bench-mac-gf2ext128
# runs-on: macos-latest
# steps:
# - uses: styfle/[email protected]
# with:
# all_but_latest: true
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# - run: wget -P data https://storage.googleapis.com/expander-compiled-circuits/keccak-ci/gf2/circuit.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 2 -f gf2ext128
# Test-linux:
# name: Test-linux
# runs-on: 7950x3d
# steps:
# - uses: actions/checkout@v4
# - run: . "$HOME/.cargo/env"
# - run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
# - run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo test -p arith --release
# - run: RUSTFLAGS="-C target-cpu=native" cargo test -p bi-kzg --release
# - run: RUSTFLAGS="-C target-cpu=native" cargo test --no-default-features --release
# - run: RUSTFLAGS="-C target-cpu=native" cargo test --all-features --release
# Bench-linux-m31-ext3:
# name: Bench-linux-m31-ext3
# runs-on: 7950x3d
# steps:
# - uses: actions/checkout@v4
# - run: . "$HOME/.cargo/env"
# - run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
# - run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f m31ext3
# Bench-linux-BN254:
# name: Bench-linux-BN254
# runs-on: 7950x3d
# steps:
# - uses: actions/checkout@v4
# - run: . "$HOME/.cargo/env"
# - run: wget -P data https://storage.googleapis.com/keccak8/circuit.txt
# - run: wget -P data https://storage.googleapis.com/keccak8/witness.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f fr
# Bench-linux-gf2-ext128:
# name: Bench-linux-gf2-ext128
# runs-on: 7950x3d
# steps:
# - uses: styfle/[email protected]
# with:
# all_but_latest: true
# - uses: actions/checkout@v4
# - run: . "$HOME/.cargo/env"
# - run: wget -P data https://storage.googleapis.com/expander-compiled-circuits/keccak-ci/gf2/circuit.txt
# - run: RUSTFLAGS="-C target-cpu=native" cargo run --release -- -t 16 -f gf2ext128
33 changes: 16 additions & 17 deletions arith/benches/ext_field.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use arith::{Field, BinomialExtensionField, GF2_128x8, M31Ext3, M31Ext3x16, GF2_128};
use arith::{BinomialExtensionField, Field, GF2_128x8, M31Ext3, M31Ext3x16, GF2_128};
use ark_std::test_rng;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use tynm::type_name;
Expand All @@ -8,7 +8,7 @@ fn random_element<F: Field>() -> F {
F::random_unsafe(&mut rng)
}

pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
pub(crate) fn bench_field<F: Field + BinomialExtensionField>(c: &mut Criterion) {
c.bench_function(
&format!(
"mul-by-base-throughput<{}> 100x times {}x ",
Expand All @@ -31,7 +31,12 @@ pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
},
|(mut x, mut y, mut z, mut w, xx, yy, zz, ww)| {
for _ in 0..25 {
(x, y, z, w) = (x.mul_by_base_field(&xx), y.mul_by_base_field(&yy), z.mul_by_base_field(&zz), w.mul_by_base_field(&ww));
(x, y, z, w) = (
x.mul_by_base_field(&xx),
y.mul_by_base_field(&yy),
z.mul_by_base_field(&zz),
w.mul_by_base_field(&ww),
);
}
(x, y, z, w)
},
Expand All @@ -48,12 +53,7 @@ pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
),
|b| {
b.iter_batched(
|| {
(
random_element::<F>(),
random_element::<F::BaseField>(),
)
},
|| (random_element::<F>(), random_element::<F::BaseField>()),
|(mut x, xx)| {
for _ in 0..100 {
x = x.mul_by_base_field(&xx);
Expand Down Expand Up @@ -87,7 +87,12 @@ pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
},
|(mut x, mut y, mut z, mut w, xx, yy, zz, ww)| {
for _ in 0..25 {
(x, y, z, w) = (x.add_by_base_field(&xx), y.add_by_base_field(&yy), z.add_by_base_field(&zz), w.add_by_base_field(&ww));
(x, y, z, w) = (
x.add_by_base_field(&xx),
y.add_by_base_field(&yy),
z.add_by_base_field(&zz),
w.add_by_base_field(&ww),
);
}
(x, y, z, w)
},
Expand All @@ -104,12 +109,7 @@ pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
),
|b| {
b.iter_batched(
|| {
(
random_element::<F>(),
random_element::<F::BaseField>(),
)
},
|| (random_element::<F>(), random_element::<F::BaseField>()),
|(mut x, xx)| {
for _ in 0..100 {
x = x.add_by_base_field(&xx);
Expand All @@ -120,7 +120,6 @@ pub(crate) fn bench_field<F: Field+BinomialExtensionField>(c: &mut Criterion) {
)
},
);

}

fn ext_by_base_benchmark(c: &mut Criterion) {
Expand Down
Loading

0 comments on commit 7606d38

Please sign in to comment.