From 64073198d7e52c91883db7b919864672532078c5 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 5 Oct 2021 15:16:47 +0200 Subject: [PATCH 1/2] Use term 'profile' instead of 'build' as that's what we're using elsewhere --- .github/workflows/ci.yml | 4 ++-- ci/check-benchmarks.sh | 2 +- collector/src/execute.rs | 50 +++++++++++++++++++------------------- collector/src/main.rs | 52 ++++++++++++++++++++-------------------- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83989ace2..c30d7dc0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: "--exclude webrender-wrench,style-servo,cargo,rustc", "--include webrender-wrench,style-servo,cargo --exclude rustc", ] - BUILD_KINDS: [ + PROFILE_KINDS: [ "Check,Doc,Debug", "Opt", ] @@ -98,7 +98,7 @@ jobs: env: JEMALLOC_OVERRIDE: /usr/lib/x86_64-linux-gnu/libjemalloc.so BENCH_INCLUDE_EXCLUDE_OPTS: ${{ matrix.BENCH_INCLUDE_EXCLUDE_OPTS }} - BUILD_KINDS: ${{ matrix.BUILD_KINDS }} + PROFILE_KINDS: ${{ matrix.PROFILE_KINDS }} SHELL: "/bin/bash" test_profiling: diff --git a/ci/check-benchmarks.sh b/ci/check-benchmarks.sh index f089712d7..db3da14bc 100755 --- a/ci/check-benchmarks.sh +++ b/ci/check-benchmarks.sh @@ -17,7 +17,7 @@ RUST_BACKTRACE=1 \ RUST_LOG=raw_cargo_messages=trace,collector=debug,rust_sysroot=debug \ cargo run -p collector --bin collector -- \ bench_local $bindir/rustc Test \ - --builds $BUILD_KINDS \ + --builds $PROFILE_KINDS \ --cargo $bindir/cargo \ --runs All \ --rustdoc $bindir/rustdoc \ diff --git a/collector/src/execute.rs b/collector/src/execute.rs index fe82e70a2..b3a529521 100644 --- a/collector/src/execute.rs +++ b/collector/src/execute.rs @@ -1,6 +1,6 @@ //! Execute benchmarks. -use crate::{BuildKind, Compiler, ScenarioKind}; +use crate::{Compiler, ProfileKind, ScenarioKind}; use anyhow::{anyhow, bail, Context}; use collector::command_output; use collector::etw_parser; @@ -230,7 +230,7 @@ impl Profiler { // What cargo subcommand do we need to run for this profiler? If not // `rustc`, must be a subcommand that itself invokes `rustc`. - fn subcommand(&self, build_kind: BuildKind) -> Option<&'static str> { + fn subcommand(&self, build_kind: ProfileKind) -> Option<&'static str> { match self { Profiler::PerfStat | Profiler::PerfStatSelfProfile @@ -247,15 +247,15 @@ impl Profiler { | Profiler::DepGraph | Profiler::MonoItems | Profiler::Eprintln => { - if build_kind == BuildKind::Doc { + if build_kind == ProfileKind::Doc { Some("rustdoc") } else { Some("rustc") } } Profiler::LlvmLines => match build_kind { - BuildKind::Debug | BuildKind::Opt => Some("llvm-lines"), - BuildKind::Check | BuildKind::Doc => None, + ProfileKind::Debug | ProfileKind::Opt => Some("llvm-lines"), + ProfileKind::Check | ProfileKind::Doc => None, }, } } @@ -286,7 +286,7 @@ impl Profiler { struct CargoProcess<'a> { compiler: Compiler<'a>, cwd: &'a Path, - build_kind: BuildKind, + build_kind: ProfileKind, incremental: bool, processor_etc: Option<( &'a mut dyn Processor, @@ -393,7 +393,7 @@ impl<'a> CargoProcess<'a> { } } else { match self.build_kind { - BuildKind::Doc => "rustdoc", + ProfileKind::Doc => "rustdoc", _ => "rustc", } }; @@ -401,12 +401,12 @@ impl<'a> CargoProcess<'a> { let mut cmd = self.base_command(self.cwd, subcommand); cmd.arg("-p").arg(self.get_pkgid(self.cwd)?); match self.build_kind { - BuildKind::Check => { + ProfileKind::Check => { cmd.arg("--profile").arg("check"); } - BuildKind::Debug => {} - BuildKind::Doc => {} - BuildKind::Opt => { + ProfileKind::Debug => {} + ProfileKind::Doc => {} + ProfileKind::Opt => { cmd.arg("--release"); } } @@ -534,7 +534,7 @@ pub enum Retry { pub struct ProcessOutputData<'a> { name: BenchmarkName, cwd: &'a Path, - build_kind: BuildKind, + build_kind: ProfileKind, scenario_kind: ScenarioKind, scenario_kind_str: &'a str, patch: Option<&'a Patch>, @@ -544,7 +544,7 @@ pub struct ProcessOutputData<'a> { /// processing. pub trait Processor { /// The `Profiler` being used. - fn profiler(&self, _: BuildKind) -> Profiler; + fn profiler(&self, _: ProfileKind) -> Profiler; /// Process the output produced by the particular `Profiler` being used. fn process_output( @@ -563,7 +563,7 @@ pub trait Processor { /// /// Return "true" if planning on doing something different for second /// iteration. - fn finished_first_collection(&mut self, _: BuildKind) -> bool { + fn finished_first_collection(&mut self, _: ProfileKind) -> bool { false } @@ -626,7 +626,7 @@ impl<'a> MeasureProcessor<'a> { fn insert_stats( &mut self, scenario: database::Scenario, - build_kind: BuildKind, + build_kind: ProfileKind, stats: (Stats, Option, Option), ) { let version = String::from_utf8( @@ -643,10 +643,10 @@ impl<'a> MeasureProcessor<'a> { let collection = self.rt.block_on(self.conn.collection_id(&version)); let profile = match build_kind { - BuildKind::Check => database::Profile::Check, - BuildKind::Debug => database::Profile::Debug, - BuildKind::Doc => database::Profile::Doc, - BuildKind::Opt => database::Profile::Opt, + ProfileKind::Check => database::Profile::Check, + ProfileKind::Debug => database::Profile::Debug, + ProfileKind::Doc => database::Profile::Doc, + ProfileKind::Opt => database::Profile::Opt, }; if let Some(files) = stats.2 { @@ -806,7 +806,7 @@ impl Upload { } impl<'a> Processor for MeasureProcessor<'a> { - fn profiler(&self, _build: BuildKind) -> Profiler { + fn profiler(&self, _build: ProfileKind) -> Profiler { if self.is_first_collection && self.is_self_profile { if cfg!(unix) { Profiler::PerfStatSelfProfile @@ -826,7 +826,7 @@ impl<'a> Processor for MeasureProcessor<'a> { self.is_first_collection = true; } - fn finished_first_collection(&mut self, build: BuildKind) -> bool { + fn finished_first_collection(&mut self, build: ProfileKind) -> bool { let original = self.profiler(build); self.is_first_collection = false; // We need to run again if we're going to use a different profiler @@ -919,7 +919,7 @@ impl<'a> ProfileProcessor<'a> { } impl<'a> Processor for ProfileProcessor<'a> { - fn profiler(&self, _: BuildKind) -> Profiler { + fn profiler(&self, _: ProfileKind) -> Profiler { self.profiler } @@ -1292,7 +1292,7 @@ impl Benchmark { &'a self, compiler: Compiler<'a>, cwd: &'a Path, - build_kind: BuildKind, + build_kind: ProfileKind, ) -> CargoProcess<'a> { let mut cargo_args = self .config @@ -1339,7 +1339,7 @@ impl Benchmark { pub fn measure( &self, processor: &mut dyn Processor, - build_kinds: &[BuildKind], + build_kinds: &[ProfileKind], scenario_kinds: &[ScenarioKind], compiler: Compiler<'_>, iterations: Option, @@ -1429,7 +1429,7 @@ impl Benchmark { } // Rustdoc does not support incremental compilation - if build_kind != BuildKind::Doc { + if build_kind != ProfileKind::Doc { // An incremental build from scratch (slowest incremental case). // This is required for any subsequent incremental builds. if scenario_kinds.contains(&ScenarioKind::IncrFull) diff --git a/collector/src/main.rs b/collector/src/main.rs index af2df26f2..792a65798 100644 --- a/collector/src/main.rs +++ b/collector/src/main.rs @@ -43,26 +43,26 @@ impl<'a> Compiler<'a> { } #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -pub enum BuildKind { +pub enum ProfileKind { Check, Debug, Doc, Opt, } -impl BuildKind { +impl ProfileKind { fn all() -> Vec { vec![ - BuildKind::Check, - BuildKind::Debug, - BuildKind::Doc, - BuildKind::Opt, + ProfileKind::Check, + ProfileKind::Debug, + ProfileKind::Doc, + ProfileKind::Opt, ] } fn default() -> Vec { // Don't run rustdoc by default. - vec![BuildKind::Check, BuildKind::Debug, BuildKind::Opt] + vec![ProfileKind::Check, ProfileKind::Debug, ProfileKind::Opt] } } @@ -102,12 +102,12 @@ impl ScenarioKind { } } -// How the --builds arg maps to BuildKinds. -const STRINGS_AND_BUILD_KINDS: &[(&str, BuildKind)] = &[ - ("Check", BuildKind::Check), - ("Debug", BuildKind::Debug), - ("Doc", BuildKind::Doc), - ("Opt", BuildKind::Opt), +// How the --builds arg maps to ProfileKinds. +const STRINGS_AND_PROFILE_KINDS: &[(&str, ProfileKind)] = &[ + ("Check", ProfileKind::Check), + ("Debug", ProfileKind::Debug), + ("Doc", ProfileKind::Doc), + ("Opt", ProfileKind::Opt), ]; // How the --runs arg maps to ScenarioKinds. @@ -118,11 +118,11 @@ const STRINGS_AND_SCENARIO_KINDS: &[(&str, ScenarioKind)] = &[ ("IncrPatched", ScenarioKind::IncrPatched), ]; -fn build_kinds_from_arg(arg: &Option<&str>) -> anyhow::Result> { +fn build_kinds_from_arg(arg: &Option<&str>) -> anyhow::Result> { if let Some(arg) = arg { - kinds_from_arg("build", STRINGS_AND_BUILD_KINDS, arg) + kinds_from_arg("build", STRINGS_AND_PROFILE_KINDS, arg) } else { - Ok(BuildKind::default()) + Ok(ProfileKind::default()) } } @@ -211,7 +211,7 @@ fn bench( rt: &mut Runtime, pool: database::Pool, artifact_id: &ArtifactId, - build_kinds: &[BuildKind], + build_kinds: &[ProfileKind], scenario_kinds: &[ScenarioKind], compiler: Compiler<'_>, benchmarks: &[Benchmark], @@ -398,7 +398,7 @@ fn get_benchmarks( /// - `cargo`: if one is given, check if it is acceptable. Otherwise, look /// for the nightly Cargo via `rustup`. fn get_local_toolchain( - build_kinds: &[BuildKind], + build_kinds: &[ProfileKind], rustc: &str, rustdoc: Option<&str>, cargo: Option<&str>, @@ -456,7 +456,7 @@ fn get_local_toolchain( Some(PathBuf::from(rustdoc).canonicalize().with_context(|| { format!("failed to canonicalize rustdoc executable '{}'", rustdoc) })?) - } else if build_kinds.contains(&BuildKind::Doc) { + } else if build_kinds.contains(&ProfileKind::Doc) { // We need a `rustdoc`. Look for one next to `rustc`. if let Ok(rustdoc) = rustc.with_file_name("rustdoc").canonicalize() { debug!("found rustdoc: {:?}", &rustdoc); @@ -500,7 +500,7 @@ fn generate_cachegrind_diffs( id2: &str, out_dir: &Path, benchmarks: &[Benchmark], - build_kinds: &[BuildKind], + build_kinds: &[ProfileKind], scenario_kinds: &[ScenarioKind], errors: &mut BenchmarkErrors, ) { @@ -510,7 +510,7 @@ fn generate_cachegrind_diffs( if let ScenarioKind::IncrPatched = scenario_kind { continue; } - if build_kind == BuildKind::Doc && scenario_kind.is_incr() { + if build_kind == ProfileKind::Doc && scenario_kind.is_incr() { continue; } let filename = |prefix, id| { @@ -614,7 +614,7 @@ fn profile( profiler: Profiler, out_dir: &Path, benchmarks: &[Benchmark], - build_kinds: &[BuildKind], + build_kinds: &[ProfileKind], scenario_kinds: &[ScenarioKind], errors: &mut BenchmarkErrors, ) { @@ -875,7 +875,7 @@ fn main_result() -> anyhow::Result { &mut rt, pool, &ArtifactId::Commit(commit), - &BuildKind::all(), + &ProfileKind::all(), &ScenarioKind::all(), Compiler::from_sysroot(&sysroot), &benchmarks, @@ -912,10 +912,10 @@ fn main_result() -> anyhow::Result { ScenarioKind::all_non_incr() }; let build_kinds = if collector::version_supports_doc(toolchain) { - BuildKind::all() + ProfileKind::all() } else { - let mut all = BuildKind::all(); - let doc = all.iter().position(|bk| *bk == BuildKind::Doc).unwrap(); + let mut all = ProfileKind::all(); + let doc = all.iter().position(|bk| *bk == ProfileKind::Doc).unwrap(); all.remove(doc); all }; From f4db791ace2aca6f200d584f018f43243ae7a8eb Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 5 Oct 2021 16:36:46 +0200 Subject: [PATCH 2/2] Force rebuild