Skip to content

[PERF] Optimize 3rd heaviest func, (81b -> 10m) #15043

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

Merged

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
Contributor

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 performance-project 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
performance-project 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