Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Parameterize BenchmarkId on output type in PR bench comments #829

Merged
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
9 changes: 9 additions & 0 deletions .github/workflows/bench-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ jobs:
run: sudo apt-get install -y pkg-config libssl-dev
- uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v2
- name: Load env vars
run: |
set -a
source bench.env
set +a
echo "LURK_BENCH_OUTPUT=pr-comment" >> $GITHUB_ENV
env | grep -E 'LURK|EC_GPU|CUDA'
working-directory: ${{ github.workspace }}/benches
# Run the comparative benchmark and comment output on the PR
- uses: boa-dev/criterion-compare-action@v3
with:
Expand Down Expand Up @@ -77,6 +85,7 @@ jobs:
set -a
source bench.env
set +a
echo "LURK_BENCH_OUTPUT=pr-comment" >> $GITHUB_ENV
env | grep -E 'LURK|EC_GPU|CUDA'
working-directory: ${{ github.workspace }}/benches
# Run the comparative benchmark and comment output on the PR
Expand Down
83 changes: 44 additions & 39 deletions benches/fibonacci_lem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,73 @@ impl ProveParams {
fn name(&self) -> String {
format!("Fibonacci-rc={}", self.reduction_count)
}

fn params(&self) -> String {
let output_type = bench_parameters_env().unwrap_or("stdout".into());
match output_type.as_ref() {
"pr-comment" => format!("num-{}", self.fib_n),
"commit-comment" => todo!(),
"gh-pages" => todo!(),
_ => format!("num-{}/{}-{}", self.fib_n, self.sha, self.date),
}
}
}

fn bench_parameters_env() -> anyhow::Result<String> {
std::env::var("LURK_BENCH_OUTPUT")
.map_err(|e| anyhow!("Noise threshold env var isn't set: {e}"))
}
Comment on lines +64 to +77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this stage, this probably indicates we want to document what folks are allowed to put in the variables defined in the env file.


fn rc_env() -> anyhow::Result<Vec<usize>> {
std::env::var("LURK_RC")
.map_err(|e| anyhow!("Reduction count env var isn't set: {e}"))
.and_then(|rc| {
let vec: anyhow::Result<Vec<usize>> = rc
.split(',')
.map(|rc| {
rc.parse::<usize>()
.map_err(|e| anyhow!("Failed to parse RC: {e}"))
})
.collect();
vec
})
}

fn noise_threshold_env() -> anyhow::Result<f64> {
std::env::var("LURK_BENCH_NOISE_THRESHOLD")
.map_err(|e| anyhow!("Noise threshold env var isn't set: {e}"))
.and_then(|nt| {
nt.parse::<f64>()
.map_err(|e| anyhow!("Failed to parse noise threshold: {e}"))
})
}

fn fibo_prove<M: measurement::Measurement>(
prove_params: ProveParams,
c: &mut BenchmarkGroup<'_, M>,
state: &Rc<RefCell<State>>,
) {
let ProveParams {
fib_n,
reduction_count,
date,
sha,
} = prove_params;

let limit = fib_limit(fib_n, reduction_count);
let limit = fib_limit(prove_params.fib_n, prove_params.reduction_count);
let lang_pallas = Lang::<pallas::Scalar, Coproc<pallas::Scalar>>::new();
let lang_rc = Arc::new(lang_pallas.clone());

// use cached public params
let instance = Instance::new(
reduction_count,
prove_params.reduction_count,
lang_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_params::<_, _, MultiFrame<'_, _, _>>(&instance).unwrap();

// Track the number of `Lurk frames / sec`
let rc = reduction_count as u64;
let rc = prove_params.reduction_count as u64;
c.throughput(criterion::Throughput::Elements(
rc * u64::div_ceil((11 + 16 * fib_n) as u64, rc),
rc * u64::div_ceil((11 + 16 * prove_params.fib_n) as u64, rc),
));

c.bench_with_input(
BenchmarkId::new(
prove_params.name(),
format!("num-{}/{sha}-{date}", prove_params.fib_n),
),
BenchmarkId::new(prove_params.name(), prove_params.params()),
&prove_params,
|b, prove_params| {
let store = Store::default();
Expand Down Expand Up @@ -125,30 +154,6 @@ fn fibo_prove<M: measurement::Measurement>(
);
}

fn rc_env() -> anyhow::Result<Vec<usize>> {
std::env::var("LURK_RC")
.map_err(|e| anyhow!("Reduction count env var isn't set: {e}"))
.and_then(|rc| {
let vec: anyhow::Result<Vec<usize>> = rc
.split(',')
.map(|rc| {
rc.parse::<usize>()
.map_err(|e| anyhow!("Failed to parse RC: {e}"))
})
.collect();
vec
})
}

fn noise_threshold_env() -> anyhow::Result<f64> {
std::env::var("LURK_BENCH_NOISE_THRESHOLD")
.map_err(|e| anyhow!("Noise threshold env var isn't set: {e}"))
.and_then(|nt| {
nt.parse::<f64>()
.map_err(|e| anyhow!("Failed to parse noise threshold: {e}"))
})
}

fn fibonacci_prove(c: &mut Criterion) {
tracing_subscriber::fmt::init();
set_bench_config();
Expand Down
Loading