Repository navigation
rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters - #166492
train-dev-admin wants to merge 2 commits into
Conversation
…ted_parameters Skip checking functions with fewer than 2 parameters. Use a stack-allocated SmallVec instead of FxHashMap for small parameters lists Compare (Symbol, SyntaxContext) directly to avoid calling Ident::normalize_to_macro_rules()
|
Thanks for the pull request, and welcome! The Rust Project has assigned @wesleywiser (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? me |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters
| } | ||
|
|
||
| // 16 bytes per entry (Symbol: 4B, SyntaxContext: 4B, Span: 8B) -> 128B on stack | ||
| let mut seen: SmallVec<[(Symbol, SyntaxContext, Span); 8]> = SmallVec::new(); |
There was a problem hiding this comment.
This does have O(n^2) behaviour, but if you're running into that there are probably bigger problems
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (dccab3d): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @bors rollup=iffy rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.0%, secondary 2.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 462.461s -> 470.678s (1.78%) |
|
Nice, this doesn't recover the whole regression, but it's positive. |
| (name == ident.name && prev_ctxt == ctxt).then_some(span) | ||
| }) { |
There was a problem hiding this comment.
If you want try improving this a bit more, I'd try to specialize it even more against the emit path - the lint almost never fires, and ctxt is almost always the same for a single function definition:
e.g. avoid normalize_to_macro_rules call on the main path, only store Symbol in the vec and compare only those during normal path, and when there's a match, lookup the ctxt and span back in the params again to confirm the ctxt and emit the lint.
There was a problem hiding this comment.
@panstromek I hope I understand correct and new commit is exact what we need here.
There was a problem hiding this comment.
yes, let's try it out ;)
…ol-only fast duplicate check
|
There's a lot of things in the queue, we only need check results, so let's do that @bors try @rust-timer queue profiles=Check |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (52239fa): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 462.136s -> 463.156s (0.22%) |
|
This looks better, but only marginally, it might even be the same. I think this is ok like this. @JonathanBrouwer Do you have some opinions? Feel free to |
Fixes #166410
Slowdown came from the lint in #165366 and showed up on
externsandlibcSkip checking functions with fewer than 2 parameters.
Use a stack-allocated
SmallVecinstead ofFxHashMapfor small parameters lists.Compare
(Symbol, SyntaxContext)directly to avoid callingIdent::normalize_to_macro_rules()The warnings are unchanged, I ran tests/ui/lint/duplicate-parameter-names.rs,
but looks like we need to do perf again: time regression on
externsandlibcshould be less.