Merge pull request #258 from zcash/ci-benchmarks

CI: Benchmark tweaks
This commit is contained in:
str4d 2021-12-15 23:14:33 +00:00 committed by GitHub
commit a5de219cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 24 deletions

View File

@ -1,29 +1,35 @@
name: Benchmarks
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
permissions:
contents: write
deployments: write
jobs:
build:
name: Run orchard benchmarks
benchmark:
name: Performance regression check
runs-on: ubuntu-latest
env:
CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Run benchmarks
run: |
# run benchmarks and save baseline in a directory called "new"
cargo bench -- --verbose
- name: Upload benchmarks
run: |
# upload the files
bash <(curl -s https://criterion.dev/bash)
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.51.0
override: true
- name: Run benchmark
run: cargo bench -- --output-format bencher | tee output.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: Orchard Benchmarks
tool: 'cargo'
output-file-path: output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@str4d'

View File

@ -25,7 +25,7 @@ fn criterion_benchmark(c: &mut Criterion) {
let vk = VerifyingKey::build();
let pk = ProvingKey::build();
for num_recipients in 1..=4 {
let create_bundle = |num_recipients| {
let mut builder = Builder::new(
Flags::from_parts(true, true),
Anchor::from_bytes([0; 32]).unwrap(),
@ -43,9 +43,16 @@ fn criterion_benchmark(c: &mut Criterion) {
.map(|a| a.to_instance(*bundle.flags(), *bundle.anchor()))
.collect();
{
let mut group = c.benchmark_group("proving");
group.sample_size(10);
(bundle, instances)
};
let recipients_range = 1..=4;
{
let mut group = c.benchmark_group("proving");
group.sample_size(10);
for num_recipients in recipients_range.clone() {
let (bundle, instances) = create_bundle(num_recipients);
group.bench_function(BenchmarkId::new("bundle", num_recipients), |b| {
b.iter(|| {
bundle
@ -55,9 +62,12 @@ fn criterion_benchmark(c: &mut Criterion) {
});
});
}
}
{
let mut group = c.benchmark_group("verifying");
{
let mut group = c.benchmark_group("verifying");
for num_recipients in recipients_range {
let (bundle, instances) = create_bundle(num_recipients);
let bundle = bundle
.create_proof(&pk)
.unwrap()