Skip to content

Commit a9633d1

Browse files
authored
Merge pull request #509 from mstange/push-xwuwnyzzrmoy
cargo update + various improvements
2 parents e4f5d67 + 51c5cfd commit a9633d1

File tree

20 files changed

+266
-255
lines changed

20 files changed

+266
-255
lines changed

Cargo.lock

Lines changed: 154 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etw-reader/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ categories = ["os::windows-apis"]
1414
bitflags = "2.8"
1515
num-traits = "0.2"
1616
num-derive = "0.4"
17-
once_cell = "1.8.0"
18-
fxhash = "0.2.1"
17+
rustc-hash = "2"
1918
memoffset = "0.9"
2019

2120
[dependencies.windows]

etw-reader/src/etw_types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::ops::Deref;
22
use std::rc::Rc;
3+
use std::cell::OnceCell;
34

4-
use once_cell::unsync::OnceCell;
5+
use rustc_hash::FxHashMap;
56
use windows::core::{GUID, PCWSTR};
67
use windows::Win32::System::Diagnostics::Etw::{self, PropertyStruct};
78

@@ -198,7 +199,7 @@ impl TraceEventInfoRaw {
198199
{
199200
let is_bitmap =
200201
map_info.Flag == super::Etw::EVENTMAP_INFO_FLAG_MANIFEST_BITMAP;
201-
let mut map = super::FastHashMap::default();
202+
let mut map = FxHashMap::default();
202203
assert!(
203204
map_info.Anonymous.MapEntryValueType
204205
== super::Etw::EVENTMAP_ENTRY_VALUETYPE_ULONG

etw-reader/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use fxhash::FxHasher;
21
use memoffset::offset_of;
32
pub use windows::core::GUID;
43
use windows::core::{h, HSTRING, PWSTR};
@@ -13,8 +12,6 @@ use windows::Win32::System::Diagnostics::Etw::{
1312
};
1413

1514
use std::borrow::Cow;
16-
use std::collections::HashMap;
17-
use std::hash::BuildHasherDefault;
1815
use std::mem;
1916
use std::path::Path;
2017

@@ -44,7 +41,6 @@ use tdh_types::{PrimitiveDesc, PropertyDesc, TdhInType};
4441
use tdh_types::{Property, TdhOutType};
4542
use traits::EncodeUtf16;
4643

47-
pub type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
4844
#[repr(C)]
4945
#[derive(Clone)]
5046
pub struct EventTraceLogfile(Etw::EVENT_TRACE_LOGFILEW);

etw-reader/src/property.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
//!
33
//! The `property` module expose the basic structures that represent the Properties an Event contains
44
//! based on it's Schema. This Properties can then be used to parse accordingly their values.
5+
6+
use rustc_hash::FxHashMap;
7+
58
use super::schema::Schema;
69
use super::tdh_types::Property;
7-
use super::FastHashMap;
810

911
/// Event Property information
1012
#[derive(Clone, Debug)]
@@ -28,14 +30,14 @@ impl<'a> PropertyInfo<'a> {
2830

2931
pub(crate) struct PropertyIter {
3032
properties: Vec<Property>,
31-
pub(crate) name_to_indx: FastHashMap<String, usize>,
33+
pub(crate) name_to_indx: FxHashMap<String, usize>,
3234
}
3335

3436
impl PropertyIter {
3537
pub fn new(schema: &Schema) -> Self {
3638
let prop_count = schema.event_schema.property_count();
3739
let mut properties = Vec::new();
38-
let mut name_to_indx = FastHashMap::default();
40+
let mut name_to_indx = FxHashMap::default();
3941
for i in 0..prop_count {
4042
let prop = schema.event_schema.property(i);
4143
name_to_indx.insert(prop.name.clone(), i as usize);

etw-reader/src/schema.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
//! This module contains the means needed to locate and interact with the Schema of an ETW event
44
use std::collections::hash_map::Entry;
55
use std::rc::Rc;
6+
use std::cell::OnceCell;
67

7-
use once_cell::unsync::OnceCell;
88
use windows::core::GUID;
99
use windows::Win32::System::Diagnostics::Etw::{self, EVENT_HEADER_FLAG_64_BIT_HEADER};
10+
use rustc_hash::FxHashMap;
1011

1112
use super::etw_types::{DecodingSource, EventRecord, TraceEventInfoRaw};
1213
use super::property::PropertyIter;
14+
use super::tdh;
1315
use super::tdh_types::Property;
14-
use super::{tdh, FastHashMap};
1516

1617
/// Schema module errors
1718
#[derive(Debug)]
@@ -46,15 +47,15 @@ struct SchemaKey {
4647

4748
// A map from tracelogging schema metdata to ids
4849
struct TraceLoggingProviderIds {
49-
ids: FastHashMap<Vec<u8>, u16>,
50+
ids: FxHashMap<Vec<u8>, u16>,
5051
next_id: u16,
5152
}
5253

5354
impl TraceLoggingProviderIds {
5455
fn new() -> Self {
5556
// start the ids at 1 because of 0 is typically the value stored
5657
TraceLoggingProviderIds {
57-
ids: FastHashMap::default(),
58+
ids: FxHashMap::default(),
5859
next_id: 1,
5960
}
6061
}
@@ -114,8 +115,8 @@ impl SchemaKey {
114115
/// Credits: [KrabsETW::schema_locator](https://github.com/microsoft/krabsetw/blob/master/krabs/krabs/schema_locator.hpp)
115116
#[derive(Default)]
116117
pub struct SchemaLocator {
117-
schemas: FastHashMap<SchemaKey, Rc<Schema>>,
118-
tracelogging_providers: FastHashMap<GUID, TraceLoggingProviderIds>,
118+
schemas: FxHashMap<SchemaKey, Rc<Schema>>,
119+
tracelogging_providers: FxHashMap<GUID, TraceLoggingProviderIds>,
119120
}
120121

121122
pub trait EventSchema {
@@ -150,8 +151,8 @@ impl std::fmt::Debug for SchemaLocator {
150151
impl SchemaLocator {
151152
pub fn new() -> Self {
152153
SchemaLocator {
153-
schemas: FastHashMap::default(),
154-
tracelogging_providers: FastHashMap::default(),
154+
schemas: FxHashMap::default(),
155+
tracelogging_providers: FxHashMap::default(),
155156
}
156157
}
157158

etw-reader/src/tdh_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ use std::rc::Rc;
1515
use bitflags::bitflags;
1616
use num_derive::{FromPrimitive, ToPrimitive};
1717
use num_traits::FromPrimitive;
18+
use rustc_hash::FxHashMap;
1819
use windows::Win32::System::Diagnostics::Etw;
1920

2021
use super::etw_types::EventPropertyInfo;
2122

2223
#[derive(Debug, Clone, Default)]
2324
pub struct PropertyMapInfo {
2425
pub is_bitmap: bool,
25-
pub map: super::FastHashMap<u32, String>,
26+
pub map: FxHashMap<u32, String>,
2627
}
2728
#[derive(Debug, Clone)]
2829
pub struct PrimitiveDesc {

fxprof-processed-profile/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ serde_json = "1.0"
1515
serde = "1.0.204"
1616
serde_derive = "1.0.188"
1717
debugid = "0.8.0"
18-
fxhash = "0.2.1"
18+
rustc-hash = "2"
1919

2020
[dev-dependencies]
2121
assert-json-diff = "2.0.1"
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::collections::HashMap;
2-
use std::hash::BuildHasherDefault;
1+
use rustc_hash::FxHashMap;
32

4-
use fxhash::FxHasher;
5-
6-
pub type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
3+
pub type FastHashMap<K, V> = FxHashMap<K, V>;

samply/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ serde_derive = "1.0.137"
4242
serde = "1.0.204"
4343
wholesym = { version = "0.8.0", path = "../wholesym", features = ["api"]}
4444
platform-dirs = "0.3"
45-
once_cell = "1.17"
46-
fxhash = "0.2.1"
45+
rustc-hash = "2"
4746
mio = { version = "1", features = ["os-ext", "os-poll"] }
4847
ctrlc = "3.4.4"
4948
log = "0.4.21"

samply/src/linux_shared/vdso.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use object::Object;
2-
use once_cell::sync::OnceCell;
2+
use std::sync::OnceLock;
33
use wholesym::{CodeId, ElfBuildId};
44

55
/// Returns the memory address range in this process where the VDSO is mapped.
@@ -36,7 +36,7 @@ pub struct VdsoObject {
3636

3737
impl VdsoObject {
3838
pub fn shared_instance_for_this_process() -> Option<&'static Self> {
39-
static INSTANCE: OnceCell<Option<VdsoObject>> = OnceCell::new();
39+
static INSTANCE: OnceLock<Option<VdsoObject>> = OnceLock::new();
4040
INSTANCE
4141
.get_or_init(|| {
4242
let data = get_vdso_data()?;

samply/src/mac/proc_maps.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::cmp::Ordering;
22
use std::collections::HashMap;
33
use std::mem::MaybeUninit;
44
use std::ops::{Deref, Range};
5+
#[cfg(target_arch = "aarch64")]
6+
use std::sync::OnceLock;
57
use std::{mem, ptr};
68

79
use dyld_bindings::{dyld_all_image_infos, dyld_image_info};
@@ -35,8 +37,6 @@ use object::macho::{
3537
};
3638
use object::read::macho::{MachHeader, Section, Segment};
3739
use object::LittleEndian;
38-
#[cfg(target_arch = "aarch64")]
39-
use once_cell::sync::Lazy;
4040
use uuid::Uuid;
4141
use wholesym::samply_symbols::object;
4242
use wholesym::CodeId;
@@ -477,11 +477,7 @@ fn get_virtual_address_size() -> Option<u32> {
477477
}
478478

479479
#[cfg(target_arch = "aarch64")]
480-
static PTR_AUTH_MASK: Lazy<PtrAuthMask> = Lazy::new(|| {
481-
let addr_bits = get_virtual_address_size().unwrap_or(47);
482-
let mask_bits = 64 - addr_bits;
483-
PtrAuthMask(u64::MAX >> mask_bits)
484-
});
480+
static PTR_AUTH_MASK: OnceLock<PtrAuthMask> = OnceLock::new();
485481

486482
#[cfg(target_arch = "aarch64")]
487483
fn get_unwinding_registers(
@@ -498,7 +494,11 @@ fn get_unwinding_registers(
498494
)
499495
}
500496
.into_result()?;
501-
let mask = *PTR_AUTH_MASK;
497+
let mask = *PTR_AUTH_MASK.get_or_init(|| {
498+
let addr_bits = get_virtual_address_size().unwrap_or(47);
499+
let mask_bits = 64 - addr_bits;
500+
PtrAuthMask(u64::MAX >> mask_bits)
501+
});
502502
Ok((
503503
mask.strip_ptr_auth(state.__pc),
504504
UnwindRegsAarch64::new_with_ptr_auth_mask(mask, state.__lr, state.__sp, state.__fp),

samply/src/mac/time.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use std::sync::OnceLock;
2+
13
use mach2::mach_time;
2-
use once_cell::sync::OnceCell;
34

4-
static NANOS_PER_TICK: OnceCell<mach_time::mach_timebase_info> = OnceCell::new();
5+
static NANOS_PER_TICK: OnceLock<mach_time::mach_timebase_info> = OnceLock::new();
56

67
pub fn get_monotonic_timestamp() -> u64 {
78
let nanos_per_tick = NANOS_PER_TICK.get_or_init(|| unsafe {

samply/src/shared/types.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
use std::collections::HashMap;
2-
use std::hash::BuildHasherDefault;
3-
4-
use fxhash::FxHasher;
51
use linux_perf_data::linux_perf_event_reader;
62
use linux_perf_event_reader::constants::{
73
PERF_CONTEXT_GUEST, PERF_CONTEXT_GUEST_KERNEL, PERF_CONTEXT_GUEST_USER, PERF_CONTEXT_KERNEL,
84
PERF_CONTEXT_USER,
95
};
106
use linux_perf_event_reader::CpuMode;
117

12-
pub type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
8+
pub type FastHashMap<K, V> = rustc_hash::FxHashMap<K, V>;
139

1410
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1511
pub enum StackMode {

samply/src/windows/etw_reader/etw_types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use std::cell::OnceCell;
12
use std::ops::Deref;
23
use std::rc::Rc;
34

4-
use once_cell::unsync::OnceCell;
5+
use rustc_hash::FxHashMap;
56
use windows::core::{GUID, PCWSTR};
67
use windows::Win32::System::Diagnostics::Etw::{self, PropertyStruct};
78

@@ -198,7 +199,7 @@ impl TraceEventInfoRaw {
198199
{
199200
let is_bitmap =
200201
map_info.Flag == super::Etw::EVENTMAP_INFO_FLAG_MANIFEST_BITMAP;
201-
let mut map = super::FastHashMap::default();
202+
let mut map = FxHashMap::default();
202203
assert!(
203204
map_info.Anonymous.MapEntryValueType
204205
== super::Etw::EVENTMAP_ENTRY_VALUETYPE_ULONG

samply/src/windows/etw_reader/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use fxhash::FxHasher;
21
use memoffset::offset_of;
32
pub use windows::core::GUID;
43
use windows::core::{h, HSTRING, PWSTR};
@@ -13,8 +12,6 @@ use windows::Win32::System::Diagnostics::Etw::{
1312
};
1413

1514
use std::borrow::Cow;
16-
use std::collections::HashMap;
17-
use std::hash::BuildHasherDefault;
1815
use std::mem;
1916
use std::path::Path;
2017

@@ -44,7 +41,6 @@ use tdh_types::{PrimitiveDesc, PropertyDesc, TdhInType};
4441
use tdh_types::{Property, TdhOutType};
4542
use traits::EncodeUtf16;
4643

47-
pub type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
4844
#[repr(C)]
4945
#[derive(Clone)]
5046
pub struct EventTraceLogfile(Etw::EVENT_TRACE_LOGFILEW);

samply/src/windows/etw_reader/property.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
//!
33
//! The `property` module expose the basic structures that represent the Properties an Event contains
44
//! based on it's Schema. This Properties can then be used to parse accordingly their values.
5+
6+
use rustc_hash::FxHashMap;
7+
58
use super::schema::Schema;
69
use super::tdh_types::Property;
7-
use super::FastHashMap;
810

911
/// Event Property information
1012
#[derive(Clone, Debug)]
@@ -28,14 +30,14 @@ impl<'a> PropertyInfo<'a> {
2830

2931
pub(crate) struct PropertyIter {
3032
properties: Vec<Property>,
31-
pub(crate) name_to_indx: FastHashMap<String, usize>,
33+
pub(crate) name_to_indx: FxHashMap<String, usize>,
3234
}
3335

3436
impl PropertyIter {
3537
pub fn new(schema: &Schema) -> Self {
3638
let prop_count = schema.event_schema.property_count();
3739
let mut properties = Vec::new();
38-
let mut name_to_indx = FastHashMap::default();
40+
let mut name_to_indx = FxHashMap::default();
3941
for i in 0..prop_count {
4042
let prop = schema.event_schema.property(i);
4143
name_to_indx.insert(prop.name.clone(), i as usize);

0 commit comments

Comments
 (0)