Skip to content

Call features_query fewer times in smart_resolve_macro_path#155155

Draft
fmease wants to merge 1 commit intorust-lang:mainfrom
fmease:diag-attr-perf
Draft

Call features_query fewer times in smart_resolve_macro_path#155155
fmease wants to merge 1 commit intorust-lang:mainfrom
fmease:diag-attr-perf

Conversation

@fmease
Copy link
Copy Markdown
Member

@fmease fmease commented Apr 11, 2026

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 11, 2026
@fmease
Copy link
Copy Markdown
Member Author

fmease commented Apr 11, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Apr 11, 2026
Call `features_query` fewer times in `smart_resolve_macro_path`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 11, 2026
.collect::<Vec<_>>();
let typo = find_best_match_for_name(&candidates, attribute.ident.name, Some(5))
let stable_diagnostic_attributes: Vec<_> =
[sym::on_unimplemented, sym::do_not_recommend, sym::on_move]
Copy link
Copy Markdown
Member Author

@fmease fmease Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

(preexisting) on_move "stable"? That's news to me. Should probably be gated as well. Or is it gated elsewhere?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember that attribute being gated, so it's gate is probably elsewhere

Copy link
Copy Markdown
Contributor

@mejrs mejrs Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmease the gates are in attribute parsing, all three unstable diagnostic attrs have a check like

if !cx.features().diagnostic_on_unknown() {
return;
}

The checks in rustc_resolve here are just for typo suggestions. but on_move was merged in between the creation and merge of #152901, that's probably why it's accidentally there.

Copy link
Copy Markdown
Member Author

@fmease fmease Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks, I see, obvious in hindsight

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give on_move the same feature check as on_const/on_unknown below? Thanks!

(sym::on_unknown, self.tcx.features().diagnostic_on_unknown()),
];

if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)
Copy link
Copy Markdown
Member Author

@fmease fmease Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

(preexisting) Kinda odd that we perform this check here instead of over in rustc_attr_parsing. Of course, this check has existed long before rustc_attr_parsing was introduced but now we should have better infrastructure in place.

Note that I'm not super familiar with the "low-level entry point" of the new attribute parsing infrastructure, so I don't know if there's a good reason why this check happens here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I still have plans to move feature gating to the new attribute parsing Infrastructure, but that is nicer to do after the lint attributes are ported again

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 11, 2026

☀️ Try build successful (CI)
Build commit: bbece70 (bbece7035e94319094008a1fedee27ce316f74d3, parent: 5f36a7f8072e835d73d9e1f7ab8a2134ac7352dc)

@rust-timer

This comment has been minimized.

.collect::<Vec<_>>();
let typo = find_best_match_for_name(&candidates, attribute.ident.name, Some(5))
let stable_diagnostic_attributes: Vec<_> =
[sym::on_unimplemented, sym::do_not_recommend, sym::on_move]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give on_move the same feature check as on_const/on_unknown below? Thanks!

let typo = find_best_match_for_name(
&stable_diagnostic_attributes,
attribute.ident.name,
Some(5),
Copy link
Copy Markdown
Contributor

@mejrs mejrs Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View changes since the review

I just realized that on_move and on_const are really similar to each other (their edit distance is 4), so this should probably be

Suggested change
Some(5),
None,

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (bbece70): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (secondary -1.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.6% [-1.6%, -1.6%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary 3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.0% [3.0%, 3.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 6
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.0%] 6

Bootstrap: 491.284s -> 489.863s (-0.29%)
Artifact size: 394.15 MiB -> 394.15 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 11, 2026
@fmease
Copy link
Copy Markdown
Member Author

fmease commented Apr 11, 2026

Hmm, too bad.

@mejrs
Copy link
Copy Markdown
Contributor

mejrs commented Apr 11, 2026

ImportData went from 216 to 352 bytes, could that be it? I have a PR that boxes it, #155167

@fmease
Copy link
Copy Markdown
Member Author

fmease commented Apr 11, 2026

I guess I'll repurpose this PR as a ~cleanup one ^^ once I've applied mejrs's suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants