feat: remove generic parameter from the BigNum trait#44
Merged
TomAFrench merged 8 commits intomainfrom Nov 8, 2024
Merged
Conversation
iAmMichaelConnor
commented
Nov 5, 2024
TomAFrench
approved these changes
Nov 8, 2024
BigNum trait
Merged
TomAFrench
added a commit
that referenced
this pull request
Nov 8, 2024
* main: feat: remove generic parameter from the `BigNum` trait (#44) fix: fix broken tests in `runtime_bignum_test.nr` (#39) feat: remove a bunch of unnecessary bytecode from unconstrained ops (#50) fix: Fix barrett reduction bug (#51) feat: optimize brillig execution of `split_X_bits` functions (#47)
| evaluate_quadratic_expression::<_, MOD_BITS, _, _, _, _>( | ||
| params, | ||
| map(lhs_terms, |bns| map(bns, |bn| Self::get_limbs(bn))), | ||
| map( |
Collaborator
Author
There was a problem hiding this comment.
@TomAFrench I've honed in on this PR being the one that caused a regression in the constraint counts of BigNum. In particular, I was measuring the constraints of calls to this evaluate_quadratic_expression function.
Any thoughts on why the changes in this PR are increasing constraint counts? Is it simply that converting between slices and arrays is not free?
Collaborator
Author
There was a problem hiding this comment.
The extra ACIR opcodes (for a main function which calls this evaluate_quadratic_expression) function appear to be:
INIT (id: 0, len: 4)
EXPR [ (-1, _5) 0 ]
MEM (id: 0, read at: x5, value: x6)
EXPR [ (-1, _7) 1 ]
MEM (id: 0, read at: x7, value: x8)
EXPR [ (-1, _9) 2 ]
MEM (id: 0, read at: x9, value: x10)
EXPR [ (-1, _11) 3 ]
MEM (id: 0, read at: x11, value: x12)
INIT (id: 1, len: 4)
MEM (id: 1, read at: x5, value: x13)
MEM (id: 1, read at: x7, value: x14)
MEM (id: 1, read at: x9, value: x15)
MEM (id: 1, read at: x11, value: x16)
Member
There was a problem hiding this comment.
Yeah, this is bad actor codegen as we're just reading all the values out of the array to write into another one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Although not explained in the original code, there's a reason why arrays of size
Nare never passed to/from setters and getters ofBigNum; it's so that external libs can write use a genericBigNumwhere BigNum: BigNumTrait, without having to specify anN. Removal offrom_arrayandget_limbsresolves this.Also resolves a modulus_bits typo in one of the off-the-shelf params files.