Skip to content

feat: optimise for pederson hash#7

Open
hellojason3 wants to merge 1 commit intofeat/merge-compile-too-long-into-mainfrom
feat/optimise-memory-for-pederson-hash
Open

feat: optimise for pederson hash#7
hellojason3 wants to merge 1 commit intofeat/merge-compile-too-long-into-mainfrom
feat/optimise-memory-for-pederson-hash

Conversation

@hellojason3
Copy link
Copy Markdown
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
Copy Markdown
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