Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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#533I 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