Conversation
- Add an end-to-end performance test for get_raw_transaction against compute_txid Result performed against a size of 500 unconfirmed mempool txs indicate that compute_txid() validation introduces a negligible performance impact, consuming just 0.946% of the time required to get_raw_transaction.
- add criterion benchmarks for compute_txid and deserialize across three transaction sizes. The result indicate that both operations scale linearly with the size of the transaction, but are both fast even for a large transaction. The txid check costs a stable ~0.6-2.7 µs/tx (size-dependent; ~0.8 µs typical), reproducible across runs. It's roughly 2x a bare deserialize, but both are sub-µs — and it's <1% of the full get_raw_transaction fetch, which is dominated by the RPC round-trip.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR seeks to provide the performance metrics for adding
compute_txid()verification check for everyfetched mempool transaction to Emitter::mempool_at
in #2283.
Tests
crates/bitcoind_rpc/tests/perf_check.rs— an end-to-end test usingbdk_testenv(spins up a real regtest node), which broadcasts ~500 mempool txs and timesget_raw_transaction(the fetch already done per tx) against thecompute_txid()check.crates/bitcoind_rpc/benches/txid_check.rs— a criterion microbench isolating the CPU cost ofcompute_txid()vs a bare consensus-deserialize, across three transaction sizes. Provides the absolute cost.How to reproduce
cargo test --release -p bdk_bitcoind_rpc --test perf_check -- --nocapturefor end-to-end test modulecargo bench -p bdk_bitcoind_rpc --bench txid_checkfor criterion benchesResults
Machine: Macbook pro M1 (16GB RAM, macOS Tahoe v26.6.2, 10 Cores CPU).
End-to-end (500 mempool txs, localhost regtest):
get_raw_transaction(RPC round-trip + hex + deserialize — already paid)compute_txid()checkIsolated CPU cost (criterion,
time:estimates):compute_txid(the check)deserializeInterpretation
get_raw_transactionfetch, which is dominated by the RPC round-trip.Conclusion: the txid check has no meaningful impact on sync performance.
Checklists
All Submissions: