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

@ -15,6 +15,7 @@ path = "lib.rs"
base = { workspace = true }
base64 = { workspace = true }
chrono = { workspace = true }
rustc-hash = { workspace = true }
crossbeam-channel = { workspace = true }
devtools_traits = { workspace = true }
embedder_traits = { workspace = true }

View file

@ -2,15 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::collections::HashMap;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use rustc_hash::FxHashMap;
#[derive(Debug, Default)]
pub(crate) struct IdMap {
pub(crate) browser_ids: HashMap<WebViewId, u32>,
pub(crate) browsing_context_ids: HashMap<BrowsingContextId, u32>,
pub(crate) outer_window_ids: HashMap<PipelineId, u32>,
pub(crate) browser_ids: FxHashMap<WebViewId, u32>,
pub(crate) browsing_context_ids: FxHashMap<BrowsingContextId, u32>,
pub(crate) outer_window_ids: FxHashMap<PipelineId, u32>,
}
impl IdMap {

View file

@ -30,6 +30,7 @@ use embedder_traits::{AllowOrDeny, EmbedderMsg, EmbedderProxy};
use ipc_channel::ipc::IpcSender;
use log::{trace, warn};
use resource::{ResourceArrayType, ResourceAvailable};
use rustc_hash::FxHashMap;
use serde::Serialize;
use servo_rand::RngCore;
@ -116,12 +117,12 @@ pub(crate) struct StreamId(u32);
struct DevtoolsInstance {
actors: Arc<Mutex<ActorRegistry>>,
id_map: Arc<Mutex<IdMap>>,
browsing_contexts: HashMap<BrowsingContextId, String>,
browsing_contexts: FxHashMap<BrowsingContextId, String>,
receiver: Receiver<DevtoolsControlMsg>,
pipelines: HashMap<PipelineId, BrowsingContextId>,
actor_workers: HashMap<WorkerId, String>,
pipelines: FxHashMap<PipelineId, BrowsingContextId>,
actor_workers: FxHashMap<WorkerId, String>,
actor_requests: HashMap<String, String>,
connections: HashMap<StreamId, TcpStream>,
connections: FxHashMap<StreamId, TcpStream>,
next_resource_id: u64,
}
@ -179,12 +180,12 @@ impl DevtoolsInstance {
let instance = Self {
actors,
id_map: Arc::new(Mutex::new(IdMap::default())),
browsing_contexts: HashMap::new(),
pipelines: HashMap::new(),
browsing_contexts: FxHashMap::default(),
pipelines: FxHashMap::default(),
receiver,
actor_requests: HashMap::new(),
actor_workers: HashMap::new(),
connections: HashMap::new(),
actor_workers: FxHashMap::default(),
connections: FxHashMap::default(),
next_resource_id: 1,
};