perf(chain): refactor TxGraph.spends from BTreeMap to HashMap#2145
perf(chain): refactor TxGraph.spends from BTreeMap to HashMap#2145shubham-shinde-442 wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
|
Does the performance improvement justify the added complexity? |
|
I reviewed the implementation, and indeed the Furthermore, in terms of developer experience, I believe the performance improvement justifies the change made, as it keeps |
|
Thanks @lucasdbr05 for the review — a few pushbacks though. The O(log(n) + k) → O(k) improvement for Also worth noting: the reviewer's conclusion that "it keeps A few remaining concerns before this can move forward:
|
Resolves: #2026
Description
Refactors
TxGraph.spendsfield fromBTreeMaptoHashMapfor improvedperformance while maintaining all existing behavioral guarantees.
Problem:
The
spendsfield was aBTreeMap<OutPoint, HashSet<Txid>>, providing O(log n)lookups. For transaction graph traversal this is unnecessary overhead.
Solution:
HashMap<OutPoint, HashSet<Txid>>for O(1) average-case lookupsspend_vouts_by_txid: HashMap<Txid, BTreeSet<u32>>to:descendant walking)
Notes to the reviewers
Changelog notice
Checklists
All Submissions:
New Features:
Bugfixes: