diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2020-10-22 08:51:31 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <eddyb@lyken.rs> | 2022-06-13 07:56:47 +0000 |
| commit | d76573abd19d50c25c5b58ec7fc5cfef579e6eef (patch) | |
| tree | dfc4bfb7dbb0054bff1ced5d5c0ed836b63d4718 /compiler/rustc_data_structures/src/profiling.rs | |
| parent | 083721a1a7365d3afe1521cd2661b2201aac0450 (diff) | |
| download | rust-d76573abd19d50c25c5b58ec7fc5cfef579e6eef.tar.gz rust-d76573abd19d50c25c5b58ec7fc5cfef579e6eef.zip | |
Integrate measureme's hardware performance counter support.
Diffstat (limited to 'compiler/rustc_data_structures/src/profiling.rs')
| -rw-r--r-- | compiler/rustc_data_structures/src/profiling.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index bf7924a81ff..a1f42d8d3c0 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -550,14 +550,20 @@ impl SelfProfiler { pub fn new( output_directory: &Path, crate_name: Option<&str>, - event_filters: &Option<Vec<String>>, + event_filters: Option<&[String]>, + counter_name: &str, ) -> Result<SelfProfiler, Box<dyn Error + Send + Sync>> { fs::create_dir_all(output_directory)?; let crate_name = crate_name.unwrap_or("unknown-crate"); - let filename = format!("{}-{}.rustc_profile", crate_name, process::id()); + // HACK(eddyb) we need to pad the PID, strange as it may seem, as its + // length can behave as a source of entropy for heap addresses, when + // ASLR is disabled and the heap is otherwise determinic. + let pid: u32 = process::id(); + let filename = format!("{}-{:07}.rustc_profile", crate_name, pid); let path = output_directory.join(&filename); - let profiler = Profiler::new(&path)?; + let profiler = + Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?; let query_event_kind = profiler.alloc_string("Query"); let generic_activity_event_kind = profiler.alloc_string("GenericActivity"); @@ -570,7 +576,7 @@ impl SelfProfiler { let mut event_filter_mask = EventFilter::empty(); - if let Some(ref event_filters) = *event_filters { + if let Some(event_filters) = event_filters { let mut unknown_events = vec![]; for item in event_filters { if let Some(&(_, mask)) = |
