-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Renaming private declarations takes 40+ seconds #57031
Comments
Summary: Renaming a private method in a Dart file with no parts takes over 40 seconds, significantly slowing down refactoring. The issue is caused by the creation of an index for future renamings, which is currently done synchronously. The user suggests creating the index in the background to avoid impacting user workflow. |
Just suggesting this because in my case I could've simply used find/replace and that would have been way faster. And people who experience this kind of long waiting might use this instead because of this even though there may be some downsides like needing to take a look at Strings and similar things for correct handling of it. |
@scheglov for verification
I think we already do. Last I looked at it, the index is created (and updated) every time we analyze a library cycle, which means that after the initial analysis of everything that's in the workspace we should have everything we need. |
Yes, we compute index when we resolve a Dart file. We do search across all libraries of a Pub package, including dependencies. So, we need to index all of them. Even if rename never updates dependencies, the search engine, and the index are used for both search and rename. Because rename is search essentially. So, when you do search or rename the first time, we discover and index all dependencies. |
Probably. Yes, we did not have need to break this down into smaller performance operations. |
@FMorschel can you reliably reproduce this? I just tried to repro to see if I could get some approx timings with the CPU profiler to confirm the time is where we think (I wondered if some work could be skipped when we know we're only searching for privates?), so I tried:
It wasn't fast, but it was only 2-3s which is very different to what you see. That doesn't feel like the kind of difference that differences between our hardware so I think I might not be reproducing the same thing. |
I can. I'm unsure about the real waiting time, but last night, I was working on an assist and renamed the test class (it is just used locally, but it is public), which also took a long time. I'm unsure of what I can do to help identify the problem here. If you have any ideas I'm open to them. |
@FMorschel sorry I should've been clearer what I was asking... Can you describe the precise steps so I can see if I can repro in the same way here? Can you also confirm the SDK version you're using for analysis (eg. the one VS Code is selecting... probably your value from |
Dart 3.7.0-edge.3a895e28b44aacd08bd9055f05c16f14078eb067 (main) (Wed Nov 6 10:23:38 2024 +0000) on "windows_x64"
The snapshot =D
About 20s in, I do see that the IDE shows "Analyzing..." on the status bar so some time for that can be reanalyzing files but still. If you now undo this and rename I don't get more than 85ms to rename the same class or If I leave the project open for some time and try to rename it again, it can take ~3s as you mentioned so that is consistent. |
Also, if you think that solving for private declarations is easier you can take a look at |
While working at https://dart-review.googlesource.com/c/sdk/+/392860 for #49294, I was refactoring and needed to rename a private method for
AddConst
.The method was used only once and since it is a file with no parts the analysis and renaming for this should be really fast.
After talking with @DanTup on Discord he mentioned that this is actually caused by the creation of an index that for future renamings would decrease the waiting time.
I was wondering if we could ever do some form of work to help users with this long waiting time for renaming simple things. I have two suggestions which basically overlap:
The text was updated successfully, but these errors were encountered: