Skip to content
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

Don't suggest names for errors in normal IDE usage #6063

Merged
merged 9 commits into from
Feb 5, 2019
Merged

Don't suggest names for errors in normal IDE usage #6063

merged 9 commits into from
Feb 5, 2019

Conversation

cartermp
Copy link
Contributor

@cartermp cartermp commented Jan 5, 2019

Fixes #6044

This turns off name suggestion for errors in the IDE except for Build, instead using Completion as a source of names for suggesting errors in a Roslyn code fix.

The following will still generate suggestions on build errors:

  • fsc.exe
  • fsi.exe
  • Build within VS
  • FSI within VS
  • dotnet build

However, names will not be continuously generated when editing code in the IDE and triggering this logic due to having typed an unresolved identifier. This should resolve the current (as of latest dev16.0 branch) biggest source of CPU and memory usage in normal IDE usage for larger solutions.

@cartermp

This comment has been minimized.

src/fsharp/service/service.fsi Outdated Show resolved Hide resolved
src/fsharp/service/service.fsi Outdated Show resolved Hide resolved
@forki
Copy link
Contributor

forki commented Jan 7, 2019

I don' really think disabling it is the way to go.
Did you check #6049 ?

@cartermp
Copy link
Contributor Author

cartermp commented Jan 7, 2019

I captured my thoughts on that PR but I'll restate the important bit here:

Fundamentally, this feature is simply not built with IDE tooling in mind. It's great for a batch compile job/command line builds, but for a long-running process like a language server it's simply calculating and re-calculating too many things. The feature needs two "modes":

  • The current one for batch compile jobs
  • An out-of-process spellchecker routine that uses a tree (such as Roslyn's which uses a BKTree) to traverse a populated set of symbols independently of the in-proc work

The latter is not something that FCS can do yet. We're going to pursue this sort of architecture in the future, but not right now.

Disabling this by default while we are still in the VS process for this sort of work is the right thing to do.

@forki
Copy link
Contributor

forki commented Jan 7, 2019 via email

@cartermp
Copy link
Contributor Author

cartermp commented Jan 7, 2019

That's a false equivalence.

@vasily-kirichenko
Copy link
Contributor

Excellent, but I think fsc.exe should not generate suggestions by default either. It should be a pure-IDE, optional feature.

@majocha
Copy link
Contributor

majocha commented Jan 8, 2019

Yes, this looks like the proper way to deal with it.
The code that computes suggestions should be called by the FSharpReplaceWithSuggestionCodeFixProvider instead.

This way the impact should be so low that I don't see the need to disable this feature at all.

@cartermp
Copy link
Contributor Author

cartermp commented Jan 9, 2019

It'll be heinous to decouple the logic that generates candidates:

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L1831-L1838

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L1845-L1851

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2209-L2248

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2354-L2392

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2478-L2514

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2577-L2606

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2681-L2696

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2800-L2805

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2821-L2826

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2844-L2852

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2873-L2878

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2885-L2890

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L2920-L2933

https://github.com/Microsoft/visualfsharp/blob/a7acf9f4198550f697945ba36c8321e96541eeab/src/fsharp/NameResolution.fs#L3055-L3104

I'm not particularly keen on doing that but I suppose it's possible. Lots and lots of plumbing values to/from NameResolution if we want the code fix to be able to get the same fidelity of results.

A different way could be picked, but something basic like checking matches against all symbols is going to be expensive (I've tested it and it is SLOW), and may not give the same results. If that were crippled to just be within the current document it wouldn't be bad, but then the feature would be inconsistent with using the IDE build.

I'm also not in favor of ripping out this feature for fsc/normal build. It's a valuable feature that I wouldn't be pressing on if it weren't affecting CPU and memory so much in the IDE.

@dsyme
Copy link
Contributor

dsyme commented Jan 9, 2019

I've noticed this feature to be useful in the IDE. But I've also noticed the computation to be oddly expensive.

@cartermp cartermp changed the title [WIP] Don't suggest names for errors in normal IDE usage Don't suggest names for errors in normal IDE usage Jan 11, 2019
@forki
Copy link
Contributor

forki commented Jan 11, 2019

Even if I disagree with disabling this feature by default: I want to thank you folks for working so hard on perf. I think the community really appreciates that kudos! Also big thanks to @davkean for profiling work.

@cartermp
Copy link
Contributor Author

@forki Thanks 🙂 - I've actually now changed the code fix to be on by default, but I'd like to play with it a bit more to see what the impact is. This means the code is run differently, so it could mean that the algorithm isn't triggered as much.

@cartermp
Copy link
Contributor Author

As of the current state of this PR (code fix on by default), the allocations in #6044 are practically gone:

image

And CPU usage doesn't even register. So I think this PR solves the problem. However, suggestions are generated differently than with Build. It is equivalent to invoking completion. Is that considered fine?

@forki
Copy link
Contributor

forki commented Jan 12, 2019

Cool. So ctrl+shift b would still trigger it? How about saving a file?

@cartermp
Copy link
Contributor Author

@forki So unfortunately due to #6036 you won't see ctrl+B unless you toggle "Build Only":

image

We really need to fix that bug for reasons beyond this, but when it is fixed you should probably see both in the error list.

Saving a file does not show it, nor is it in the QuickInfo tooltip (we don't control that, unfortunately). But the fixer icon is in the tooltip area:

image
image

And of course ctrl+. will trigger it as well.

@cartermp
Copy link
Contributor Author

@TIHan @KevinRansom this is ready

@cartermp cartermp mentioned this pull request Feb 4, 2019
6 tasks
Copy link
Contributor

@TIHan TIHan left a comment

Choose a reason for hiding this comment

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

Looks great. Not a fan of booleans as arguments, but we can clean that stuff up later. This is worth having to get rid of allocations.

@KevinRansom KevinRansom closed this Feb 5, 2019
@KevinRansom KevinRansom reopened this Feb 5, 2019
@cartermp cartermp merged commit da89b7f into dotnet:dev16.0 Feb 5, 2019
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
* Don't suggest names for errors in normal IDE usage

* Remove flag from parsing and project opens

* Move flag into FSharpChecker

* Suggest names based on symbols in the current document

* Cleanup and turn on code fix by default

* Use declarationlistinfo as a source for suggesting names

* Reduce diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants