mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 10:43:25 +00:00
perf: use IdentityMap
This commit is contained in:
Generated
+10
-3
@@ -744,7 +744,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1028,6 +1028,12 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "identity-hash"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfdd7caa900436d8f13b2346fe10257e0c05c1f1f9e351f4f5d57c03bd5f45da"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "1.1.0"
|
||||
@@ -1117,6 +1123,7 @@ dependencies = [
|
||||
"fastbloom",
|
||||
"getrandom 0.3.3",
|
||||
"hex-literal",
|
||||
"identity-hash",
|
||||
"lazy_static",
|
||||
"lru-slab",
|
||||
"qlog",
|
||||
@@ -1705,7 +1712,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2447,7 +2454,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.61.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -52,6 +52,7 @@ slab = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tinyvec = { workspace = true, features = ["alloc"] }
|
||||
tracing = { workspace = true }
|
||||
identity-hash = "0.1.0"
|
||||
|
||||
# Feature flags & dependencies for wasm
|
||||
# wasm-bindgen is assumed for a wasm*-*-unknown target
|
||||
|
||||
@@ -18,9 +18,17 @@ use crate::{
|
||||
use qlog::events::quic::MetricsUpdated;
|
||||
|
||||
/// Id representing different paths when using multipath extension
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)]
|
||||
pub struct PathId(pub(crate) u32);
|
||||
|
||||
impl std::hash::Hash for PathId {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
state.write_u32(self.0);
|
||||
}
|
||||
}
|
||||
|
||||
impl identity_hash::IdentityHashable for PathId {}
|
||||
|
||||
impl coding::Codec for PathId {
|
||||
fn decode<B: bytes::Buf>(r: &mut B) -> coding::Result<Self> {
|
||||
let v = VarInt::decode(r)?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rustc_hash::FxHashMap;
|
||||
use identity_hash::{IdentityHashable, IntMap};
|
||||
|
||||
use crate::Instant;
|
||||
|
||||
@@ -86,7 +86,7 @@ const STACK_TIMERS: usize = 4;
|
||||
#[derive(Debug, Clone)]
|
||||
struct SmallMap<K, V, const SIZE: usize> {
|
||||
stack: [Option<(K, V)>; SIZE],
|
||||
heap: Option<FxHashMap<K, V>>,
|
||||
heap: Option<IntMap<K, V>>,
|
||||
}
|
||||
|
||||
impl<K, V, const SIZE: usize> Default for SmallMap<K, V, SIZE> {
|
||||
@@ -100,7 +100,7 @@ impl<K, V, const SIZE: usize> Default for SmallMap<K, V, SIZE> {
|
||||
|
||||
impl<K, V, const SIZE: usize> SmallMap<K, V, SIZE>
|
||||
where
|
||||
K: std::cmp::Eq + std::hash::Hash,
|
||||
K: std::cmp::Eq + std::hash::Hash + IdentityHashable,
|
||||
{
|
||||
fn insert(&mut self, key: K, value: V) -> Option<V> {
|
||||
// check stack for space
|
||||
|
||||
Reference in New Issue
Block a user