Skip to content

perf: Remove anyhow from P2P code#6244

Merged
eichhorl merged 4 commits into
masterfrom
eichhorl/remove-anyhow
Aug 12, 2025
Merged

perf: Remove anyhow from P2P code#6244
eichhorl merged 4 commits into
masterfrom
eichhorl/remove-anyhow

Conversation

@eichhorl

@eichhorl eichhorl commented Aug 12, 2025

Copy link
Copy Markdown
Contributor

anyhow captures a backtrace whenever an error is created. This can be quite expensive and has lead to a performance regression after updating the libunwind version in #4848.

The P2P code does not make use of this backtrace anywhere.

Therefore, this PR removes anyhow from all P2P crates, and replaces it with a custom opaque error type, that doesn't capture backtraces.

See also this issue: dtolnay/anyhow#346

@eichhorl eichhorl changed the title fix: Remove anyhow from P2P code perf: Remove anyhow from P2P code Aug 12, 2025
@github-actions github-actions Bot added fix perf and removed fix labels Aug 12, 2025
@eichhorl eichhorl marked this pull request as ready for review August 12, 2025 15:03
@eichhorl eichhorl requested a review from a team as a code owner August 12, 2025 15:03
Comment thread rs/p2p/quic_transport/src/lib.rs
Comment thread rs/p2p/quic_transport/src/lib.rs
@kpop-dfinity

Copy link
Copy Markdown
Contributor

anyhow captures a backtrace whenever an error is created. This can be quite expensive and lead to a performance regression after updating the libunwind version in #4848.

Does it make a noticeable difference in our performance tests?

@eichhorl

Copy link
Copy Markdown
Contributor Author

anyhow captures a backtrace whenever an error is created. This can be quite expensive and lead to a performance regression after updating the libunwind version in #4848.

Does it make a noticeable difference in our performance tests?

I only tried the tecdsa_performance_test, but there I observed an increase of signatures per second from ~1.77/s to ~1.97/s, and an increase in finalization rate from ~1/s to ~2/s.

@kpop-dfinity

Copy link
Copy Markdown
Contributor

anyhow captures a backtrace whenever an error is created. This can be quite expensive and lead to a performance regression after updating the libunwind version in #4848.

Does it make a noticeable difference in our performance tests?

I only tried the tecdsa_performance_test, but there I observed an increase of signatures per second from ~1.77/s to ~1.97/s, and an increase in finalization rate from ~1/s to ~2/s.

wow

@kpop-dfinity kpop-dfinity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice catch!

@eichhorl eichhorl added this pull request to the merge queue Aug 12, 2025
Merged via the queue into master with commit 8a9e163 Aug 12, 2025
28 checks passed
@eichhorl eichhorl deleted the eichhorl/remove-anyhow branch August 12, 2025 19:11
kpop-dfinity pushed a commit that referenced this pull request Aug 13, 2025
`anyhow` captures a backtrace whenever an error is created. This can be
quite expensive and has lead to a performance regression after updating
the `libunwind` version in #4848.

The P2P code does not make use of this backtrace anywhere.

Therefore, this PR removes `anyhow` from all P2P crates, and replaces it
with a custom opaque error type, that doesn't capture backtraces.

See also this issue: dtolnay/anyhow#346

---------

Co-authored-by: IDX GitHub Automation <infra+github-automation@dfinity.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants