Repository navigation
perf(txpool): keep popped transactions in the best transactions snapshot - #35
Closed
haardikk21 wants to merge 1 commit into
Closed
haardikk21 wants to merge 1 commit into
haardikk21 wants to merge 1 commit into
Conversation
Author
|
CI failures here are not from this diff and match #31 / the
|
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.
Stacked on #31; the diff is the last commit only.
Summary
BestTransactions::pop_bestremoved each yielded transaction fromall.allis animbl::OrdMapcloned from the pending pool, so its nodes are shared with the pool. The first write to a shared node copies that node, including a clone of everyPendingTransaction(and itsArc) in it. Transaction ids from different senders are spread over the whole map, so almost every pop copied a fresh leaf.Popped transactions now stay in
all. Apopped: FxHashSet<TransactionId>records them instead:pop_bestskips keys whose id is inpopped, then marks the id it yields.ancestorignores popped ids, so a live transaction whose ancestor was already yielded still becomes independent, as before.popped, so a replacement of an already yielded transaction is yielded again, as before.size_hintsubtractspopped.len().poppedonly holds ids inall, so the bound is exact, as before.Yield order and outcomes are unchanged. The new test
test_best_live_transactions_after_their_ancestor_or_original_was_poppedcovers both live-update cases. On the parent commit its yield assertions pass too; only its new check that popped transactions remain inallfails there.Benchmarks
benches/best_transactions.rs(added in #31), ABBA on a Linux devbox (AMD Ryzen AI MAX+ 395, 32 threads, Linux 7.2, rustc 1.96.0). Each arm was built once and the binaries ran in the order A, B, B, A, pinned to cores 4–15, with 2s warm-up and 5s measurement. A = #31 (e69a3ac09), B = this change. Times are means of the A runs and of the B runs, in µs.take_512, which matches how payload builders use the iterator (take a prefix, then drop it), saves about 30–40 ns per yielded transaction. A full drain eventually copies most of the shared map whichever way it is mutated, so it gains less.Pool writes while a snapshot is live (
add_128_with_live_snapshot) are unchanged.Validation
cargo test -p reth-transaction-pool --all-features: 280 unit, 15 integration and 3 doc tests pass.cargo clippy -p reth-transaction-pool --all-features --all-targets -- -D warningscargo +nightly fmt -p reth-transaction-pool -- --check