-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement --perf flag to lintcheck for benchmarking #14116
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
Conversation
Turns out I was completely overcomplicating myself, there was no need for an external tool such as becnhv2 or even the original becnh, we already had the benchmarking infrastructure right under our noses! This PR implements a new **lintcheck** option called --perf, using it as a flag will mean that lintcheck builds Clippy as a release package and hooks perf to it. The realization that lintcheck is already 90% of what a benchmarking tool needs came to me in a dream.
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
@@ -46,6 +46,11 @@ pub(crate) struct LintcheckConfig { | |||
/// Run clippy on the dependencies of crates specified in crates-toml | |||
#[clap(long, conflicts_with("max_jobs"))] | |||
pub recursive: bool, | |||
/// Also produce a `perf.data` file, implies --jobs=1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like this implies
is true currently, there might be a #[clap]
flag for it though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized it immediately after uploading the issue, just updated it to actually imply (declare a default value, and exit if it the flags don't comply)
lintcheck/src/main.rs
Outdated
fn build_clippy() -> String { | ||
fn build_clippy(release_build: bool) -> String { | ||
let output = Command::new("cargo") | ||
.args(["run", "--bin=clippy-driver", "--", "--version"]) | ||
.args([ | ||
"run", | ||
"--bin=clippy-driver", | ||
if release_build { "-r" } else { "" }, | ||
"--", | ||
"--version", | ||
]) | ||
.stderr(Stdio::inherit()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we want to bump up CARGO_PROFILE_RELEASE_DEBUG
when perf is enabled too?
lintcheck/src/main.rs
Outdated
if config.perf && config.max_jobs != 1 { | ||
eprintln!( | ||
"Lintcheck's --perf flag must be triggered only with 1 job,\nremove either the --jobs/-j flag or the --perf flag" | ||
); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to use Clap's conflicts_with
for this
lintcheck/src/main.rs
Outdated
"--", | ||
"cargo", | ||
]); | ||
cmd.env("CARGO_PROFILE_RELEASE_DEBUG", "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would want to go in build_clippy
as we want the debuginfo on the built clippy rather than the packages we're linting
e2a6764
to
48ae7ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
In #14116 we added a benchmarking option for Lintcheck, this commit adds a new chapter to the book AND improves that option into a more usable state. It's recommended to review one commit at a time. - **Document how to benchmark with lintcheck --perf** - **Several improvements on lintcheck perf (desc.)** - Now lintcheck perf deletes target directory after benchmarking, benchmarking with a cache isn't very useful or telling of any precise outcome. - Support for benchmarking several times without having to do a cargo clean. - Compress perf.data changelog: none
Turns out I was completely overcomplicating myself,
there was no need for an external tool such as becnhv2
or even the original becnh, we already had the benchmarking
infrastructure right under our noses!
This PR implements a new lintcheck option called
--perf, using it as a flag will mean that lintcheck
builds Clippy as a release package and hooks perf to it.
The realization that lintcheck is already 90% of what
a benchmarking tool needs came to me in a dream ☁️
changelog:none