about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-11-17 16:13:49 +0100
committerGitHub <noreply@github.com>2020-11-17 16:13:49 +0100
commitfa45fce0d37ed5991e1080468c84322350156f22 (patch)
tree1eee509ad8275bca3c83c3a0f6c5e398f41b4e0d /compiler/rustc_data_structures/src
parent81f9feba97adba7efc81e53a1bb0222ac977121b (diff)
parentefe703a01ac11d3fa3f6d0126645cafff143d476 (diff)
downloadrust-fa45fce0d37ed5991e1080468c84322350156f22.tar.gz
rust-fa45fce0d37ed5991e1080468c84322350156f22.zip
Rollup merge of #78702 - wesleywiser:self_profile_cgu_sizes, r=Mark-Simulacrum
[self-profiling] Include the estimated size of each cgu in the profile

This is helpful when looking for CGUs where the size estimate isn't a
good indicator of compilation time.

I verified that moving the profiling timer call doesn't affect the
results.

Results:

<img width="297" alt="Screen Shot 2020-11-03 at 7 25 04 AM" src="https://user-images.githubusercontent.com/831192/97985503-5901d100-1da6-11eb-9f10-f3e399702952.png">

`measureme` doesn't have support for custom arg names yet so `arg0` is the CGU name and `arg1` is the estimated size.
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/profiling.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs
index e598d7a683d..5d13b7f27c7 100644
--- a/compiler/rustc_data_structures/src/profiling.rs
+++ b/compiler/rustc_data_structures/src/profiling.rs
@@ -272,6 +272,28 @@ impl SelfProfilerRef {
         })
     }
 
+    #[inline(always)]
+    pub fn generic_activity_with_args(
+        &self,
+        event_label: &'static str,
+        event_args: &[String],
+    ) -> TimingGuard<'_> {
+        self.exec(EventFilter::GENERIC_ACTIVITIES, |profiler| {
+            let builder = EventIdBuilder::new(&profiler.profiler);
+            let event_label = profiler.get_or_alloc_cached_string(event_label);
+            let event_id = if profiler.event_filter_mask.contains(EventFilter::FUNCTION_ARGS) {
+                let event_args: Vec<_> = event_args
+                    .iter()
+                    .map(|s| profiler.get_or_alloc_cached_string(&s[..]))
+                    .collect();
+                builder.from_label_and_args(event_label, &event_args)
+            } else {
+                builder.from_label(event_label)
+            };
+            TimingGuard::start(profiler, profiler.generic_activity_event_kind, event_id)
+        })
+    }
+
     /// Start profiling a query provider. Profiling continues until the
     /// TimingGuard returned from this call is dropped.
     #[inline(always)]