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

chore: inner-product protocol cleanup #34

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

AaronFeickert
Copy link
Contributor

@AaronFeickert AaronFeickert commented Jun 19, 2023

The inner-product protocol implementation includes many unnecessary clones when computing per-round multiscalar multiplication evaluations. These are unnecessary, since the evaluation function can accept reference iterators. Further, some multiplicative scalar offsets were being computed twice.

This PR cleans up these parts of the protocol for memory and computational efficiency, The evaluations now use only references, eliminating the clones. It's also more clever about scalar offsets to reduce duplicated computations.

Closes #33.

@AaronFeickert AaronFeickert marked this pull request as ready for review June 19, 2023 19:09
Copy link
Contributor

@CjS77 CjS77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oddly, the benchmarks were not faster with this PR on my Macbook Pro (2018). Though it was difficult to replicate due the CPU throttling issues, it looks like the clones are very fast compared to other operations. Maybe the iters have some overhead vs a contiguous block of memory that a vec has 🤷

Nevertheless, I like this.. it's cleaner and must be more memory efficient

@CjS77 CjS77 merged commit 215bac6 into tari-project:main Jun 20, 2023
5 checks passed
@AaronFeickert
Copy link
Contributor Author

Yeah, I wondered about whether the use of iterators incurred any overhead, but didn't find anything definitive about this. The scalar computation duplication overhead should be small compared to group operations, and it seems reasonable that it could fall within the noise threshold of benchmarking.

@AaronFeickert AaronFeickert deleted the ipp-clones branch June 20, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up inner-product protocol memory use
3 participants