Skip to content

Commit

Permalink
perf(crypto): CRP-2039 extend IDKG complaint benchmarks with other modes
Browse files Browse the repository at this point in the history
  • Loading branch information
altkdf committed Jan 31, 2024
1 parent ea78ca8 commit d205e8f
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions rs/crypto/benches/idkg.rs
Expand Up @@ -58,30 +58,28 @@ fn crypto_idkg_benchmarks(criterion: &mut Criterion) {
bench_create_dealing(group, &test_case, mode, vault_type, rng);
bench_verify_dealing_private(group, &test_case, mode, vault_type, rng);
bench_load_transcript(group, &test_case, mode, vault_type, rng);
if test_case.num_of_nodes >= mode.min_subnet_size_for_complaint() {
bench_open_transcript(group, &test_case, mode, vault_type, rng);
bench_load_transcript_with_openings(group, &test_case, mode, vault_type, rng);
}
}

bench_retain_active_transcripts(group, &test_case, 1, vault_type, rng);

if test_case.num_of_nodes >= IDkgMode::Random.min_subnet_size_for_complaint() {
bench_open_transcript(group, &test_case, vault_type, rng);
bench_load_transcript_with_openings(group, &test_case, vault_type, rng);
}

// The following benchmarks are not affected by the choice of the
// vault, we benchmark them only once with the default vault type.
if vault_type == VaultType::default() {
for mode in IDkgMode::iter() {
bench_verify_dealing_public(group, &test_case, mode, vault_type, rng);
bench_create_transcript(group, &test_case, mode, vault_type, rng);
bench_verify_transcript(group, &test_case, mode, vault_type, rng);
if test_case.num_of_nodes >= mode.min_subnet_size_for_complaint() {
bench_verify_complaint(group, &test_case, mode, vault_type, rng);
bench_verify_opening(group, &test_case, mode, vault_type, rng);
}
}

bench_verify_initial_dealings(group, &test_case, vault_type, rng);

if test_case.num_of_nodes >= IDkgMode::Random.min_subnet_size_for_complaint() {
bench_verify_complaint(group, &test_case, vault_type, rng);
bench_verify_opening(group, &test_case, vault_type, rng);
}
}
}
}
Expand Down Expand Up @@ -378,13 +376,14 @@ fn bench_retain_active_transcripts<M: Measurement, R: RngCore + CryptoRng>(
fn bench_verify_complaint<M: Measurement, R: RngCore + CryptoRng>(
group: &mut BenchmarkGroup<'_, M>,
test_case: &TestCase,
mode: IDkgMode,
vault_type: VaultType,
rng: &mut R,
) {
let env = test_case.new_test_environment(vault_type, rng);
let context = IDkgModeTestContext::new_for_complaint(IDkgMode::Random, &env, rng);
let context = IDkgModeTestContext::new_for_complaint(mode, &env, rng);

group.bench_function("verify_complaint_random", |bench| {
group.bench_function(format!("verify_complaint_{mode}"), |bench| {
bench.iter_batched_ref(
|| context.setup_outputs_for_complaint(&env, test_case.alg, rng),
|complaint_context| {
Expand All @@ -406,13 +405,14 @@ fn bench_verify_complaint<M: Measurement, R: RngCore + CryptoRng>(
fn bench_open_transcript<M: Measurement, R: RngCore + CryptoRng>(
group: &mut BenchmarkGroup<'_, M>,
test_case: &TestCase,
mode: IDkgMode,
vault_type: VaultType,
rng: &mut R,
) {
let env = test_case.new_test_environment(vault_type, rng);
let context = IDkgModeTestContext::new_for_complaint(IDkgMode::Random, &env, rng);
let context = IDkgModeTestContext::new_for_complaint(mode, &env, rng);

group.bench_function("open_transcript_random", |bench| {
group.bench_function(format!("open_transcript_{mode}"), |bench| {
bench.iter_batched_ref(
|| {
let complaint_context =
Expand Down Expand Up @@ -445,13 +445,14 @@ fn bench_open_transcript<M: Measurement, R: RngCore + CryptoRng>(
fn bench_verify_opening<M: Measurement, R: RngCore + CryptoRng>(
group: &mut BenchmarkGroup<'_, M>,
test_case: &TestCase,
mode: IDkgMode,
vault_type: VaultType,
rng: &mut R,
) {
let env = test_case.new_test_environment(vault_type, rng);
let context = IDkgModeTestContext::new_for_complaint(IDkgMode::Random, &env, rng);
let context = IDkgModeTestContext::new_for_complaint(mode, &env, rng);

group.bench_function("verify_opening_random", |bench| {
group.bench_function(format!("verify_opening_{mode}"), |bench| {
bench.iter_batched_ref(
|| {
let complaint_context =
Expand Down Expand Up @@ -485,13 +486,14 @@ fn bench_verify_opening<M: Measurement, R: RngCore + CryptoRng>(
fn bench_load_transcript_with_openings<M: Measurement, R: RngCore + CryptoRng>(
group: &mut BenchmarkGroup<'_, M>,
test_case: &TestCase,
mode: IDkgMode,
vault_type: VaultType,
rng: &mut R,
) {
let env = test_case.new_test_environment(vault_type, rng);
let context = IDkgModeTestContext::new_for_complaint(IDkgMode::Random, &env, rng);
let context = IDkgModeTestContext::new_for_complaint(mode, &env, rng);

group.bench_function("load_transcript_with_openings_random", |bench| {
group.bench_function(format!("load_transcript_with_openings_{mode}"), |bench| {
bench.iter_batched_ref(
|| {
let complaint_context =
Expand Down

0 comments on commit d205e8f

Please sign in to comment.