Skip to content
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

Add rustdoc-json perf check #1512

Closed
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
2 changes: 1 addition & 1 deletion collector/src/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Benchmark {
}

// Rustdoc does not support incremental compilation
if profile != Profile::Doc {
if profile.is_doc() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

Suggested change
if profile.is_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()) {
Expand Down
7 changes: 6 additions & 1 deletion collector/src/benchmark/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ pub enum Profile {
Check,
Debug,
Doc,
JsonDoc,
Opt,
}

impl Profile {
pub fn all() -> Vec<Self> {
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<Self> {
vec![Profile::Check, Profile::Debug, Profile::Opt]
}

pub fn is_doc(self) -> bool {
matches!(self, Self::Doc | Self::JsonDoc)
}
}
2 changes: 1 addition & 1 deletion collector/src/bin/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions collector/src/execute/bencher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
14 changes: 9 additions & 5 deletions collector/src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ impl PerfTool {
| ProfileTool(DepGraph)
| ProfileTool(MonoItems)
| ProfileTool(LlvmIr) => {
if profile == Profile::Doc {
if profile.is_doc() {
Some("rustdoc")
} else {
Some("rustc")
}
}
ProfileTool(LlvmLines) => match profile {
Profile::Debug | Profile::Opt => Some("llvm-lines"),
Profile::Check | Profile::Doc => None,
Profile::Check | Profile::Doc | Profile::JsonDoc => None,
},
}
}
Expand Down Expand Up @@ -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"
}
};

Expand All @@ -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");
}
Expand Down
6 changes: 3 additions & 3 deletions collector/src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions database/src/bin/ingest-json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ async fn ingest<T: Ingesting>(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 {
Expand Down
4 changes: 4 additions & 0 deletions database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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)),
})
Expand All @@ -249,6 +252,7 @@ impl fmt::Display for Profile {
Profile::Opt => "opt",
Profile::Debug => "debug",
Profile::Doc => "doc",
Profile::JsonDoc => "jsondoc",
}
)
}
Expand Down
1 change: 1 addition & 0 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 3 additions & 0 deletions site/src/request_handlers/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub struct ByProfile<T> {
pub check: T,
pub debug: T,
pub doc: T,
pub json_doc: T,
pub opt: T,
}

Expand All @@ -169,6 +170,7 @@ impl<T> ByProfile<T> {
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?,
})
}
Expand All @@ -181,6 +183,7 @@ impl<T> std::ops::Index<Profile> for ByProfile<T> {
Profile::Check => &self.check,
Profile::Debug => &self.debug,
Profile::Doc => &self.doc,
Profile::JsonDoc => &self.json_doc,
Profile::Opt => &self.opt,
}
}
Expand Down