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

Fix poseidon hash bottleneck in Mina submodule #1378

Merged
merged 6 commits into from
Jan 24, 2024

Conversation

MartinMinkov
Copy link
Contributor

@MartinMinkov MartinMinkov commented Jan 19, 2024

mina: MinaProtocol/mina#14921
bindings: o1-labs/o1js-bindings#237

Summary

When performing a Poseidon hash, the Rust code responsible for performing the update has a bottleneck, primarily due to re-computing its internal parameters every time the function is invoked, as seen in the figure below.
image
It can be seen that mina_poseidon::pasta::fp_kimchi::params takes nearly 50ms, where the total running time of the hash stack trace is 53ms. By using the static version of the params function, we only generate the params once and then reload them every time it's used.

The results of the change can be seen in the figure below.
image
The profile shows that the params have not been generated this time, making the total running time 4ms.
This means we have a 13x speedup on Poseidon hashing 🎉

@MartinMinkov MartinMinkov force-pushed the perf/poseidon-hash-bottleneck branch from ea96734 to bb29f33 Compare January 19, 2024 00:12
@MartinMinkov MartinMinkov marked this pull request as ready for review January 19, 2024 00:35
@MartinMinkov MartinMinkov linked an issue Jan 19, 2024 that may be closed by this pull request
Copy link

@emberian emberian left a comment

Choose a reason for hiding this comment

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

wow!

Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

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

Amazing!

Copy link
Member

@Trivo25 Trivo25 left a comment

Choose a reason for hiding this comment

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

This improvement is worthy of a changelog entry imo!

@MartinMinkov MartinMinkov force-pushed the perf/poseidon-hash-bottleneck branch from 282138b to 88998ce Compare January 24, 2024 18:48
@MartinMinkov MartinMinkov merged commit fdbfc36 into main Jan 24, 2024
13 checks passed
@MartinMinkov MartinMinkov deleted the perf/poseidon-hash-bottleneck branch January 24, 2024 20:10
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.

Remove Poseidon bottleneck
4 participants