rust-lang / rust-lang/rust-clippy

[Perf] Where are the LLVM symbols coming from?

Open
#14,423 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

G-performance-project
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

When profiling Clippy either with Valgrind or with cargo lintcheck --perf, we can see that Clippy does a lot of use out of LLVM symbols. We need to investigate why is that the case and how can we remediate it.

Using Valgrind (specifically Callgrind), turns out that we are spending a lot of resources on LLVM symbols that cargo check does not spend resources on.

Where are the LLVM calls coming from? I have some theories.

  1. We are using a query/function that triggers codegen.
  2. Clippy does not actually deactivate codegen (weird)
  3. #![feature(rustc_private)] for importing rustc_hir and such automatically imports LLVM and performs some internal LLVM function.

callgrind output showing a lot of calls to libLLVM.so.20.1-rust-1.87.0-nightly, notably llvm::Option::addArgument

Some time ago I talked about why does Clippy have so many relocations, and how it could be caused by the dynamic linking. Since then I've had a chat with someone that mentioned that LLVM compilation suffers from a lot of relocations, and how that could be the reason.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by profiling Clippy with Valgrind/Callgrind and cargo lintcheck --perf, then compare the LLVM activity with cargo check. Trace whether the calls come from a query that triggers codegen, codegen not being disabled, or importing rustc_private components such as rustc_hir. Done means identifying the source of the LLVM symbols and documenting or implementing a remediation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, devtools, performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.