-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize bind_least_significant_variable
#319
Optimize bind_least_significant_variable
#319
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
What would the take home message be from this optimization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Thank you!
Rust inserts bound checks on every slice indexing when it's not able to prove that the indexing will not be out of bounds. For example, this will not result in any bound checks being inserted for i in 0..v.len() {
v[i] = 3;
} since A good tool to figure that out is Bound checks are bad for 2 reasons:
In our case, both versions of the code vectorized the load of Note that since with Goldilocks we're playing with "big" |
Makes sense, thank you for the great explanation! |
This PR removes the slide bound checks in
MultiLinearPoly::bind_least_significant_variable
.In the serial case, we see a 7-9% improvement in the
bind-variable
benchmark, and sum-check performance improvement by 2.5-3.5%. Parallel performance doesn't change, presumably since the algorithm is bounded by the threading overhead rather than the time each threads spends looping over its chunk.The LogUp-GKR benchmark also didn't change, since
bind_least_significant_variable
was not a bottleneck. However I see this PR as a proof of concept, and will apply similar bound checks removal in any hot loop I find in a subsequent PR.Below are the serial bind-variable and sum-check benchmark results: