From 0dc32ad79a6e710de08fab38f6c0ef32caa56b71 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 10 Jan 2023 15:24:48 +0100 Subject: [PATCH] Add rustdoc-json perf check --- collector/src/benchmark/mod.rs | 2 +- collector/src/benchmark/profile.rs | 7 ++++++- collector/src/bin/collector.rs | 2 +- collector/src/execute/bencher.rs | 1 + collector/src/execute/mod.rs | 14 +++++++++----- collector/src/toolchain.rs | 6 +++--- database/src/bin/ingest-json.rs | 1 + database/src/lib.rs | 4 ++++ database/src/pool/postgres.rs | 1 + database/src/pool/sqlite.rs | 1 + site/src/request_handlers/dashboard.rs | 3 +++ 11 files changed, 31 insertions(+), 11 deletions(-) diff --git a/collector/src/benchmark/mod.rs b/collector/src/benchmark/mod.rs index 1675e8e74..d1ef133f9 100644 --- a/collector/src/benchmark/mod.rs +++ b/collector/src/benchmark/mod.rs @@ -291,7 +291,7 @@ impl Benchmark { } // Rustdoc does not support incremental compilation - if profile != Profile::Doc { + if profile.is_doc() { // An incremental from scratch (slowest incremental case). // This is required for any subsequent incremental builds. if scenarios.iter().any(|s| s.is_incr()) { diff --git a/collector/src/benchmark/profile.rs b/collector/src/benchmark/profile.rs index 44cbf6a8f..ffd4cb45c 100644 --- a/collector/src/benchmark/profile.rs +++ b/collector/src/benchmark/profile.rs @@ -4,15 +4,20 @@ pub enum Profile { Check, Debug, Doc, + JsonDoc, Opt, } impl Profile { pub fn all() -> Vec { - vec![Profile::Check, Profile::Debug, Profile::Doc, Profile::Opt] + vec![Profile::Check, Profile::Debug, Profile::Doc, Profile::JsonDoc, Profile::Opt] } pub fn all_non_doc() -> Vec { vec![Profile::Check, Profile::Debug, Profile::Opt] } + + pub fn is_doc(self) -> bool { + matches!(self, Self::Doc | Self::JsonDoc) + } } diff --git a/collector/src/bin/collector.rs b/collector/src/bin/collector.rs index fbae8528b..b21e2d68b 100644 --- a/collector/src/bin/collector.rs +++ b/collector/src/bin/collector.rs @@ -233,7 +233,7 @@ fn generate_cachegrind_diffs( for benchmark in benchmarks { for &profile in profiles { for scenario in scenarios.iter().flat_map(|scenario| { - if profile == Profile::Doc && scenario.is_incr() { + if profile.is_doc() && scenario.is_incr() { return vec![]; } match scenario { diff --git a/collector/src/execute/bencher.rs b/collector/src/execute/bencher.rs index bae1ffda5..d687e6315 100644 --- a/collector/src/execute/bencher.rs +++ b/collector/src/execute/bencher.rs @@ -98,6 +98,7 @@ impl<'a> BenchProcessor<'a> { Profile::Check => database::Profile::Check, Profile::Debug => database::Profile::Debug, Profile::Doc => database::Profile::Doc, + Profile::JsonDoc => database::Profile::JsonDoc, Profile::Opt => database::Profile::Opt, }; diff --git a/collector/src/execute/mod.rs b/collector/src/execute/mod.rs index b3aef91cb..dbf56c9d8 100644 --- a/collector/src/execute/mod.rs +++ b/collector/src/execute/mod.rs @@ -61,7 +61,7 @@ impl PerfTool { | ProfileTool(DepGraph) | ProfileTool(MonoItems) | ProfileTool(LlvmIr) => { - if profile == Profile::Doc { + if profile.is_doc() { Some("rustdoc") } else { Some("rustc") @@ -69,7 +69,7 @@ impl PerfTool { } ProfileTool(LlvmLines) => match profile { Profile::Debug | Profile::Opt => Some("llvm-lines"), - Profile::Check | Profile::Doc => None, + Profile::Check | Profile::Doc | Profile::JsonDoc => None, }, } } @@ -210,9 +210,10 @@ impl<'a> CargoProcess<'a> { Some(sub) => sub, } } else { - match self.profile { - Profile::Doc => "rustdoc", - _ => "rustc", + if self.profile.is_doc() { + "rustdoc" + } else { + "rustc" } }; @@ -224,6 +225,9 @@ impl<'a> CargoProcess<'a> { } Profile::Debug => {} Profile::Doc => {} + Profile::JsonDoc => { + cmd.env("RUSTDOCFLAGS", "-Z unstable-options --output-format=json"); + } Profile::Opt => { cmd.arg("--release"); } diff --git a/collector/src/toolchain.rs b/collector/src/toolchain.rs index 2a47fc9d9..b433845ce 100644 --- a/collector/src/toolchain.rs +++ b/collector/src/toolchain.rs @@ -347,15 +347,15 @@ pub fn get_local_toolchain( Some(rustdoc.canonicalize().with_context(|| { format!("failed to canonicalize rustdoc executable {:?}", rustdoc) })?) - } else if profiles.contains(&Profile::Doc) { + } else if profiles.iter().any(|p| p.is_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); Some(rustdoc) } else { anyhow::bail!( - "'Doc' build specified but '--rustdoc' not specified and no 'rustdoc' found \ - next to 'rustc'" + "'Doc' or 'JsonDoc' build specified but '--rustdoc' not specified and no \ + 'rustdoc' found next to 'rustc'" ); } } else { diff --git a/database/src/bin/ingest-json.rs b/database/src/bin/ingest-json.rs index 2bb6d9536..8d770dd0e 100644 --- a/database/src/bin/ingest-json.rs +++ b/database/src/bin/ingest-json.rs @@ -925,6 +925,7 @@ async fn ingest(conn: &T, caches: &mut IdCache, path: &Path) { Profile::Check => "check", Profile::Debug => "debug", Profile::Doc => "doc", + Profile::JsonDoc => "jsondoc", Profile::Opt => "opt", }; let state = match &run.state { diff --git a/database/src/lib.rs b/database/src/lib.rs index 57df45907..4bc3716b2 100644 --- a/database/src/lib.rs +++ b/database/src/lib.rs @@ -222,6 +222,8 @@ pub enum Profile { Debug, /// A doc build Doc, + /// A doc build with `--output-format=json` option. + JsonDoc, /// An optimized "release" build Opt, } @@ -233,6 +235,7 @@ impl std::str::FromStr for Profile { "check" => Profile::Check, "debug" => Profile::Debug, "doc" => Profile::Doc, + "jsondoc" => Profile::JsonDoc, "opt" => Profile::Opt, _ => return Err(format!("{} is not a profile", s)), }) @@ -249,6 +252,7 @@ impl fmt::Display for Profile { Profile::Opt => "opt", Profile::Debug => "debug", Profile::Doc => "doc", + Profile::JsonDoc => "jsondoc", } ) } diff --git a/database/src/pool/postgres.rs b/database/src/pool/postgres.rs index 5386cd645..065ac82a8 100644 --- a/database/src/pool/postgres.rs +++ b/database/src/pool/postgres.rs @@ -551,6 +551,7 @@ where "opt" => Profile::Opt, "debug" => Profile::Debug, "doc" => Profile::Doc, + "jsondoc" => Profile::JsonDoc, o => unreachable!("{}: not a profile", o), }, row.get::<_, String>(3).as_str().parse().unwrap(), diff --git a/database/src/pool/sqlite.rs b/database/src/pool/sqlite.rs index 3ee679bac..f763ddb73 100644 --- a/database/src/pool/sqlite.rs +++ b/database/src/pool/sqlite.rs @@ -473,6 +473,7 @@ impl Connection for SqliteConnection { "opt" => Profile::Opt, "debug" => Profile::Debug, "doc" => Profile::Doc, + "jsondoc" => Profile::JsonDoc, o => unreachable!("{}: not a profile", o), }, row.get::<_, String>(3)?.as_str().parse().unwrap(), diff --git a/site/src/request_handlers/dashboard.rs b/site/src/request_handlers/dashboard.rs index b72666714..2bb133d84 100644 --- a/site/src/request_handlers/dashboard.rs +++ b/site/src/request_handlers/dashboard.rs @@ -156,6 +156,7 @@ pub struct ByProfile { pub check: T, pub debug: T, pub doc: T, + pub json_doc: T, pub opt: T, } @@ -169,6 +170,7 @@ impl ByProfile { check: f(Profile::Check).await?, debug: f(Profile::Debug).await?, doc: f(Profile::Doc).await?, + json_doc: f(Profile::JsonDoc).await?, opt: f(Profile::Opt).await?, }) } @@ -181,6 +183,7 @@ impl std::ops::Index for ByProfile { Profile::Check => &self.check, Profile::Debug => &self.debug, Profile::Doc => &self.doc, + Profile::JsonDoc => &self.json_doc, Profile::Opt => &self.opt, } }