[PERF] Optimize 3rd heaviest func, (81b -> 10m) #15043
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So this is funny, the query
tcx.module_children
was top 3 in mosttime 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 forget_def_path
viamatch_libc_symbol
. This query pretty-prints things and performs someanalysis.
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%