Removed FnvHash and transformed the rest to FxHashmap (#39233)

This should be the final PR for the Hash Function series that is
trivial.

Of note: I decided to transform `HashMapTracedValues<Atom,..>` to use
FxBuildHasher. This is likely not going to improve performance as Atom's
already have a unique u32 that is used as the Hash but it safes a few
bytes for the RandomState that is normally in the HashMap.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Hash function changes should not change functionality, we
slightly decrease the size and unit tests still work.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-09-10 15:34:54 +02:00 committed by GitHub
parent 726b456120
commit 84465e7768
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 211 additions and 202 deletions

View file

@ -22,6 +22,7 @@ crossbeam-channel = { workspace = true }
data-url = { workspace = true }
embedder_traits = { workspace = true }
headers = { workspace = true }
rustc-hash = { workspace = true }
http = { workspace = true }
hyper-util = { workspace = true }
hyper_serde = { workspace = true }

View file

@ -4,7 +4,6 @@
#![deny(unsafe_code)]
use std::collections::HashMap;
use std::fmt::Display;
use std::sync::{LazyLock, OnceLock};
use std::thread::{self, JoinHandle};
@ -26,6 +25,7 @@ use malloc_size_of::malloc_size_of_is_0;
use malloc_size_of_derive::MallocSizeOf;
use mime::Mime;
use request::RequestId;
use rustc_hash::FxHashMap;
use rustls_pki_types::CertificateDer;
use serde::{Deserialize, Serialize};
use servo_rand::RngCore;
@ -604,7 +604,7 @@ pub type BoxedFetchCallback = Box<dyn FnMut(FetchResponseMsg) + Send + 'static>;
struct FetchThread {
/// A list of active fetches. A fetch is no longer active once the
/// [`FetchResponseMsg::ProcessResponseEOF`] is received.
active_fetches: HashMap<RequestId, BoxedFetchCallback>,
active_fetches: FxHashMap<RequestId, BoxedFetchCallback>,
/// A crossbeam receiver attached to the router proxy which converts incoming fetch
/// updates from IPC messages to crossbeam messages as well as another sender which
/// handles requests from clients wanting to do fetches.
@ -631,7 +631,7 @@ impl FetchThread {
.name("FetchThread".to_owned())
.spawn(move || {
let mut fetch_thread = FetchThread {
active_fetches: HashMap::new(),
active_fetches: FxHashMap::default(),
receiver,
to_fetch_sender,
};