@@ -35,8 +35,9 @@ pub const PROFILE_TYPES: [ProfileType; NUM_PROFILE_TYPES] = [
3535/// 1. Always enabled types.
3636/// 2. On by default types.
3737/// 3. Off by default types.
38+ ///
3839/// But this doesn't really matter anymore, because the number of sample types
39- /// has grown.
40+ /// has grown and the optimizations used don't work well anymore .
4041#[ derive( Default , Debug ) ]
4142#[ repr( C ) ]
4243pub struct SampleValues {
@@ -65,30 +66,30 @@ pub struct SampleValues {
6566 pub file_write_size_samples : i64 ,
6667}
6768
68- /// The sample values for a given profile type.
69- ///
70- /// The repr(u8) is valid even though this holds data larger than u8; see the
71- /// documentation on primitive representations:
72- /// https://doc.rust-lang.org/reference/type-layout.html#primitive-representations
73- ///
74- /// If the order of the enum is changed, or if variants are added or removed,
75- /// then [`PROFILE_TYPES`] needs to be changed.
76- #[ repr( u8 ) ]
77- pub enum SampleValue {
78- WallTime { nanoseconds : i64 , count : i64 } ,
79- CpuTime { nanoseconds : i64 } ,
80- Alloc { bytes : i64 , count : i64 } ,
81- Timeline { nanoseconds : i64 } ,
82- Exception { count : i64 } ,
83- FileIoReadTime { nanoseconds : i64 , count : i64 } ,
84- FileIoWriteTime { nanoseconds : i64 , count : i64 } ,
85- FileIoReadSize { bytes : i64 , count : i64 } ,
86- FileIoWriteSize { bytes : i64 , count : i64 } ,
87- SocketReadTime { nanoseconds : i64 , count : i64 } ,
88- SocketWriteTime { nanoseconds : i64 , count : i64 } ,
89- SocketReadSize { bytes : i64 , count : i64 } ,
90- SocketWriteSize { bytes : i64 , count : i64 } ,
91- }
69+ // // / The sample values for a given profile type.
70+ // // /
71+ // // / The repr(u8) is valid even though this holds data larger than u8; see the
72+ // // / documentation on primitive representations:
73+ // // / https://doc.rust-lang.org/reference/type-layout.html#primitive-representations
74+ // // /
75+ // // / If the order of the enum is changed, or if variants are added or removed,
76+ // /// then [`PROFILE_TYPES`] needs to be changed (or vice versa)
77+ // #[repr(u8)]
78+ // pub enum SampleValue {
79+ // WallTime { nanoseconds: i64, count: i64 },
80+ // CpuTime { nanoseconds: i64 },
81+ // Alloc { bytes: i64, count: i64 },
82+ // Timeline { nanoseconds: i64 },
83+ // Exception { count: i64 },
84+ // FileIoReadTime { nanoseconds: i64, count: i64 },
85+ // FileIoWriteTime { nanoseconds: i64, count: i64 },
86+ // FileIoReadSize { bytes: i64, count: i64 },
87+ // FileIoWriteSize { bytes: i64, count: i64 },
88+ // SocketReadTime { nanoseconds: i64, count: i64 },
89+ // SocketWriteTime { nanoseconds: i64, count: i64 },
90+ // SocketReadSize { bytes: i64, count: i64 },
91+ // SocketWriteSize { bytes: i64, count: i64 },
92+ // }
9293
9394/// Tracks which profile types are enabled. Since there are 1 or 2 sample
9495/// types per profile, it also keeps a bitset for which sample types and
@@ -234,8 +235,8 @@ impl EnabledProfiles {
234235 pub fn filter < ' a > (
235236 & self ,
236237 sample_values : & ' a SampleValues ,
237- ) -> SampleIter < i64 , impl Iterator < Item = i64 > + ' a > {
238- let bitset = self . samples . clone ( ) ;
238+ ) -> SampleIter < impl Iterator < Item = i64 > + ' a > {
239+ let bitset = self . samples ;
239240 let len = bitset. len ( ) ;
240241 let iter =
241242 sample_values
@@ -252,9 +253,7 @@ impl EnabledProfiles {
252253 SampleIter { len, iter }
253254 }
254255
255- pub fn enabled_profile_types < ' a > (
256- & ' a self ,
257- ) -> SampleIter < ProfileType , impl Iterator < Item = ProfileType > + ' a > {
256+ pub fn enabled_profile_types ( & self ) -> SampleIter < impl Iterator < Item = ProfileType > + ' _ > {
258257 let len = self . num_enabled_profiles ( ) ;
259258 let iter = PROFILE_TYPES
260259 . iter ( )
@@ -265,9 +264,7 @@ impl EnabledProfiles {
265264 SampleIter { len, iter }
266265 }
267266
268- pub fn enabled_sample_types < ' a > (
269- & ' a self ,
270- ) -> SampleIter < ValueType , impl Iterator < Item = ValueType > + ' a > {
267+ pub fn enabled_sample_types ( & self ) -> SampleIter < impl Iterator < Item = ValueType > + ' _ > {
271268 let len = self . num_enabled_sample_types ( ) ;
272269 let iter = self . enabled_profile_types ( ) . flatten ( ) ;
273270 SampleIter { len, iter }
@@ -399,28 +396,26 @@ const SAMPLE_TYPE_FILE_IO_WRITE_SIZE: ProfileType = ProfileType::from([
399396 } ,
400397] ) ;
401398
402- impl SampleValue {
403- fn discriminant ( & self ) -> usize {
404- // SAFETY: SampleValue uses a primitive representation.
405- let r#repr = unsafe { * ( self as * const Self as * const u8 ) } ;
406- r#repr as usize
407- }
408- }
409-
410- impl SampleValue {
411- pub fn sample_types ( & self ) -> ProfileType {
412- let discriminant = self . discriminant ( ) ;
413- PROFILE_TYPES [ discriminant]
414- }
415- }
416-
417- pub struct SampleIter < T , I : Iterator < Item = T > > {
399+ // impl SampleValue {
400+ // pub fn discriminant(&self) -> usize {
401+ // // SAFETY: SampleValue uses a primitive representation.
402+ // let r#repr = unsafe { *(self as *const Self as *const u8) };
403+ // r#repr as usize
404+ // }
405+ //
406+ // pub fn sample_types(&self) -> ProfileType {
407+ // let discriminant = self.discriminant();
408+ // PROFILE_TYPES[discriminant]
409+ // }
410+ // }
411+
412+ pub struct SampleIter < I : Iterator > {
418413 len : usize ,
419414 iter : I ,
420415}
421416
422- impl < T , I : Iterator < Item = T > > Iterator for SampleIter < T , I > {
423- type Item = T ;
417+ impl < I : Iterator > Iterator for SampleIter < I > {
418+ type Item = I :: Item ;
424419 fn next ( & mut self ) -> Option < Self :: Item > {
425420 let next = self . iter . next ( ) ;
426421 if next. is_some ( ) {
@@ -435,7 +430,7 @@ impl<T, I: Iterator<Item = T>> Iterator for SampleIter<T, I> {
435430 }
436431}
437432
438- impl < T , I : Iterator < Item = T > > ExactSizeIterator for SampleIter < T , I > {
433+ impl < I : Iterator > ExactSizeIterator for SampleIter < I > {
439434 fn len ( & self ) -> usize {
440435 self . len
441436 }
0 commit comments