Allocate less memory when validating new mempool transactions #12838
Labels
C-enhancement
New feature or request
M-prevent-stale
Prevents old inactive issues/PRs from being closed due to inactivity
S-needs-triage
This issue needs to be labelled
Describe the feature
Not sure how accurate bytehound is but it reports that validating new mempool transactions allocates (and deallocates) ~100 GB of RAM for ~10M transactions in ~10 minutes (~15k new transactions per second).
This matches
samply
's complaint in #12629 about copying the 32-byte tx-cost being a big overhead in the same code path.This issue traces the whole transaction validation process and removes unneeded allocations. For instance, one of the earliest checks,
ensure_max_init_code_size
, copies the 21-byteTxKind
(kind()
) to check if the new transaction is a Create one.reth/crates/transaction-pool/src/traits.rs
Lines 1067 to 1071 in 02824da
This check alone would allocate 200MB to validate 10M transactions. Intuitively, this should be a single reference byte check of the
&TxKind
enum.More to come 🙏.
Additional context
No response
The text was updated successfully, but these errors were encountered: