Skip to content

Commit 766f920

Browse files
Add dep-graph collector
1 parent a3b9c2d commit 766f920

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

collector/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ The mandatory `<PROFILER>` argument must be one of the following.
366366
- **Output**. File per CGU, currently, placed in a directory inside results.
367367
- **Notes**. Will likely work best with `Full` builds, on either Debug or Opt
368368
profiles.
369+
- `dep-graph`: Dump the incremental dependency graph (as produced by
370+
-Zdump-dep-graph).
371+
- **Purpose**. This is useful when debugging changes to incremental behavior.
372+
- **Slowdown**. Equivalent to normal compilation.
373+
- **Output**. .dot and .txt file (.txt likely is what you want to see first).
374+
- **Notes**. Works primarily with incremental compilation kinds.
369375

370376
The mandatory `<RUSTC>` argument is a patch to a rustc executable, similar to
371377
`bench_local`.

collector/src/execute.rs

+21
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ pub enum Profiler {
180180
Eprintln,
181181
LlvmLines,
182182
MonoItems,
183+
DepGraph,
183184
}
184185

185186
impl Profiler {
@@ -201,6 +202,7 @@ impl Profiler {
201202
"eprintln" => Ok(Profiler::Eprintln),
202203
"llvm-lines" => Ok(Profiler::LlvmLines),
203204
"mono-items" => Ok(Profiler::MonoItems),
205+
"dep-graph" => Ok(Profiler::DepGraph),
204206
_ => Err(anyhow!("'{}' is not a known profiler", name)),
205207
}
206208
}
@@ -222,6 +224,7 @@ impl Profiler {
222224
Profiler::Eprintln => "eprintln",
223225
Profiler::LlvmLines => "llvm-lines",
224226
Profiler::MonoItems => "mono-items",
227+
Profiler::DepGraph => "dep-graph",
225228
}
226229
}
227230

@@ -241,6 +244,7 @@ impl Profiler {
241244
| Profiler::Callgrind
242245
| Profiler::DHAT
243246
| Profiler::Massif
247+
| Profiler::DepGraph
244248
| Profiler::MonoItems
245249
| Profiler::Eprintln => {
246250
if build_kind == BuildKind::Doc {
@@ -272,6 +276,8 @@ impl Profiler {
272276
| Profiler::Massif
273277
| Profiler::MonoItems
274278
| Profiler::Eprintln => true,
279+
// only incremental
280+
Profiler::DepGraph => scenario_kind != ScenarioKind::Full,
275281
Profiler::LlvmLines => scenario_kind == ScenarioKind::Full,
276282
}
277283
}
@@ -1183,6 +1189,21 @@ impl<'a> Processor for ProfileProcessor<'a> {
11831189
}
11841190
}
11851191

1192+
Profiler::DepGraph => {
1193+
let tmp_file = filepath(data.cwd.as_ref(), "dep_graph.txt");
1194+
let output =
1195+
filepath(self.output_dir, &out_file("dep-graph")).with_extension("txt");
1196+
1197+
fs::copy(&tmp_file, &output)?;
1198+
1199+
let tmp_file = filepath(data.cwd.as_ref(), "dep_graph.dot");
1200+
let output =
1201+
filepath(self.output_dir, &out_file("dep-graph")).with_extension("dot");
1202+
1203+
// May not exist if not incremental, but then that's OK.
1204+
fs::copy(&tmp_file, &output)?;
1205+
}
1206+
11861207
// `cargo llvm-lines` writes its output to stdout. We copy that
11871208
// output into a file in the output dir.
11881209
Profiler::LlvmLines => {

collector/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ fn main_result() -> anyhow::Result<i32> {
674674
(@arg PROFILER: +required +takes_value
675675
"One of: 'self-profile', 'time-passes', 'perf-record',\n\
676676
'oprofile', 'cachegrind', 'callgrind', 'dhat', 'massif',\n\
677-
'eprintln', 'llvm-lines', 'mono-items'")
677+
'eprintln', 'llvm-lines', 'mono-items', 'dep-graph'")
678678
(@arg RUSTC: +required +takes_value "The path to the local rustc to benchmark")
679679
(@arg ID: +required +takes_value "Identifier to associate benchmark results with")
680680

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

collector/src/rustc-fake.rs

+9
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ fn main() {
294294
assert!(cmd.status().expect("failed to spawn").success());
295295
}
296296

297+
"dep-graph" => {
298+
args.push("-Zdump-dep-graph".into());
299+
args.push("-Zquery-dep-graph".into());
300+
let mut cmd = Command::new(tool);
301+
cmd.args(&args);
302+
303+
assert!(cmd.status().expect("failed to spawn").success());
304+
}
305+
297306
_ => {
298307
panic!("unknown wrapper: {}", wrapper);
299308
}

0 commit comments

Comments
 (0)