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

Document and improve (a lot) lintcheck --perf #14194

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

blyxyas
Copy link
Member

@blyxyas blyxyas commented Feb 10, 2025

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

Introducing a new chapter to the book, known as "Benchmarking Clippy".
It explains the benchmarking capabilities of lintcheck --perf
and gives a concrete example on how benchmark and compare a PR with
master
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2025

r? @flip1995

rustbot has assigned @flip1995.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 10, 2025
@blyxyas blyxyas changed the title book bench Document and improve (a lot) lintcheck --perf Feb 10, 2025
- 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. Now we can benchmark a PR and master (or a single
change in the same commit) without having to move the perf.data files
into an external directory.

- Compress perf.data to allow for allowing multiple stacks and
occupy much less space
@samueltardieu
Copy link
Contributor

samueltardieu commented Feb 11, 2025

Maybe we should integrate this into the CI as well. If this is costly (I haven't had a chance to try it yet), we may even be able to watch the comments and react to certain commands, as we would do with a bot.

@flip1995
Copy link
Member

r? @Alexendoo

I won't get to review this any time soon. And I think, Alex is the better reviewer for this anyway.


The first `perf.data` will not have any numbers appended, but any subsequent
benchmark will be written to `perf.data.number` with a number growing for 0.
All benchmarks are compressed so that you can
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the end of this sentence is missing! :)

cmd.args(&[
"record",
"-e",
"instructions", // Only count instructions
"-g", // Enable call-graph, useful for flamegraphs and produces richer reports
"--quiet", // Do not tamper with lintcheck's normal output
"--compression-level=22",
Copy link
Member

Choose a reason for hiding this comment

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

Does this not slow down the capture? zstd 22 is pretty slow

cmd.args(&[
"record",
"-e",
"instructions", // Only count instructions
"-g", // Enable call-graph, useful for flamegraphs and produces richer reports
"--quiet", // Do not tamper with lintcheck's normal output
"--compression-level=22",
"--freq=97", // Slow down program to capture all events
Copy link
Member

Choose a reason for hiding this comment

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

This reduces the sampling frequency considerably meaning fewer captured events

There is no way to capture all the events with perf record as it is a sampling profiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants