Skip to content

Commit bf20a56

Browse files
committed
Move the rest of 'build_kind' to 'profile_kind'
1 parent 64c192d commit bf20a56

File tree

3 files changed

+71
-73
lines changed

3 files changed

+71
-73
lines changed

collector/src/execute.rs

+43-46
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Profiler {
230230

231231
// What cargo subcommand do we need to run for this profiler? If not
232232
// `rustc`, must be a subcommand that itself invokes `rustc`.
233-
fn subcommand(&self, build_kind: ProfileKind) -> Option<&'static str> {
233+
fn subcommand(&self, profile_kind: ProfileKind) -> Option<&'static str> {
234234
match self {
235235
Profiler::PerfStat
236236
| Profiler::PerfStatSelfProfile
@@ -247,13 +247,13 @@ impl Profiler {
247247
| Profiler::DepGraph
248248
| Profiler::MonoItems
249249
| Profiler::Eprintln => {
250-
if build_kind == ProfileKind::Doc {
250+
if profile_kind == ProfileKind::Doc {
251251
Some("rustdoc")
252252
} else {
253253
Some("rustc")
254254
}
255255
}
256-
Profiler::LlvmLines => match build_kind {
256+
Profiler::LlvmLines => match profile_kind {
257257
ProfileKind::Debug | ProfileKind::Opt => Some("llvm-lines"),
258258
ProfileKind::Check | ProfileKind::Doc => None,
259259
},
@@ -286,7 +286,7 @@ impl Profiler {
286286
struct CargoProcess<'a> {
287287
compiler: Compiler<'a>,
288288
cwd: &'a Path,
289-
build_kind: ProfileKind,
289+
profile_kind: ProfileKind,
290290
incremental: bool,
291291
processor_etc: Option<(
292292
&'a mut dyn Processor,
@@ -361,9 +361,9 @@ impl<'a> CargoProcess<'a> {
361361
// really.
362362
fn run_rustc(&mut self, needs_final: bool) -> anyhow::Result<()> {
363363
log::info!(
364-
"run_rustc with incremental={}, build_kind={:?}, scenario_kind={:?}, patch={:?}",
364+
"run_rustc with incremental={}, profile_kind={:?}, scenario_kind={:?}, patch={:?}",
365365
self.incremental,
366-
self.build_kind,
366+
self.profile_kind,
367367
self.processor_etc.as_ref().map(|v| v.1),
368368
self.processor_etc.as_ref().and_then(|v| v.3)
369369
);
@@ -374,33 +374,33 @@ impl<'a> CargoProcess<'a> {
374374
// machinery works).
375375
let subcommand =
376376
if let Some((ref mut processor, scenario_kind, ..)) = self.processor_etc {
377-
let profiler = processor.profiler(self.build_kind);
377+
let profiler = processor.profiler(self.profile_kind);
378378
if !profiler.is_scenario_kind_allowed(scenario_kind) {
379379
return Err(anyhow::anyhow!(
380380
"this profiler doesn't support {:?} scenarios",
381381
scenario_kind
382382
));
383383
}
384384

385-
match profiler.subcommand(self.build_kind) {
385+
match profiler.subcommand(self.profile_kind) {
386386
None => {
387387
return Err(anyhow::anyhow!(
388-
"this profiler doesn't support {:?} builds",
389-
self.build_kind
388+
"this profiler doesn't support the {:?} profile",
389+
self.profile_kind
390390
))
391391
}
392392
Some(sub) => sub,
393393
}
394394
} else {
395-
match self.build_kind {
395+
match self.profile_kind {
396396
ProfileKind::Doc => "rustdoc",
397397
_ => "rustc",
398398
}
399399
};
400400

401401
let mut cmd = self.base_command(self.cwd, subcommand);
402402
cmd.arg("-p").arg(self.get_pkgid(self.cwd)?);
403-
match self.build_kind {
403+
match self.profile_kind {
404404
ProfileKind::Check => {
405405
cmd.arg("--profile").arg("check");
406406
}
@@ -428,7 +428,7 @@ impl<'a> CargoProcess<'a> {
428428
.as_mut()
429429
.map(|v| &mut v.0)
430430
.expect("needs_final needs a processor");
431-
let profiler = processor.profiler(self.build_kind).name();
431+
let profiler = processor.profiler(self.profile_kind).name();
432432
// If we're using a processor, we expect that only the crate
433433
// we're interested in benchmarking will be built, not any
434434
// dependencies.
@@ -484,7 +484,7 @@ impl<'a> CargoProcess<'a> {
484484
let data = ProcessOutputData {
485485
name: self.processor_name.clone(),
486486
cwd: self.cwd,
487-
build_kind: self.build_kind,
487+
profile_kind: self.profile_kind,
488488
scenario_kind,
489489
scenario_kind_str,
490490
patch,
@@ -534,7 +534,7 @@ pub enum Retry {
534534
pub struct ProcessOutputData<'a> {
535535
name: BenchmarkName,
536536
cwd: &'a Path,
537-
build_kind: ProfileKind,
537+
profile_kind: ProfileKind,
538538
scenario_kind: ScenarioKind,
539539
scenario_kind_str: &'a str,
540540
patch: Option<&'a Patch>,
@@ -626,7 +626,7 @@ impl<'a> MeasureProcessor<'a> {
626626
fn insert_stats(
627627
&mut self,
628628
scenario: database::Scenario,
629-
build_kind: ProfileKind,
629+
profile_kind: ProfileKind,
630630
stats: (Stats, Option<SelfProfile>, Option<SelfProfileFiles>),
631631
) {
632632
let version = String::from_utf8(
@@ -642,7 +642,7 @@ impl<'a> MeasureProcessor<'a> {
642642
.unwrap();
643643

644644
let collection = self.rt.block_on(self.conn.collection_id(&version));
645-
let profile = match build_kind {
645+
let profile = match profile_kind {
646646
ProfileKind::Check => database::Profile::Check,
647647
ProfileKind::Debug => database::Profile::Debug,
648648
ProfileKind::Doc => database::Profile::Doc,
@@ -806,7 +806,7 @@ impl Upload {
806806
}
807807

808808
impl<'a> Processor for MeasureProcessor<'a> {
809-
fn profiler(&self, _build: ProfileKind) -> Profiler {
809+
fn profiler(&self, _profile: ProfileKind) -> Profiler {
810810
if self.is_first_collection && self.is_self_profile {
811811
if cfg!(unix) {
812812
Profiler::PerfStatSelfProfile
@@ -826,11 +826,11 @@ impl<'a> Processor for MeasureProcessor<'a> {
826826
self.is_first_collection = true;
827827
}
828828

829-
fn finished_first_collection(&mut self, build: ProfileKind) -> bool {
830-
let original = self.profiler(build);
829+
fn finished_first_collection(&mut self, profile: ProfileKind) -> bool {
830+
let original = self.profiler(profile);
831831
self.is_first_collection = false;
832832
// We need to run again if we're going to use a different profiler
833-
self.profiler(build) != original
833+
self.profiler(profile) != original
834834
}
835835

836836
fn process_output(
@@ -842,27 +842,27 @@ impl<'a> Processor for MeasureProcessor<'a> {
842842
Ok(res) => {
843843
match data.scenario_kind {
844844
ScenarioKind::Full => {
845-
self.insert_stats(database::Scenario::Empty, data.build_kind, res);
845+
self.insert_stats(database::Scenario::Empty, data.profile_kind, res);
846846
}
847847
ScenarioKind::IncrFull => {
848848
self.insert_stats(
849849
database::Scenario::IncrementalEmpty,
850-
data.build_kind,
850+
data.profile_kind,
851851
res,
852852
);
853853
}
854854
ScenarioKind::IncrUnchanged => {
855855
self.insert_stats(
856856
database::Scenario::IncrementalFresh,
857-
data.build_kind,
857+
data.profile_kind,
858858
res,
859859
);
860860
}
861861
ScenarioKind::IncrPatched => {
862862
let patch = data.patch.unwrap();
863863
self.insert_stats(
864864
database::Scenario::IncrementalPatch(patch.name),
865-
data.build_kind,
865+
data.profile_kind,
866866
res,
867867
);
868868
}
@@ -934,7 +934,7 @@ impl<'a> Processor for ProfileProcessor<'a> {
934934
let out_file = |prefix: &str| -> String {
935935
format!(
936936
"{}-{}-{}-{:?}-{}",
937-
prefix, self.id, data.name, data.build_kind, data.scenario_kind_str
937+
prefix, self.id, data.name, data.profile_kind, data.scenario_kind_str
938938
)
939939
};
940940

@@ -1292,7 +1292,7 @@ impl Benchmark {
12921292
&'a self,
12931293
compiler: Compiler<'a>,
12941294
cwd: &'a Path,
1295-
build_kind: ProfileKind,
1295+
profile_kind: ProfileKind,
12961296
) -> CargoProcess<'a> {
12971297
let mut cargo_args = self
12981298
.config
@@ -1313,7 +1313,7 @@ impl Benchmark {
13131313
compiler,
13141314
processor_name: self.name.clone(),
13151315
cwd,
1316-
build_kind,
1316+
profile_kind,
13171317
incremental: false,
13181318
processor_etc: None,
13191319
manifest_path: self
@@ -1339,7 +1339,7 @@ impl Benchmark {
13391339
pub fn measure(
13401340
&self,
13411341
processor: &mut dyn Processor,
1342-
build_kinds: &[ProfileKind],
1342+
profile_kinds: &[ProfileKind],
13431343
scenario_kinds: &[ScenarioKind],
13441344
compiler: Compiler<'_>,
13451345
iterations: Option<usize>,
@@ -1350,13 +1350,13 @@ impl Benchmark {
13501350
return processor.measure_rustc(compiler).context("measure rustc");
13511351
}
13521352

1353-
if self.config.disabled || build_kinds.is_empty() {
1353+
if self.config.disabled || profile_kinds.is_empty() {
13541354
eprintln!("Skipping {}: disabled", self.name);
13551355
bail!("disabled benchmark");
13561356
}
13571357

13581358
eprintln!("Preparing {}", self.name);
1359-
let build_kind_dirs = build_kinds
1359+
let profile_kind_dirs = profile_kinds
13601360
.iter()
13611361
.map(|kind| Ok((*kind, self.make_temp_dir(&self.path)?)))
13621362
.collect::<anyhow::Result<Vec<_>>>()?;
@@ -1385,10 +1385,10 @@ impl Benchmark {
13851385
// target-directory global lock during compilation.
13861386
crossbeam_utils::thread::scope::<_, anyhow::Result<()>>(|s| {
13871387
let server = jobserver::Client::new(num_cpus::get()).context("jobserver::new")?;
1388-
for (build_kind, prep_dir) in &build_kind_dirs {
1388+
for (profile_kind, prep_dir) in &profile_kind_dirs {
13891389
let server = server.clone();
13901390
s.spawn::<_, anyhow::Result<()>>(move |_| {
1391-
self.mk_cargo_process(compiler, prep_dir.path(), *build_kind)
1391+
self.mk_cargo_process(compiler, prep_dir.path(), *profile_kind)
13921392
.jobserver(server)
13931393
.run_rustc(false)?;
13941394
Ok(())
@@ -1398,18 +1398,18 @@ impl Benchmark {
13981398
})
13991399
.unwrap()?;
14001400

1401-
for (build_kind, prep_dir) in build_kind_dirs {
1401+
for (profile_kind, prep_dir) in profile_kind_dirs {
14021402
eprintln!(
14031403
"Running {}: {:?} + {:?}",
1404-
self.name, build_kind, scenario_kinds
1404+
self.name, profile_kind, scenario_kinds
14051405
);
14061406

14071407
// We want at least two runs for all benchmarks (since we run
14081408
// self-profile separately).
14091409
processor.start_first_collection();
14101410
for i in 0..cmp::max(iterations, 2) {
14111411
if i == 1 {
1412-
let different = processor.finished_first_collection(build_kind);
1412+
let different = processor.finished_first_collection(profile_kind);
14131413
if iterations == 1 && !different {
14141414
// Don't run twice if this processor doesn't need it and
14151415
// we've only been asked to run once.
@@ -1423,28 +1423,25 @@ impl Benchmark {
14231423

14241424
// A full non-incremental build.
14251425
if scenario_kinds.contains(&ScenarioKind::Full) {
1426-
self.mk_cargo_process(compiler, cwd, build_kind)
1426+
self.mk_cargo_process(compiler, cwd, profile_kind)
14271427
.processor(processor, ScenarioKind::Full, "Full", None)
14281428
.run_rustc(true)?;
14291429
}
14301430

14311431
// Rustdoc does not support incremental compilation
1432-
if build_kind != ProfileKind::Doc {
1433-
// An incremental build from scratch (slowest incremental case).
1432+
if profile_kind != ProfileKind::Doc {
1433+
// An incremental from scratch (slowest incremental case).
14341434
// This is required for any subsequent incremental builds.
1435-
if scenario_kinds.contains(&ScenarioKind::IncrFull)
1436-
|| scenario_kinds.contains(&ScenarioKind::IncrUnchanged)
1437-
|| scenario_kinds.contains(&ScenarioKind::IncrPatched)
1438-
{
1439-
self.mk_cargo_process(compiler, cwd, build_kind)
1435+
if scenario_kinds.iter().any(|s| s.is_incr()) {
1436+
self.mk_cargo_process(compiler, cwd, profile_kind)
14401437
.incremental(true)
14411438
.processor(processor, ScenarioKind::IncrFull, "IncrFull", None)
14421439
.run_rustc(true)?;
14431440
}
14441441

14451442
// An incremental build with no changes (fastest incremental case).
14461443
if scenario_kinds.contains(&ScenarioKind::IncrUnchanged) {
1447-
self.mk_cargo_process(compiler, cwd, build_kind)
1444+
self.mk_cargo_process(compiler, cwd, profile_kind)
14481445
.incremental(true)
14491446
.processor(
14501447
processor,
@@ -1463,7 +1460,7 @@ impl Benchmark {
14631460
// An incremental build with some changes (realistic
14641461
// incremental case).
14651462
let scenario_kind_str = format!("IncrPatched{}", i);
1466-
self.mk_cargo_process(compiler, cwd, build_kind)
1463+
self.mk_cargo_process(compiler, cwd, profile_kind)
14671464
.incremental(true)
14681465
.processor(
14691466
processor,

collector/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ pub fn robocopy(
186186
}
187187

188188
fn run_command_with_output(cmd: &mut Command) -> anyhow::Result<process::Output> {
189-
log::trace!("running: {:?}", cmd);
190189
let mut child = cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
191190

192191
let mut stdout = Vec::new();
@@ -218,8 +217,8 @@ fn run_command_with_output(cmd: &mut Command) -> anyhow::Result<process::Output>
218217

219218
Ok(process::Output {
220219
status,
221-
stdout: stdout,
222-
stderr: stderr,
220+
stdout,
221+
stderr,
223222
})
224223
}
225224

@@ -228,7 +227,7 @@ pub fn command_output(cmd: &mut Command) -> anyhow::Result<process::Output> {
228227

229228
if !output.status.success() {
230229
return Err(anyhow::anyhow!(
231-
"expected success, got {}\n\nstderr={}\n\n stdout={}",
230+
"expected success, got {}\n\nstderr={}\n\n stdout={}\n",
232231
output.status,
233232
String::from_utf8_lossy(&output.stderr),
234233
String::from_utf8_lossy(&output.stdout)

0 commit comments

Comments
 (0)