Skip to content
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

Performance: use fewer operations in generate sum loop #71

Merged
merged 3 commits into from
Apr 19, 2023

Conversation

JayWhite2357
Copy link
Contributor

@JayWhite2357 JayWhite2357 commented Apr 18, 2023

Description

The following line is doing a lot of redundant compute for different iterations of t.

product *= table[b << 1] * (F::one() - t_as_field)
                            + table[(b << 1) + 1] * t_as_field;

In fact, the two * on the rhs can be removed entirely. This PR instead replaces table[b << 1] * (F::one() - t_as_field) + table[(b << 1) + 1] * t_as_field with an arithmetic sequence with first term table[b << 1] and second term table[(b << 1) + 1].

This improves performance by a decent amount. For instance:

Prove/GKR/15            time:   [75.101 ms 78.168 ms 81.418 ms]                         
                        change: [-48.075% -44.927% -41.822%] (p = 0.00 < 0.05)
                        Performance has improved.

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.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests - This is simply a rewrite of a loop, no functionality has changed.
  • Updated relevant documentation in the code - Nothing to update
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@JayWhite2357 JayWhite2357 changed the title Fewer operations Performance: use fewer operations in generate sum loop Apr 18, 2023
@JayWhite2357 JayWhite2357 marked this pull request as ready for review April 18, 2023 19:52
@Pratyush
Copy link
Member

Thanks for the PR!

@Pratyush Pratyush merged commit 6b88896 into arkworks-rs:master Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants