From b5bec171841ef35d9f29a58ec567c734348118d0 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 7 Jul 2021 11:13:46 +0200 Subject: [PATCH] Add docs to new methods --- compiler/rustc_data_structures/src/profiling.rs | 8 ++++++-- compiler/rustc_query_system/src/dep_graph/graph.rs | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 531214bc40e..ef101c56ab5 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -255,7 +255,7 @@ impl SelfProfilerRef { /// Start profiling with some event filter for a given event. Profiling continues until the /// TimingGuard returned from this call is dropped. #[inline(always)] - pub fn generic_activity_with_event(&self, event_id: EventId) -> TimingGuard<'_> { + pub fn generic_activity_with_event_id(&self, event_id: EventId) -> TimingGuard<'_> { self.exec(EventFilter::GENERIC_ACTIVITIES, |profiler| { TimingGuard::start(profiler, profiler.generic_activity_event_kind, event_id) }) @@ -390,7 +390,11 @@ impl SelfProfilerRef { } } - pub fn get_or_alloc_cached_string(&self, s: &'static str) -> Option { + /// Gets a `StringId` for the given string. This method makes sure that + /// any strings going through it will only be allocated once in the + /// profiling data. + /// Returns `None` if the self-profiling is not enabled. + pub fn get_or_alloc_cached_string(&self, s: &str) -> Option { self.profiler.as_ref().map(|p| p.get_or_alloc_cached_string(s)) } diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index d629fc2aa81..c8a46e974f3 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -39,6 +39,7 @@ pub struct DepGraph { /// The cached event id for profiling node interning. This saves us /// from having to look up the event id every time we intern a node /// which may incur too much overhead. + /// This will be None if self-profiling is disabled. node_intern_event_id: Option, } @@ -265,7 +266,7 @@ impl DepGraph { // Get timer for profiling `DepNode` interning let node_intern_timer = self .node_intern_event_id - .map(|eid| dcx.profiler().generic_activity_with_event(eid)); + .map(|eid| dcx.profiler().generic_activity_with_event_id(eid)); // Intern the new `DepNode`. let (dep_node_index, prev_and_color) = data.current.intern_node( dcx.profiler(),