chore: replace fnv with fxhashmap (#7927)

This commit is contained in:
Matthias Seitz
2024-04-27 17:10:26 +02:00
committed by GitHub
parent 2deb259ead
commit 2b6921b161
7 changed files with 11 additions and 10 deletions

2
Cargo.lock generated
View File

@ -7826,7 +7826,6 @@ dependencies = [
"auto_impl",
"bitflags 2.5.0",
"criterion",
"fnv",
"futures-util",
"itertools 0.12.1",
"metrics",
@ -7844,6 +7843,7 @@ dependencies = [
"reth-tasks",
"reth-tracing",
"revm",
"rustc-hash",
"schnellru",
"serde",
"serde_json",

View File

@ -321,6 +321,7 @@ serde_with = "3.3.0"
humantime = "2.1"
humantime-serde = "1.1"
rand = "0.8.5"
rustc-hash = "1.1.0"
schnellru = "0.2"
strum = "0.26"
rayon = "1.7"

View File

@ -37,7 +37,7 @@ tempfile = { workspace = true, optional = true }
derive_more.workspace = true
eyre.workspace = true
paste.workspace = true
rustc-hash = "1.1.0"
rustc-hash.workspace = true
# arbitrary utils
arbitrary = { workspace = true, features = ["derive"], optional = true }

View File

@ -36,9 +36,9 @@ metrics.workspace = true
aquamarine.workspace = true
thiserror.workspace = true
tracing.workspace = true
rustc-hash.workspace = true
schnellru.workspace = true
serde = { workspace = true, features = ["derive", "rc"], optional = true }
fnv = "1.0.7"
bitflags.workspace = true
auto_impl.workspace = true
smallvec.workspace = true

View File

@ -1,5 +1,5 @@
use fnv::FnvHashMap;
use reth_primitives::Address;
use rustc_hash::FxHashMap;
use std::collections::HashMap;
/// An internal mapping of addresses.
@ -13,7 +13,7 @@ pub(crate) struct SenderIdentifiers {
/// Assigned `SenderId` for an `Address`.
address_to_id: HashMap<Address, SenderId>,
/// Reverse mapping of `SenderId` to `Address`.
sender_to_address: FnvHashMap<SenderId, Address>,
sender_to_address: FxHashMap<SenderId, Address>,
}
impl SenderIdentifiers {

View File

@ -3,7 +3,7 @@ use crate::{
pool::size::SizeTracker,
PoolTransaction, SubPoolLimit, ValidPoolTransaction, TXPOOL_MAX_ACCOUNT_SLOTS_PER_SENDER,
};
use fnv::FnvHashMap;
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use std::{
cmp::Ordering,
@ -40,7 +40,7 @@ pub struct ParkedPool<T: ParkedOrd> {
last_sender_submission: BTreeSet<SubmissionSenderId>,
/// Keeps track of the number of transactions in the pool by the sender and the last submission
/// id.
sender_transaction_count: FnvHashMap<SenderId, SenderTransactionCount>,
sender_transaction_count: FxHashMap<SenderId, SenderTransactionCount>,
/// Keeps track of the size of this pool.
///
/// See also [`PoolTransaction::size`].

View File

@ -18,7 +18,6 @@ use crate::{
PoolConfig, PoolResult, PoolTransaction, PriceBumpConfig, TransactionOrdering,
ValidPoolTransaction, U256,
};
use fnv::FnvHashMap;
use itertools::Itertools;
use reth_primitives::{
constants::{
@ -26,6 +25,7 @@ use reth_primitives::{
},
Address, TxHash, B256,
};
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use std::{
cmp::Ordering,
@ -44,7 +44,7 @@ use tracing::trace;
/// include_mmd!("docs/mermaid/txpool.mmd")
pub struct TxPool<T: TransactionOrdering> {
/// Contains the currently known information about the senders.
sender_info: FnvHashMap<SenderId, SenderInfo>,
sender_info: FxHashMap<SenderId, SenderInfo>,
/// pending subpool
///
/// Holds transactions that are ready to be executed on the current state.
@ -903,7 +903,7 @@ pub(crate) struct AllTransactions<T: PoolTransaction> {
/// _All_ transaction in the pool sorted by their sender and nonce pair.
txs: BTreeMap<TransactionId, PoolInternalTransaction<T>>,
/// Tracks the number of transactions by sender that are currently in the pool.
tx_counter: FnvHashMap<SenderId, usize>,
tx_counter: FxHashMap<SenderId, usize>,
/// The current block number the pool keeps track of.
last_seen_block_number: u64,
/// The current block hash the pool keeps track of.