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 optimizations #5

Merged
merged 2 commits into from
Nov 24, 2022
Merged

Performance optimizations #5

merged 2 commits into from
Nov 24, 2022

Conversation

cryptoquick
Copy link
Contributor

I benchmarked with cargo-flamegraph using flamegraph --bin rana (but don't let this run too long), and it's pretty clear the primary performance bottleneck is the secp256k1 library, which is not unexpected. ECs are somewhat computationally expensive. I attempted some performance optimizations on the crate itself, but that ran into some issues, so I opened an issue here: rust-bitcoin/rust-secp256k1#533

I also briefly experimented with using the k256 library, but it was dog slow. Not worth it at all.

Additionally, I added atomic operations for measuring iterations across the entire system, but this will have a certain performance impact, about as much as a CPU cache miss, so, could be significant, but without decent measurements, it's difficult to optimize performance. Maybe this can be stripped out using conditional compilation if sheer performance is desired, with no regard for performance stats.

I recommend compiling it with these commands for maximum performance:
RUSTFLAGS="-Ctarget-cpu=native" cargo build --release && cargo strip && target/release/rana

@grunch
Copy link
Owner

grunch commented Nov 24, 2022

LGTM!

Great research about performance, do you know how we can optionally use GPU instead of CPU?

@grunch grunch merged commit d79d516 into grunch:main Nov 24, 2022
@grunch
Copy link
Owner

grunch commented Nov 24, 2022

What would be cargo strip? is this an extension subcommand to cargo?

@ok300
Copy link
Contributor

ok300 commented Nov 24, 2022

Great research about performance, do you know how we can optionally use GPU instead of CPU?

Curious about that as well.

@ok300 ok300 mentioned this pull request Nov 24, 2022
@cryptoquick cryptoquick deleted the perf branch November 24, 2022 14:54
@cryptoquick
Copy link
Contributor Author

Oh, sorry, it's just this project, a helper for the strip command, which strips debug symbols from the binary. It looks like it's outdated now though, since it's now built into cargo. See:
https://github.com/guedou/cargo-strip

@cryptoquick
Copy link
Contributor Author

Great research about performance, do you know how we can optionally use GPU instead of CPU?

This I'm really not sure. Elliptic curves are a lot more complicated than hashing.

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.

None yet

3 participants