Skip to content

Commit

Permalink
Add docs to new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rylev committed Jul 7, 2021
1 parent 6e33dce commit b5bec17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -390,7 +390,11 @@ impl SelfProfilerRef {
}
}

pub fn get_or_alloc_cached_string(&self, s: &'static str) -> Option<StringId> {
/// 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<StringId> {
self.profiler.as_ref().map(|p| p.get_or_alloc_cached_string(s))
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_query_system/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct DepGraph<K: DepKind> {
/// 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<EventId>,
}

Expand Down Expand Up @@ -265,7 +266,7 @@ impl<K: DepKind> DepGraph<K> {
// 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(),
Expand Down

0 comments on commit b5bec17

Please sign in to comment.