Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Reduce number of reallocations #6

Merged
merged 1 commit into from
Oct 10, 2023
Merged

Reduce number of reallocations #6

merged 1 commit into from
Oct 10, 2023

Conversation

Nashtare
Copy link
Member

@Nashtare Nashtare commented Oct 7, 2023

Description

Pre-allocate sufficient amounts when creating new vectors, most of the time relying on the compressed_size() method from the CanonicalSerialize trait.

Mostly useful for to_bytes methods. Some vector initializations are purposedly left untouched, either because they are within unit tests or because they deal with malicious participants which, we hope at least, wouldn't require more than 1 allocation in the worst case (i.e. at most 4 malicious participants at once).

PR Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added or updated tests that comprehensively prove my change is effective or that my feature works

@Nashtare Nashtare self-assigned this Oct 7, 2023
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (7553d9a) 82.68% compared to head (9a9bf1b) 82.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
- Coverage   82.68%   82.55%   -0.14%     
==========================================
  Files          13       13              
  Lines        1057     1026      -31     
==========================================
- Hits          874      847      -27     
+ Misses        183      179       -4     
Files Coverage Δ
src/dkg/complaint.rs 98.52% <100.00%> (ø)
src/dkg/key_generation.rs 91.22% <100.00%> (-0.19%) ⬇️
src/dkg/nizkpok.rs 97.22% <100.00%> (ø)
src/dkg/participant.rs 92.77% <100.00%> (-0.57%) ⬇️
src/parameters.rs 100.00% <100.00%> (ø)
src/sign/signature.rs 79.31% <100.00%> (+0.36%) ⬆️
src/sign/precomputation.rs 90.14% <66.66%> (-0.40%) ⬇️
src/dkg/secret_share.rs 79.04% <60.00%> (ø)
src/keys.rs 80.21% <71.42%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -521,7 +521,8 @@ pub struct DKGParticipantList<C: CipherSuite> {
impl<C: CipherSuite> DistributedKeyGeneration<RoundOne, C> {
Copy link
Member

Choose a reason for hiding this comment

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

Random question, but if the to_bytes function is identical for a DistributedKeyGeneration<RoundTwo, _>, can't you implement both at the same time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes to_bytes / from_bytes could be defined for an arbitrary DkgState, I didn't bother dealing with it because we may refactor this, following #8. But that's acknowledged, thanks for noticing 👍🏼

@Nashtare Nashtare merged commit c8285c5 into main Oct 10, 2023
9 checks passed
@Nashtare Nashtare deleted the allocation branch October 10, 2023 15:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants