Skip to content

significant_drop_tightening is very slow #10532

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

Closed
Noratrieb opened this issue Mar 22, 2023 · 2 comments · Fixed by #10533
Closed

significant_drop_tightening is very slow #10532

Noratrieb opened this issue Mar 22, 2023 · 2 comments · Fixed by #10533
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@Noratrieb
Copy link
Member

Noratrieb commented Mar 22, 2023

Description

significant_drop_tightening is very slow. I tried running clippy with -Aclippy::all -Wclippy::perf on rustc_borrowck. (note that it seemed very slow on the entire compiler, so I don't think there's anything specific to borrowck, it's just very big.

According to a profile, it spends about 66% of time inside has_sig_drop_attr:

pub(crate) fn has_sig_drop_attr(&mut self, ty: Ty<'tcx>) -> bool {

More precisely, it seems to spend the time getting the type of fields.

let ty = f.ty(self.cx.tcx, b);

Inside this function it substitutes the type of the field with the substs (generic parameters) of the type. This folds the type and is a little work. This lint does that little work on everything, turning it into a lot of work. It also does so eagerly recursively which is just a receipe for slowness.

I've got a simple fix, I'll send in a PR.

Version

current master, e64c5961dc7640b4d5529608e0f321d586c027a0, 1.70.0

Additional Labels

@rustbot label +C-bug

@rustbot rustbot added the C-bug Category: Clippy is not doing the correct thing label Mar 22, 2023
@Noratrieb
Copy link
Member Author

Noratrieb commented Mar 22, 2023

flamegraph
Here's the beautiful flamegraph I made while investigating this more :)
(you may need to open the link)

@Noratrieb
Copy link
Member Author

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants