Skip to content

[Perf] Most time-consuming lints #14707

Open
@blyxyas

Description

@blyxyas

Expanded from this thread on Zulip.

I've come up with a way to isolate lints, and run them individually in a lintcheck --perf run. Here are the results:

The five lints with the highest impact are (in order or importance)

  • ctfe::ClippyCtfe with 1.05e9 instructions
  • minmax::MinMaxPass with 0.94e9
  • needless_late_init::NeedlessLateInit
  • methods::Methods with 0.92e9
  • explicit_write::ExplicitWrite with 0.90e9

Here they are represented by the five biggest peaks:

Graph on lint instruction count

Note that I could only perform the experiment on 326 out of the 344 existing passes because of experiment issues, there may exist hidden performance-intensive lints. Still, we can focus on fixing those five before any others.

Spiritual successor to #12188

HOW TO REPRODUCE

  • Clone my isolate-lints branch (or manually copy-paste the changes into your branch).

Then, ideally get a server to do this work because it will be like 10 hours of PC work (ideally without any background processes).

  • Run pypy.py, it will extract all passes from clippy_lints/src/lib.rs into about 350 files.
  • Check the last file and remove that unnecessary }, if you don't do this it will result in a compilation file in that last pass.

See lib.rs? It has an include!(var!(SELECTED_LINT_FILE)), we'll use that.

The following code block is written in bash, translate it into your preferred terminal language.

for f in ./*.txt; do
    SELECTED_LINTS_FILE=../../$f cargo lintcheck --perf --crates-toml=lintcheck/tokio_benchmark.toml && rm -r target/release/ ;
done

It will generate 344 perf.data files, we now need to convert this into readable scripts.

for f in ./perf.data*; do
  perf script -i $f > scripted/$f.scripted
done

This will generate about 344 perf.x.scripted. You can now use data-crunch/pypy.py to get the results (note that if the python data-crunch/pypy.py prints 37, you'll have to go to 38.txt to find which lint that corresponds to because the file-making script starts from 1.txt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.performance-projectFor issues and PRs related to the Clippy Performance Project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions