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

feat: optimise for pederson hash #7

Open
wants to merge 1 commit into
base: feat/merge-compile-too-long-into-main
Choose a base branch
from

Conversation

hellojason3
Copy link
Collaborator

Problem

During testing, we observed that the line let digest = self.public_input.get_hash(); consumes approximately 60GB of memory and takes around 160 seconds to run. This performance needs optimization.

Work Done

Analysis showed that most of the time is spent in the function gen_element_steps_var, which takes about 150 seconds. We optimized it by:

1.	Using global variables to replace constants, avoiding redundant calculations.
2.	Improving bitwise operation efficiency.

Result

The optimization was successful, reducing memory usage from 60GB to 3GB and execution time from 160 seconds to 27 seconds.

#[allow(clippy::needless_range_loop)]
for i in 0..256 {
let suffix = x.rsh(i);
//let suffix = x.rsh(i);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is where a lot of memory and time are consumed, so I changed the way to perform bit operations.

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.

1 participant