From 3ec065295e3c1cdef2e5a9f80e231fdf67cca898 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Fri, 30 Jan 2026 10:34:15 -0800 Subject: [PATCH] refactor(trie): replace SmallVec with Vec in sparse trie buffers (#21637) Co-authored-by: Amp Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> --- Cargo.lock | 1 - crates/trie/sparse-parallel/Cargo.toml | 2 +- crates/trie/sparse-parallel/src/trie.rs | 4 ++-- crates/trie/sparse/Cargo.toml | 2 -- crates/trie/sparse/src/trie.rs | 9 ++++----- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f4f3d8ad2..cd823c2f3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11255,7 +11255,6 @@ dependencies = [ "reth-trie", "reth-trie-common", "reth-trie-db", - "smallvec", "tracing", ] diff --git a/crates/trie/sparse-parallel/Cargo.toml b/crates/trie/sparse-parallel/Cargo.toml index 19893831aa..42e889ca0e 100644 --- a/crates/trie/sparse-parallel/Cargo.toml +++ b/crates/trie/sparse-parallel/Cargo.toml @@ -28,8 +28,8 @@ reth-metrics = { workspace = true, optional = true } metrics = { workspace = true, optional = true } # misc -smallvec.workspace = true rayon = { workspace = true, optional = true } +smallvec.workspace = true [dev-dependencies] # reth diff --git a/crates/trie/sparse-parallel/src/trie.rs b/crates/trie/sparse-parallel/src/trie.rs index 589cd81b1e..927916b24f 100644 --- a/crates/trie/sparse-parallel/src/trie.rs +++ b/crates/trie/sparse-parallel/src/trie.rs @@ -3248,9 +3248,9 @@ pub struct SparseSubtrieBuffers { /// Stack of RLP nodes rlp_node_stack: Vec, /// Reusable branch child path - branch_child_buf: SmallVec<[Nibbles; 16]>, + branch_child_buf: Vec, /// Reusable branch value stack - branch_value_stack_buf: SmallVec<[RlpNode; 16]>, + branch_value_stack_buf: Vec, /// Reusable RLP buffer rlp_buf: Vec, } diff --git a/crates/trie/sparse/Cargo.toml b/crates/trie/sparse/Cargo.toml index b2c7ee0f56..0955f204f9 100644 --- a/crates/trie/sparse/Cargo.toml +++ b/crates/trie/sparse/Cargo.toml @@ -26,7 +26,6 @@ alloy-rlp.workspace = true # misc auto_impl.workspace = true rayon = { workspace = true, optional = true } -smallvec = { workspace = true, features = ["const_new"] } # metrics reth-metrics = { workspace = true, optional = true } @@ -80,7 +79,6 @@ arbitrary = [ "alloy-trie/arbitrary", "reth-primitives-traits/arbitrary", "reth-trie-common/arbitrary", - "smallvec/arbitrary", ] [[bench]] diff --git a/crates/trie/sparse/src/trie.rs b/crates/trie/sparse/src/trie.rs index 77dd6218bd..c5889a5192 100644 --- a/crates/trie/sparse/src/trie.rs +++ b/crates/trie/sparse/src/trie.rs @@ -24,7 +24,6 @@ use reth_trie_common::{ LeafNodeRef, Nibbles, ProofTrieNode, RlpNode, TrieMask, TrieNode, CHILD_INDEX_RANGE, EMPTY_ROOT_HASH, }; -use smallvec::SmallVec; use tracing::{debug, instrument, trace}; /// The level below which the sparse trie hashes are calculated in @@ -2003,9 +2002,9 @@ pub struct RlpNodeBuffers { /// Stack of RLP nodes rlp_node_stack: Vec, /// Reusable branch child path - branch_child_buf: SmallVec<[Nibbles; 16]>, + branch_child_buf: Vec, /// Reusable branch value stack - branch_value_stack_buf: SmallVec<[RlpNode; 16]>, + branch_value_stack_buf: Vec, } impl RlpNodeBuffers { @@ -2018,8 +2017,8 @@ impl RlpNodeBuffers { is_in_prefix_set: None, }], rlp_node_stack: Vec::new(), - branch_child_buf: SmallVec::<[Nibbles; 16]>::new_const(), - branch_value_stack_buf: SmallVec::<[RlpNode; 16]>::new_const(), + branch_child_buf: Vec::new(), + branch_value_stack_buf: Vec::new(), } } }