perf(txpool): tombstone eviction-order removals in AA 2D pool#5598
Draft
mattsse wants to merge 1 commit into
Draft
perf(txpool): tombstone eviction-order removals in AA 2D pool#5598mattsse wants to merge 1 commit into
mattsse wants to merge 1 commit into
Conversation
Contributor
Author
|
derek bench |
Member
|
cc @mattsse ❌ Benchmark complete: Regression View job ❌ Bench Comparison: RegressionRefs: main vs mattsse/txpool-saturation-opt Configuration
Tempo Metrics
Builder
Builder details
Validator
Observability |
This was referenced Jun 10, 2026
cc48bb8 to
d9f4c37
Compare
At high TPS the txpool maintenance thread spends a large share of its time removing mined transactions from the eviction-order BTreeSets: every removal recomputed the transaction's priority (effective tip) and performed a keyed BTreeSet removal. Removals now only flip a liveness flag; tombstoned entries are skipped during eviction scans and compacted once more than half of a set is stale, making removal O(1) amortized. For regular 2D transactions the flag lives on the Arc-shared AA2dInternalTransaction, so tombstoning adds no allocation to the insertion path. Expiring nonce transactions carry an Arc'd flag shared between the pool entry and its eviction-order keys. As a side effect, best-transaction snapshots now skip expiring nonce transactions that were mined or evicted after the snapshot was taken. Benchmarked with the new aa_2d_pool benchmark against main (median of six interleaved runs, pool saturated at 10k transactions): - on_state_updates/expiring_mined: 3.23ms -> 2.59ms (-20%) - on_state_updates/2d_mined: 5.45ms -> 4.49ms (-18%) - add benches unchanged within noise
3aea50f to
5454528
Compare
Thegreatsura
pushed a commit
to Thegreatsura/tempo
that referenced
this pull request
Jun 11, 2026
…empoxyz#5602) Profiling a saturated AA 2D pool at 50k TPS showed the `txs_by_sender` lookups account for roughly a third of insertion time: every insert did a `get` for the per-sender limit check plus a separate `entry` to increment the count. These are now a single map operation. Two more lookups removed on the same path: the `by_hash` duplicate check is skipped for expiring nonce transactions since the expiring nonce hash entry already rejects duplicates, and the descendant promotion scan exits once it reaches an already-pending transaction. Measured with the benchmark from tempoxyz#5598 (10k transaction pool): filling the pool improves ~40% for both expiring and regular 2D nonce transactions, inserting into a 2D pool at capacity ~16%. Extracted from tempoxyz#5598.
Thegreatsura
pushed a commit
to Thegreatsura/tempo
that referenced
this pull request
Jun 11, 2026
…5603) Resolving the active hardfork walked the chain spec's fork schedule and cloned the chain spec `Arc` once per validated transaction in `validate_one` and once per inserted AA 2D transaction in `add_validated_transaction`. The validator now caches the active hardfork as an `AtomicU8` holding its `TempoHardfork::VARIANTS` index, updated in `on_new_head_block` where the EVM environment for the new tip is already constructed. The new `TempoHardfork::variant_index`/`from_variant_index` helpers handle the atomic round-trip. Extracted from tempoxyz#5598.
Contributor
Author
|
derek bench |
Member
|
cc @mattsse ⚪ Benchmark complete: No Difference View job ⚪ Bench Comparison: No DifferenceRefs: main vs mattsse/txpool-saturation-opt Configuration
Tempo Metrics
Builder
Builder details
Validator
Observability |
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.
At high TPS a large share of the txpool maintenance thread is spent in
AA2dPool::on_state_updatesremoving mined transactions from the eviction-order sets: every removal recomputed the transaction's priority (effective_tip_per_gas) and performed a keyedBTreeSetremoval. Removals now only flip a liveness flag. Tombstoned entries are skipped during eviction scans and pops, and each set is compacted once more than half of its entries are stale, making removal O(1) amortized.For regular 2D transactions the flag lives on the already Arc-shared
AA2dInternalTransaction, so tombstoning adds no allocation to the insertion path. Expiring nonce transactions carry anArc'd flag shared between the pool entry and its eviction-order keys. As a side effect,BestAA2dTransactionssnapshots now skip expiring nonce transactions that were mined or evicted after the snapshot was taken instead of yielding them.Includes a new criterion benchmark (
cargo bench -p tempo-transaction-pool --bench aa_2d_pool) covering insertion into a pool at capacity (every insert evicts) and state updates that mine many transactions at once, for both regular 2D and expiring nonce transactions.Re-measured after #5602 and #5603 landed, against current main (median of six interleaved runs, pool saturated at 10k transactions):
Trade-off: tombstoned entries keep their transaction Arcs alive until the next compaction, so the eviction-order sets can transiently hold up to twice as many entries as the pool.