Use Vec
instead of BTreeMap
for lc_map
and lc_assignment_cache
#381
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.
Description
It seems that using
BTreeMap
to store linear combinations is pretty expensive, and to improve the efficiency of constraint synthesis, this PR instead uses plain vectors forlc_map
andlc_assignment_cache
.Below is some data sampled by running the augmented circuit for sha256 from the sonobe library, and this PR can reduce the
generate_constraints
time from about 90ms to about 40ms:Note that for
lc_assignment_cache
,HashMap
might be a better choice thanVec
, as it does not cache entries that are never read and thus requires less memory, but it may take more time. Let me know which one you prefer!Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer