Skip to content

Commit 0b8b5ab

Browse files
committed
Slightly faster hash.
1 parent 34725e0 commit 0b8b5ab

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Cargo.lock

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

memapi/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2018"
1010
libc = "0.2"
1111
itertools = "0.8.2"
1212
lazy_static = "1.4.0"
13+
rustc-hash = "1.0.1"
1314

1415
[dependencies.inferno]
1516
version = "0.9.4"

memapi/src/memorytracking.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use inferno::flamegraph;
22
use itertools::Itertools;
33
use libc;
4+
use rustc_hash;
45
use std::cell::RefCell;
56
use std::collections;
67
use std::sync::Mutex;
@@ -43,17 +44,17 @@ struct Allocation {
4344
}
4445

4546
struct AllocationTracker {
46-
current_allocations: collections::HashMap<usize, Allocation>,
47-
peak_allocations: collections::HashMap<usize, Allocation>,
47+
current_allocations: rustc_hash::FxHashMap<usize, Allocation>,
48+
peak_allocations: rustc_hash::FxHashMap<usize, Allocation>,
4849
current_allocated_bytes: usize,
4950
peak_allocated_bytes: usize,
5051
}
5152

5253
impl AllocationTracker {
5354
fn new() -> AllocationTracker {
5455
AllocationTracker {
55-
current_allocations: collections::HashMap::default(),
56-
peak_allocations: collections::HashMap::default(),
56+
current_allocations: rustc_hash::FxHashMap::default(),
57+
peak_allocations: rustc_hash::FxHashMap::default(),
5758
current_allocated_bytes: 0,
5859
peak_allocated_bytes: 0,
5960
}

0 commit comments

Comments
 (0)