Skip to content

Conversation

blyxyas
Copy link
Member

@blyxyas blyxyas commented Jun 13, 2025

So this is funny, the query tcx.module_children was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
clippy::strlen_on_c_strings was calling for get_def_path via
match_libc_symbol. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from libc.
I don't really trust callgrind when it says I've turn 81 billion instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20 times
without incr" method and it went from 0.31s-0.45s to 0.25s constistently.

(Profiled, and "benchmarked") on tokio.

What I can get behind is via strlen_on_c_strings changing from 31 million instructions into 76k. 🎉 🥳

changelog: [strlen_on_c_strings]: Optimize it by 99.75%

So this is funny, the query `tcx.module_children` was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
`clippy::strlen_on_c_strings` was calling for `get_def_path` via
`match_libc_symbol`. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from `libc`.
I don't really trust callgrind when it says I've turn 81 billion instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20 times
without incr" method and it went from 0.31s-0.45s to 0.25s constistently.

(Profiled, and "benchmarked") on tokio.
@rustbot
Copy link
Collaborator

rustbot commented Jun 13, 2025

r? @y21

rustbot has assigned @y21.
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 Jun 13, 2025
@samueltardieu
Copy link
Member

Nice!

@samueltardieu samueltardieu added this pull request to the merge queue Jun 13, 2025
Merged via the queue into rust-lang:master with commit 6662aed Jun 13, 2025
11 checks passed
@blyxyas blyxyas added the G-performance-project Goal: For issues and PRs related to the Clippy Performance Project label Jun 13, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 22, 2025
…ange, r=compiler-errors

Add a warning to LateContext::get_def_path

Preventing anyone from doing the same error as rust-lang/rust-clippy#15043 fixed
rust-timer added a commit to rust-lang/rust that referenced this pull request Jun 22, 2025
Rollup merge of #142593 - blyxyas:improve-docs-itty-bitty-change, r=compiler-errors

Add a warning to LateContext::get_def_path

Preventing anyone from doing the same error as rust-lang/rust-clippy#15043 fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
G-performance-project Goal: For issues and PRs related to the Clippy Performance Project 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.

4 participants