refactor: avoid creating intermediate vectors during commit #365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale for this change
This PR refactors the
commit
function in thehyperkzg
andpedersen
modules to improve space performance by eliminating the creation of intermediatescalars
andbases
vectors. Instead, it directly constructs the required slices for thevartime_multiscalar_mul
function call and adds the binding factor in a separate step, reducing memory allocations.Criterion benchmark results
Benchmarks were completed on an Azure VM:
Standard NC24ads A100 v4 (24 vcpus, AMD EPYC 7V13 (Milan) [x86-64], and 220 GiB memory)
The
compressed-snark
criterion benchmarks show that no change in performance was detected or, in one case, within the noise threshold. Gray relates to themain
branch, blue relates to the updates in this PR..CompressedSNARK-StepCircuitSize-0/Prove

CompressedSNARK-StepCircuitSize-6399/Prove

CompressedSNARK-StepCircuitSize-22783/Prove

CompressedSNARK-StepCircuitSize-55551/Prove

CompressedSNARK-StepCircuitSize-121087/Prove

CompressedSNARK-StepCircuitSize-252159/Prove

CompressedSNARK-StepCircuitSize-514303/Prove

CompressedSNARK-StepCircuitSize-1038591/Prove

CompressedSNARK-Commitments-StepCircuitSize-0/Prove

CompressedSNARK-Commitments-StepCircuitSize-6399/Prove

CompressedSNARK-Commitments-StepCircuitSize-22783/Prove

CompressedSNARK-Commitments-StepCircuitSize-55551/Prove

CompressedSNARK-Commitments-StepCircuitSize-121087/Prove

CompressedSNARK-Commitments-StepCircuitSize-252159/Prove
