Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TimeLine LLVM profiling with the self profiler #58488

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ pub mod util {
pub mod common;
pub mod ppaux;
pub mod nodemap;
pub mod time_graph;
pub mod profiling;
pub mod bug;
}
Expand Down
31 changes: 23 additions & 8 deletions src/librustc/util/profiling.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::fs;
use std::io::{BufWriter, Write};
use std::mem;
Expand All @@ -20,12 +21,12 @@ pub enum ProfileCategory {
Other,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProfilerEvent {
QueryStart { query_name: &'static str, category: ProfileCategory, time: u64 },
QueryEnd { query_name: &'static str, category: ProfileCategory, time: u64 },
GenericActivityStart { category: ProfileCategory, time: u64 },
GenericActivityEnd { category: ProfileCategory, time: u64 },
GenericActivityStart { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
GenericActivityEnd { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
IncrementalLoadResultStart { query_name: &'static str, time: u64 },
IncrementalLoadResultEnd { query_name: &'static str, time: u64 },
QueryCacheHit { query_name: &'static str, category: ProfileCategory, time: u64 },
Expand Down Expand Up @@ -75,17 +76,27 @@ impl SelfProfiler {
}

#[inline]
pub fn start_activity(&mut self, category: ProfileCategory) {
pub fn start_activity(
&mut self,
category: ProfileCategory,
label: impl Into<Cow<'static, str>>,
) {
self.record(ProfilerEvent::GenericActivityStart {
category,
label: label.into(),
time: self.get_time_from_start(),
})
}

#[inline]
pub fn end_activity(&mut self, category: ProfileCategory) {
pub fn end_activity(
&mut self,
category: ProfileCategory,
label: impl Into<Cow<'static, str>>,
) {
self.record(ProfilerEvent::GenericActivityEnd {
category,
label: label.into(),
time: self.get_time_from_start(),
})
}
Expand Down Expand Up @@ -273,11 +284,12 @@ impl SelfProfiler {
nanos,
thread_id,
).unwrap(),
GenericActivityStart { category, time: _ } =>
GenericActivityStart { category, label, time: _ } =>
write!(file,
"{{
\"GenericActivityStart\": {{\
\"category\": \"{:?}\",\
\"label\": \"{}\",\
\"time\": {{\
\"secs\": {},\
\"nanos\": {}\
Expand All @@ -286,15 +298,17 @@ impl SelfProfiler {
}}\
}}",
category,
label,
secs,
nanos,
thread_id,
).unwrap(),
GenericActivityEnd { category, time: _ } =>
GenericActivityEnd { category, label, time: _ } =>
write!(file,
"{{\
\"GenericActivityEnd\": {{\
\"category\": \"{:?}\",\
\"label\": \"{}\",\
\"time\": {{\
\"secs\": {},\
\"nanos\": {}\
Expand All @@ -303,6 +317,7 @@ impl SelfProfiler {
}}\
}}",
category,
label,
secs,
nanos,
thread_id,
Expand Down Expand Up @@ -418,7 +433,7 @@ impl SelfProfiler {
secs,
nanos,
thread_id,
).unwrap()
).unwrap(),
}
}
}
Expand Down
268 changes: 0 additions & 268 deletions src/librustc/util/time_graph.rs

This file was deleted.

Loading