Skip to content

perf: DKG benchmarks implementations#2623

Open
SimonRastikian wants to merge 11 commits intomainfrom
simon/benchmarking-dkg
Open

perf: DKG benchmarks implementations#2623
SimonRastikian wants to merge 11 commits intomainfrom
simon/benchmarking-dkg

Conversation

@SimonRastikian
Copy link
Copy Markdown
Contributor

@SimonRastikian SimonRastikian commented Mar 26, 2026

Closes near/threshold-signatures#252
We decided not to implement Resharing and Refresh as they are conceptually exactly the same thing.
The results documentation will happen in another PR.
Issue opened #2624

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR adds benchmark implementations, which should use the test: prefix since benchmarks are performance tests.

Suggested title: test: add DKG benchmark implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

Code Review

Reviewed the DKG benchmark additions. This PR adds benchmark infrastructure for keygen across three ciphersuites (Secp256k1, Ed25519, BLS12-381) using the existing simulated protocol framework.

No critical issues found. The code follows existing benchmark patterns (mirrors the CKD bench structure), touches only benchmark/test code, and introduces no production changes.

Minor nit (non-blocking): missing newline at end of advanced_dkg.rs.

✅ Approved

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR adds benchmark implementations, so the type prefix should be test: instead of no prefix.

Suggested title: test: add DKG benchmark implementations

@SimonRastikian SimonRastikian changed the title DKG benchmarks implementations perf: DKG benchmarks implementations Mar 26, 2026
@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR adds benchmark implementations. The type prefix should be test: to indicate test/benchmark additions.

Suggested title: test: add DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR adds benchmark implementations and documentation, not performance improvements to the code itself. The type prefix should probably be test: or chore: instead of perf:.

Suggested title: test: add DKG benchmark implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR adds benchmark implementations and documentation, but doesn't change production code performance. The type prefix should probably be test: instead of perf:.
Suggested title: test: DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR implements benchmark infrastructure rather than improving performance of existing code. The type should probably be test: instead of perf:

Suggested title: test: DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR title type suggestion: This PR primarily adds benchmark implementations and documentation rather than improving the performance of the code itself. The type should probably be test: (for benchmark code) instead of perf:

Suggested title: test: Add DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 27, 2026

PR title type suggestion: This PR adds benchmark implementations, which is testing/measurement code rather than a performance improvement to the actual codebase. The type prefix should probably be test: instead of perf:.

Suggested title: test: DKG benchmarks implementations

netrome
netrome previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Collaborator

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Nice stuff!

@@ -0,0 +1,150 @@
#![allow(clippy::indexing_slicing)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sure, fine for benches

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this used though?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I couldn't find it, but the clippy has the last word

Comment on lines +24 to +31
fn threshold() -> ReconstructionLowerBound {
ReconstructionLowerBound::from(*MAX_MALICIOUS + 1)
}

fn participants_num() -> usize {
*MAX_MALICIOUS + 1
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hm I think it would be nice to make these lazy loaded constants like MAX_MALICIOUS. But not super important.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same here

);
criterion_main!(benches);

/****************************** Helpers ******************************/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not a fan of these comments. I find it nicer to create sub modules if there's a natural division of the code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will create a new issue for this. It's gonna make things simpler to review.

@claude
Copy link
Copy Markdown

claude bot commented Mar 27, 2026

PR title type suggestion: This PR adds benchmark implementations and testing infrastructure, not performance improvements to the source code itself. The type prefix should probably be test: instead of perf:

Suggested title: test: DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 27, 2026

PR title type suggestion: This PR adds benchmark implementations and test utilities, not performance optimizations. The type prefix should probably be test: instead of perf:.

Suggested title: test: add DKG benchmark implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 27, 2026

PR title type suggestion: This PR adds benchmark test implementations, so the type prefix should probably be test: instead of perf:.
Suggested title: test: add DKG benchmarks implementations

@claude
Copy link
Copy Markdown

claude bot commented Mar 27, 2026

PR title type suggestion: This PR adds benchmark implementations and documentation rather than performance improvements to the codebase itself. The type prefix should probably be test: instead of perf:.

Suggested title: test: implement DKG benchmarks

Copy link
Copy Markdown
Contributor

@gilcu3 gilcu3 left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -0,0 +1,150 @@
#![allow(clippy::indexing_slicing)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I couldn't find it, but the clippy has the last word

Comment on lines +35 to +56
fn bench_dkg_secp256k1(c: &mut Criterion) {
let num = participants_num();
let max_malicious = *MAX_MALICIOUS;
let mut sizes = Vec::with_capacity(*SAMPLE_SIZE);

let mut group = c.benchmark_group("dkg");
group.sample_size(*SAMPLE_SIZE);
group.bench_function(
format!("dkg_secp256k1_MAX_MALICIOUS_{max_malicious}_PARTICIPANTS_{num}"),
|b| {
b.iter_batched(
|| {
let preps = prepare_simulated_dkg::<Secp256K1Sha256>(threshold());
sizes.push(preps.simulator.get_view_size());
preps
},
|preps| run_simulated_protocol(preps.participant, preps.protocol, preps.simulator),
criterion::BatchSize::SmallInput,
);
},
);
analyze_received_sizes(&sizes, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: we could reuse code for all 3 implementations

pub app_pk: ckd::ElementG1,
}

/********************* DKG *********************/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: we can remove this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Benchmark and document the benchmark of DKG, Refresh, Reshare

3 participants