Skip to content

Add dep-graph collector #1046

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

Merged
merged 1 commit into from
Oct 5, 2021
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
6 changes: 6 additions & 0 deletions collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ The mandatory `<PROFILER>` argument must be one of the following.
- **Output**. File per CGU, currently, placed in a directory inside results.
- **Notes**. Will likely work best with `Full` builds, on either Debug or Opt
profiles.
- `dep-graph`: Dump the incremental dependency graph (as produced by
-Zdump-dep-graph).
- **Purpose**. This is useful when debugging changes to incremental behavior.
- **Slowdown**. Equivalent to normal compilation.
- **Output**. .dot and .txt file (.txt likely is what you want to see first).
- **Notes**. Works primarily with incremental compilation kinds.

The mandatory `<RUSTC>` argument is a patch to a rustc executable, similar to
`bench_local`.
Expand Down
21 changes: 21 additions & 0 deletions collector/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub enum Profiler {
Eprintln,
LlvmLines,
MonoItems,
DepGraph,
}

impl Profiler {
Expand All @@ -201,6 +202,7 @@ impl Profiler {
"eprintln" => Ok(Profiler::Eprintln),
"llvm-lines" => Ok(Profiler::LlvmLines),
"mono-items" => Ok(Profiler::MonoItems),
"dep-graph" => Ok(Profiler::DepGraph),
_ => Err(anyhow!("'{}' is not a known profiler", name)),
}
}
Expand All @@ -222,6 +224,7 @@ impl Profiler {
Profiler::Eprintln => "eprintln",
Profiler::LlvmLines => "llvm-lines",
Profiler::MonoItems => "mono-items",
Profiler::DepGraph => "dep-graph",
}
}

Expand All @@ -241,6 +244,7 @@ impl Profiler {
| Profiler::Callgrind
| Profiler::DHAT
| Profiler::Massif
| Profiler::DepGraph
| Profiler::MonoItems
| Profiler::Eprintln => {
if build_kind == BuildKind::Doc {
Expand Down Expand Up @@ -272,6 +276,8 @@ impl Profiler {
| Profiler::Massif
| Profiler::MonoItems
| Profiler::Eprintln => true,
// only incremental
Profiler::DepGraph => scenario_kind != ScenarioKind::Full,
Profiler::LlvmLines => scenario_kind == ScenarioKind::Full,
}
}
Expand Down Expand Up @@ -1183,6 +1189,21 @@ impl<'a> Processor for ProfileProcessor<'a> {
}
}

Profiler::DepGraph => {
let tmp_file = filepath(data.cwd.as_ref(), "dep_graph.txt");
let output =
filepath(self.output_dir, &out_file("dep-graph")).with_extension("txt");

fs::copy(&tmp_file, &output)?;

let tmp_file = filepath(data.cwd.as_ref(), "dep_graph.dot");
let output =
filepath(self.output_dir, &out_file("dep-graph")).with_extension("dot");

// May not exist if not incremental, but then that's OK.
fs::copy(&tmp_file, &output)?;
}

// `cargo llvm-lines` writes its output to stdout. We copy that
// output into a file in the output dir.
Profiler::LlvmLines => {
Expand Down
4 changes: 2 additions & 2 deletions collector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ fn main_result() -> anyhow::Result<i32> {
(@arg PROFILER: +required +takes_value
"One of: 'self-profile', 'time-passes', 'perf-record',\n\
'oprofile', 'cachegrind', 'callgrind', 'dhat', 'massif',\n\
'eprintln', 'llvm-lines', 'mono-items'")
'eprintln', 'llvm-lines', 'mono-items', 'dep-graph'")
(@arg RUSTC: +required +takes_value "The path to the local rustc to benchmark")
(@arg ID: +required +takes_value "Identifier to associate benchmark results with")

Expand Down Expand Up @@ -703,7 +703,7 @@ fn main_result() -> anyhow::Result<i32> {
(@arg PROFILER: +required +takes_value
"One of: 'self-profile', 'time-passes', 'perf-record',\n\
'oprofile', 'cachegrind', 'callgrind', 'dhat', 'massif',\n\
'eprintln', 'llvm-lines', 'mono-items'")
'eprintln', 'llvm-lines', 'mono-items', 'dep-graph'")
(@arg RUSTC_BEFORE: +required +takes_value "The path to the local rustc to benchmark")
(@arg RUSTC_AFTER: +required +takes_value "The path to the local rustc to benchmark")

Expand Down
9 changes: 9 additions & 0 deletions collector/src/rustc-fake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ fn main() {
assert!(cmd.status().expect("failed to spawn").success());
}

"dep-graph" => {
args.push("-Zdump-dep-graph".into());
args.push("-Zquery-dep-graph".into());
let mut cmd = Command::new(tool);
cmd.args(&args);

assert!(cmd.status().expect("failed to spawn").success());
}

_ => {
panic!("unknown wrapper: {}", wrapper);
}
Expand Down