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

How to disable live code compilation/analysis in Visual Studio 2017? #24513

Closed
LeonidVasilyev opened this issue Jan 29, 2018 · 82 comments
Closed
Assignees
Labels
Area-IDE Feature Request Need More Info The issue needs more information to proceed.
Milestone

Comments

@LeonidVasilyev
Copy link

LeonidVasilyev commented Jan 29, 2018

Version Used: 2.6.0.6232903
Visual Studio 2017 marks Bar() with red squiggle before project is built:
squiggle
Is it possible to alter this behavior to show errors only after manually triggered build?

In Error List I see that the error message is produced by IntelliSense. I tried to disable full solution analysis in Text Editor options, set HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Roslyn\Internal\OnOff\Features\Squiggles registry to 0, alter analyzer Active Rule Set.

For more information see Disable 'Show live semantic errors' for C# in Visual Studio 2017 and How to disable real time compilation in Visual Studio 2015 discussions on Stack Overflow.

@sharwell
Copy link
Member

sharwell commented Jan 29, 2018

💭 This may be a case where the feature was so infrequently used that it became prone to higher rates of regression bugs between releases (lack of use meant bugs in the behavior were not detected).

/cc @kuhlenh

@jmarolf
Copy link
Contributor

jmarolf commented Jan 29, 2018

Disabling full solution analysis does not disable analysis in the current file. In between VS 2013 and VS 2015 we removed the option to disable design-time analysis. Sounds like this is a request to bring that feature back.

@LeonidVasilyev
Copy link
Author

I do not find syntax error squiggles that distracting because most of the time I pay attention to them only after I finish writing particular code snippet. But I can see where Stack Overflow OP is coming from. For experienced developer live error squiggles may look like false positives.

Is it correct that you can't disable design-time analysis using registry key? Can you do that using Language Service and Editor Extensions?

@jmarolf
Copy link
Contributor

jmarolf commented Jan 30, 2018

Is it correct that you can't disable design-time analysis using registry key? Can you do that using Language Service and Editor Extensions?

There is no way to disable analysis today.

@sharwell
Copy link
Member

sharwell commented Feb 2, 2018

🔗 I marked Bc42024 Visual Basic and VB.NET unused local variable as a duplicate of this issue.

@jinujoseph jinujoseph added this to the Unknown milestone Feb 16, 2018
@d4e666

This comment has been minimized.

@CyrusNajmabadi
Copy link
Member

@d4e666 Would you be willing to collect some perf traces to help get to the bottom of any slowdowns you're seeing? Thanks!

@jmarolf
Copy link
Contributor

jmarolf commented Oct 17, 2018

As long as this does not interfere wothbmy active development sure

here is the guidance for getting a perf trace.

there are a lot of features I do not use

Under Tools -> Options you can disable CodeLens

image

Not a complete solution but hopefully it can get rid of some of the clutter for you.

@CyrusNajmabadi
Copy link
Member

@d4e666 Here are the instructions on collecting and reporting perf issues: https://github.com/dotnet/roslyn/wiki/Reporting-Visual-Studio-crashes-and-performance-issues

This would be very helpful in terms of determining what is the root cause of the problem. Thanks!

and many "live detection" features like test code detection

'test code detection' can be disabled here:

image

and find thztvthis

Sorry... this is garbled. I don't know what this is referring to.

I don't like to pay for the 1 feature I do use whilst there are 10 I never use.

In general, the features which are costly can be disabled. If performance tracing reveals something that is an issue, but can't be disabled, we can add options for it. But without tracing, there's no way to know what the root cause is. For example, you mentioned you didn't like experiences pauses. However, there is no way to know (without a trace) what is causing that pause. It may be something in Roslyn. It may be something in Resharper. It may be something in some other extension you're using. If any of those end up using the UI thread in an inappropriate manner, you may experience pauses. We'll need the tracing data to know what's up.

Thanks!

@jaredpar
Copy link
Member

@d4e666 your comment was hidden as it violates our code of conduct. Please keep future contributions in line with the COC or we may have to consider banning your account from this organization.

@CyrusNajmabadi
Copy link
Member

@d4e666 Here are the instructions on collecting and reporting perf issues: https://github.com/dotnet/roslyn/wiki/Reporting-Visual-Studio-crashes-and-performance-issues

This would be very helpful in terms of determining what is the root cause of the problem. Thanks!

@terrajobst
Copy link
Member

@d4e666

Since you ignored the warning I've blocked your account. We all have passion and want to see the right thing happen, but insulting and yelling at us isn't a productive mode of discourse. If you have any concerns, please contact conduct@dotnetfoundation.org.

@yotamoron
Copy link

Hi,

I'm running Visual Studio 2017 on a 32GB/i7/win10 machine.

Words cannot describe the slowness and frustration.

On each and every code change, it hangs. I see that the live code analysis is running in the background.

Is there a way to disable the live code analysis?

@jmarolf
Copy link
Contributor

jmarolf commented Jan 2, 2019

@yotamoron

here are some ways to disable features but there is no way to disable live code analysis.

I would really appreciate it if you could report a trace by following the directions here.

@MarcelChirtes
Copy link

MarcelChirtes commented Jan 23, 2019

Everything is off, beside the code analysis on build, but code analysis run in background when open/edit/save file (.cs) some times runs on a single file other times on all opened files.

Before, I had same setup on same machine Win10 64 + VS 2017 no problem, after reinstalling windows this issue appeared.

@MarcelChirtes
Copy link

MarcelChirtes commented Jan 23, 2019

Found a workaround, Code Analysis still runs at any action on opened file but editor is quite faster.

Tools -> Options -> Text Editor -> C# (in my case) -> Advanced -> Perform editor feature analysis in external process (experimental)
Explained here: #26076

Another place that can cause slow code analysis might be included analyses from nuget packages.
image

I removed those AWSSDK analyzers.

@effyteva
Copy link

Hi,
Is there perhaps an update on this issue?
Disabling the Live Analyzers seems to be pretty basic feature which is currently missing.

@twest820
Copy link

twest820 commented Jun 25, 2019

I'd appreciate an update as well. There's a number of questions about how to opt out of live code analysis on Stackoverflow and some frustration that it's not supported. On Google, the top searches triggered by typing "Visual Studio live code analysis" are

  • visual studio live code analysis slow
  • visual studio live code analysis hangs
  • visual studio live code analysis disable
  • visual studio 2017 live code analysis slow
  • visual studio 2019 live code analysis slow

On Bing, the corresponding top searches are

  • visual studio live code analysis slow
  • visual studio disable live code analysis
  • visual studio 2019 live code analysis slow
  • stop live code analysis visual studio

I've had various exchanges with the Visual Studio team on a number of incarnations of this issue since 2006. While live analysis performance on VS 2017 was acceptable on the solutions I work with I'm finding it intrusive with the VS 2019 nugets, to the point where it interferes with fundamental operations like scrolling. There also seem to be problems with either thread leaks or infinite loops which require Visual Studio restarts to recover from in 16.1.3. These are particularly tedious as having the CPU pinned at 100% predictably makes VS slow to exit.

I like live code analysis and find it quite useful but, during its episodes of poor behavior, it's not a feature which adds value. As such it seems appropriate to offer some form of opt out. While Code Analysis is being deprecated, something I think it gets right is its ability to run the ruleset on demand and get out of the way the rest of the time. It seems like this is currently semi-supported in that one can make a .ruleset file with few or no analyzers, switch projects to reduced .rulesets to duck some of the compute cost, and switch the projects back later. This is awkward and doesn't appear to be getting discovered by users. It also has the less than ideal result of opting out of warning level issues while retaining the overhead for information level issues like changing "out Foo ignored" to "out Foo _". It'd be valuable to have a design which preferentially allowed opting out of live informationals but still caught the more significant coding time concerns (e.g. missing Dispose() calls and CurrentCulture/InvariantCulture risks).

VS has had a model somewhat like this for CodeLens for some time. Personally, I opt out of CodeLens completely as it's too much of a drag on UX responsiveness but use find all references as a pay as you need it alternative regularly. I wouldn't really want to do this with live analysis but it'd be great if there was a way quickly move an entire solution between live analyses levels to manage background compute costs.

@bernesto
Copy link

bernesto commented Sep 1, 2019

There seems to be a lot of pain around this feature online doing a simple search.

Is it really difficult to just add a flag to just disable code analysis until roslyn is a bit more performant for those of us who wish to do so? For me, it kills my productivity with missed keystrokes and an unresponsive UI. A simple reg entry to turn it off would be appreciated!

@lauxjpn
Copy link

lauxjpn commented Sep 7, 2019

Especially for the folks that use R# for productivity, Roslyn has a huge impact on general performance in VS. There are moments, where VS just hangs, mouse clicks take a second or two to get recognized, typing lags etc. (that's with Windows Defender already disabled). And it gets worse with every major version change.

I understand, that Roslyn is a needed feature for general VS users, but for Resharper users, Roslyn's analysis is just a nuisance, kills your productivity and brings nothing new to the table that Resharper doesn't at least provide as well.

Obviously, the VS team is well aware of the performance problems, because they implemented this nice little yellow info bar, that tells you every couple of seconds, that Resharper is to blame. The truth is though, that VS and Resharper worked fluently together until Roslyn came along.
That Roslyn and Resharper are now competing for resources is obvious and it should be left to the user, which refactoring platform to use.

So until Roslyn can fully replace Resharper, the option to disabling as much of Roslyn's analysis as possible, is a highly needed feature.

Is this on the agenda of the team, or can the pros and cons or possibilities be discussed here @CyrusNajmabadi @sharwell ?

@sharwell
Copy link
Member

sharwell commented Sep 7, 2019

@lauxjpn We work hard to fix all cases that get reported with traces that we can investigate. You can find the instructions here: https://aka.ms/reportPerf. Unfortunately, the number of different user configurations is almost unimaginatively gigantic, so there is no realistic way for us to confidently address your specific scenario without the additional information. Each release tends to behave like this:

  1. Most people get performance that is slightly better
  2. A few people get performance that is worse (there are always new cases we didn't account for)
  3. A few people get performance that is much better

Most people who move from the first category to the third category do so because they were able to capture the scenario in a way that allowed us to focus our investigation on it.

@sharwell
Copy link
Member

sharwell commented Sep 7, 2019

This issue is likely to be addressed as part of #38429.

@ant-222
Copy link

ant-222 commented Oct 3, 2019

I for one need to disable live code analysis not because it is slow (which it is) but rather because it is so annoying when VS complains about a missing return statement before I have finished typing the function. It makes me miss good old VS 2008 that checked my code when I told it to.

@CyrusNajmabadi
Copy link
Member

It makes me miss good old VS 2008 that checked my code when I told it to.

vs2008 certainly checked many things in a live fashion. It didn't check more primarily due to limitations in the implementation which made narrow and incremental checking hard. But it would give live errors for all sorts of things :)

That said, i have no problem with an option to disable live editor squiggles. Either as a specific option, or as part of a larger "lightweight editing" mode. Tagging @mavasani for context as he's been looking into this.

@mavasani
Copy link
Contributor

mavasani commented Oct 3, 2019

Yes, we are actively planning for some top level option(s) or a more fine grained knob with multiple settings which would allow users to customize their preferred mode of operation and background analysis.

@CyrusNajmabadi
Copy link
Member

@mavasani Thanks!

@mavasani mavasani self-assigned this Oct 31, 2019
@mavasani mavasani removed this from the Backlog milestone Oct 31, 2019
@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Apr 24, 2021

If you decide to make bigger changes to .editorconfig may I suggest using TOML for the config file format, and making full use of arrays, tables, and other advanced features it supports?

I think it's important that we not try to do anything outside the norm or documentation of the format here: https://editorconfig.org/#file-format-details

If the community around editorconfig adopts and supports these, then i'd have no problem with us doing the same. However, until then, I would prefer to stick with what is simple and effective and easily tooled across the ecosystem.

@levicki
Copy link

levicki commented Apr 24, 2021

This ID isn't internal. It's reported in every UI we give for an issue.

I think you are reading what I write too literally.

When I said internal ID, I didn't mean hidden -- I meant what analyzer is using internally.

When you're editing the config file, the UI will provide nice human readable explanations and examples for each ID.

Are you allowed to say in which version will this UI be released?

.editorconfig is already supported industry-wide. Inventing something new to take the place of something that exists and works is just not something i think is a good idea.

I guess file format itself is good enough, I just wish that the syntax for diagnostics message configuration was the same as the one for the editor formatting configuration.

I don't think we should reinvent a mechanism for configuring this sort of thing when it's precisely the domain that this format was intended to solve.

Me neither, I was just pointing out that IDE0060 = none in a config file is not much more descriptive than storing 3c 00 followed by 00 in a binary file :-)

If the community around editorconfig adopts and supports these...

Somehow I don't think that will happen soon. They seem to be happy with INI file format.

@CyrusNajmabadi
Copy link
Member

Are you allowed to say in which version will this UI be released?

It should be in whatever the very next release of roslyn is. It's possibly already been released in preview form. @jmarolf do you know?

I meant what analyzer is using internally.

Sure. but the benefit of this is that there's no guess work. You just take whatever ID we're showing you anywhere, and you use that. I do agree that there should be something in the editorconfig to help make the ID understandable. Sam outlined an approach that i think would work well.

They seem to be happy with INI file format.

Then i would prefer to stick with that. I don't want us going and breaking with convention :)

@jmarolf
Copy link
Contributor

jmarolf commented Apr 26, 2021

Are you allowed to say in which version will this UI be released?

It should be in whatever the very next release of roslyn is. It's possibly already been released in preview form. @jmarolf do you know?

This is currently available in Visual Studio 16.10 Preview 2

@levicki
Copy link

levicki commented Apr 27, 2021

This is currently available in Visual Studio 16.10 Preview 2

Good to know, given that release channels is on 16.9.4, I believe 16.10 is not that far away.

@simeyla
Copy link

simeyla commented May 13, 2021

Regarding the Live Code Analyzers options in a project property page:

@drvic10k Can you file a new issue for the behavior you are seeing? The features described above are widely available now so it's highly likely the behavior you encountered is a similar symptom but unrelated cause.

I think the confusion is that this option is not available for .NET Framework projects. And legacy .NET Framework projects are likely to be larger and more prone to performance issues that would cause someone to need this option in the first place :-)

The property page in Visual Studio really ought to include a note on how to disable Live Code Analyzers for .NET projects. It could just link here: https://docs.microsoft.com/en-us/visualstudio/code-quality/disable-code-analysis?view=vs-2019#net-framework-projects

It was very confusing and in fact I installed a whole different preview version of VS to try to get it working!

@AntonGrekov
Copy link

AntonGrekov commented Jun 28, 2022

How happy i was using AMD Ryzen 7 5800x with 32gb of RAM quad-threaded along with Samsung EVO 970+ SSD on my home PC with 3 Chrome windows opened(30-50+ tabs each), with Ubuntu running VirtualBox, 5 messangers, IntellIj IDE running with zero latency or lagging

Until i get to know what is Roslyn Code Analysis is in Visual Studio.... That one program while everything other is shut down kills my PC completly in a way that i even get black screen blinking while video driver crashes to respond or something

That is worst experience i ever get by running a program. I read about advantages that this cool-great-feauture gives and i dont want ANY of it, no matter how great they are.

Can pls someone tell how to remove this thing out of my PC forever ?!?! PLEASSEEEEEEEEE
It loads CPU to 97-99% for more than 4 hours !!! And simply doesn't stop on a small project

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Jun 28, 2022

while video driver crashes to respond or something

@AntonGrekov our server does absolutely nothing with the video subsystem. If you are having crashes there it is an issue with your hardware.

It loads CPUE to 97-99% for more than 4 hours !!! And simply doesn't stop on a small project

Please report an issue using visual studio and have it include a trace. We can see what has gone wrong. You can use the instructions here: https://docs.microsoft.com/en-us/visualstudio/ide/how-to-increase-chances-of-performance-issue-being-fixed?view=vs-2019#slowness-and-high-cpu-issues

@AntonGrekov
Copy link

AntonGrekov commented Jul 9, 2022

@CyrusNajmabadi This thing is drains absolutly all my RAM memory. Due to this video driver crashes, because of memory lack. Today i even wasnt unable to open WIndows Task Mgr - it errored due memory lacking. All that just after Roslyn Code Ananlysis started to work with my project - i didn't even build or debug project, just opened project that was opened 10-20 times before and didnt had any changes at all......

I hardly made a screenshot because if i would try to make a screenshot 1-2 minute later ScreenShot software would also crash because of a memory lack due Rosly Code Memory RAM killer drainer software.

I tried reinstalling VisualStudio but that not seems to be an issue, the main problem is huge memory leak by Roslyn Code Analysis
2022-07-09 10_57_26-Диспетчер задач

How to fix it ? You can see at screenshot it drains 17 GB !!! of RAM and its just a beggining, in 10-20 secs later it drains 22 GB and then goes to max 24 GB limit (Just no more RAM in my PC, it could go even to 50 GB)

@AntonGrekov
Copy link

AntonGrekov commented Jul 9, 2022

image
25 Gigs Of Memory and counting ....

@CyrusNajmabadi
Copy link
Member

@AntonGrekov please see the comments in #24513 (comment)

This process is container where many components from many teams run in. We will need a reported trace to determine what the issue is here and which team will need to investigate.

@CyrusNajmabadi
Copy link
Member

How to fix it ?

@AntonGrekov there is a link provided to get the appropriate diagnostic information and traces so that the appropriate team can fix it. Please follow the instructions there. Thanks.

@AntonGrekov
Copy link

I've reported a problem with wide detailed data range to microsoft team via Report a problem tool
Meanwhile i installed brand new Windows 10 with latests updates from official Microsoft website to a new partition of my ssd drive, installed hardware drivers and just latests visual studio - just the same result, at first and later launches 23-25 gigs of RAM drained and counting........ waiting on issue resolving, meantime switch to Rider, impossible to work

@CyrusNajmabadi
Copy link
Member

@AntonGrekov can you link me to your report?

@AntonGrekov
Copy link

AntonGrekov commented Jul 12, 2022

@CyrusNajmabadi sure, https://developercommunity.visualstudio.com/t/RoslynCodeAnalysisServiceexe-drains-UPT/10091268
i still fighting this... i've tried already so many different solutions from stackoverflow or other sources - no help...
disabled code analysis for all projects, disabled code analysis in studio settings, tried different analyzer versions, and around 10 other solutions....

even if all code analys is switched off and even if Roslyn Analyzer package is not installed via nugget it still kicks in for 25-27GB until it breaks whole OS. Fresh new Windows install just exact same behaviour

I found one way to counter this: if visual studio is started on some project file(not any source code file) RAM usage may grow at max to 10 GB or even stay at 2-5GB. After around 3-5 mins it drops to 1.5 GB and now i can open sources and work normally

If project is opened with any source file at start - RoslyCodeAnalysisService kicks in and drammatically grows in RAM usage to 14GB in around 30 secs, and keep growing until it errors itself or OS hang on.....

Also that happens only on my project, which i won't say big. It has a lot of migrations, and some logic. I can't upload that project since it is commercial one

Also, i am already thinking on buying 32 GB more, but that might not help, it could just take 57GB's and still crash

UPDATE: even with "working" method when you start working with sources it still drains 23-25 GB's and crashes....

@CyrusNajmabadi
Copy link
Member

i still fighting this... i've tried already so many different solutions from stackoverflow or other sources - no help...
disabled code analysis for all projects, disabled code analysis in studio settings, tried different analyzer versions, and around 10 other solutions....

As mentinoed, this is a generic component host. Your issue may have nothing to do with code analysis. That said, thanks for the link, i'll look at it immediately.

@CyrusNajmabadi
Copy link
Member

@AntonGrekov i don't see any perf traces included with your report. Did you follow the instructions linked previously (https://docs.microsoft.com/en-us/visualstudio/ide/how-to-increase-chances-of-performance-issue-being-fixed?view=vs-2019#slowness-and-high-cpu-issues)? Specifically, we need you to include the information related to "Provide a trace..."

@AntonGrekov
Copy link

@CyrusNajmabadi I dont quite remember but probably i did Report a problem, because i remember of many log files that were submitted while creating new issue. Anyway i followed suggested link and made a new recording, now for sure.

https://developercommunity.visualstudio.com/t/RoslynCodeAnalysisService-drains-upto-25/10093330

@CyrusNajmabadi
Copy link
Member

Looks like it's still uploading and processing the data. Can you ping me tomorrow on this and i can look?

@AntonGrekov
Copy link

AntonGrekov commented Jul 12, 2022

@CyrusNajmabadi Sure, tomorrow i need to work on project that requires me to use VS, so i won't forget.

Some more info: launching proejct with any file opened rather than sources seems to help as i mentioned above. open solution with initial project file(not source) - wait for 5-10 mins - ram rush seems to calm down and stops - now you can use VS

At some point ram taken freezes at 10-12 gb, sometimes 2-4 and after launching debug it resets to 1.4gb and stays there

@AntonGrekov
Copy link

@CyrusNajmabadi MS requrested record problem in first issue, did that as well

@CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi
Copy link
Member

Trace shows teh entirety of the time in:

image

Interestingly the memory allocation hit is here:

image

as a massive single outlier in the total memory allocated here:

image

This indicates one of a few possibilities here:

  1. You have a truly MASSIVE anonymous-type e.g. new { ..... OMGHUEG ... }.
  2. You have a truly MASSIVE number of anonymous-types. e.g. new { ... } ... new { ... } ... ad infinitum.
  3. The compiler has a bug where it's effectively getting into an infinite loop while parsing anonymous-types due to some construct it doesn't understand. This infinite loop is what is causing the huge spike in CPU and the massive memory allocations as we spin forever, making no progress, constantly allocating nodes for the body of that anonymous type.

'3' seems very likely, but i can't rule out '1' or '2'. Would you be willing to zip up all your sources and send them to me? I could then do a simple parsing analysis to see what is likely causing this.

In hte meantime. @333fred @jcouv do you know of any existing issues with parsing anonymous-types, or anything we have fixed in this area that could be causing '3'? Looking at the code, i can see we do have a loop that does while (IsMakingProgress(ref lastTokenPosition)). However, i personally am not familiar/comfortable with the parser's idioms for loop parsing while ensuring progress to know if this is written correctly. This will likely take further investigation from compiler team here.

@CyrusNajmabadi
Copy link
Member

@AntonGrekov I'm going to open a new issue on this and migrate this information there.

@CyrusNajmabadi
Copy link
Member

Issue opened as: #62603

@CyrusNajmabadi CyrusNajmabadi added the Need More Info The issue needs more information to proceed. label Jul 16, 2022
@CyrusNajmabadi
Copy link
Member

Marking as 'need more info'. We will need information from @AntonGrekov to make progress on this. See: #62603

@edaqa-uncountable
Copy link

This was closed based on the discussion of performance it seems, not based on the original issue: to disable live code analysis. There is no resolution for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request Need More Info The issue needs more information to proceed.
Projects
None yet
Development

No branches or pull requests