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

DotNet 6 on Mac M1 - high CPU use and processes stuck #23267

Open
eighteentee opened this issue Dec 3, 2021 · 62 comments
Open

DotNet 6 on Mac M1 - high CPU use and processes stuck #23267

eighteentee opened this issue Dec 3, 2021 · 62 comments
Assignees
Labels
Area-MacOS untriaged Request triage from a team member

Comments

@eighteentee
Copy link

Description

I have just started coding with DotNet on my Mac as part of a CS degree course. I am experiencing a weird problem when running simple projects either in VS2022 (preview for Mac), Rider or VS Code. I first noticed that battery life was draining fast and checked the Activity Monitor - there were a number of DotNet processes all pegged at 100%. Basically if I run projects then these processes seem to run away and never quit even though a project is stopped in whatever IDE I am using - each time I must manually force quit the processes in Activity Monitor. It's getting to be really annoying now.

Configuration

I am running the latest release of DotNet 6.0 on MacOS 12.01 on a MacBook Pro Max M1 with 10 cores, 32 GPU cores, 32gb RAM and 1tb SSD. I am trying to work with simple Razor Pages apps.

@hvkhoi
Copy link

hvkhoi commented Dec 5, 2021

I have same problem

@hasanxdev
Copy link

I also have the problem that the arm version seems to be unable to stop the processes and also repeats them several times.
This is the usage of CPU processing after executing the command "dotnet run
"
image

@jun92
Copy link

jun92 commented Dec 13, 2021

same to me. any fix yet?

@eighteentee
Copy link
Author

No fix as yet. It's starting to become unusable on my machine. Hopefully MS see this and fix it soon. Can't even run VS2022 in a virtual machine as it is so slow!

Incidentally, VS2022, VS2019, VSCode (with C# DotNet extensions) and JetBrains Rider all exhibit the same problem and allow native DotNet 6 processes to accumulate and run away at 100% CPU use all the time. Having to constantly keep my eye on Activity Monitor just to close down these DotNet 6 processes is becoming tiresome and cumbersome. This is almost at the point where I'm going to have to buy a Windows machine just to work with DotNet 6 - bonkers when I have such a powerhouse of a laptop!

Is there any way of moving this up the priority list for fixing? Surely just cannot be a few people experiencing this same problem?

@brianamm
Copy link

brianamm commented Jan 4, 2022

This is not isolated to M1 Macs. I'm having the same problem on a 2016 i7 MBP. I haven't isolated the exact steps to reproduce yet. I'm using VSCode 1.63.2 and .NET 6.0.101. The runaway processes either need to be quit through Activity Monitor, or the laptop needs to be rebooted. They won't go away on their own even after VSCode, terminal, etc are closed.

@buyaa-n buyaa-n transferred this issue from dotnet/core Jan 5, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Jan 5, 2022
@baronfel
Copy link
Member

baronfel commented Jan 5, 2022

Hey folks, in order to help us diagnose this it would be very helpful if you could provide some of the commands that these dotnet processes are running. I think it's possible to do this through Activity Monitor, but you should also be able to use the ps utility to retrieve some of this. If we had an idea of what commands/applications were being run via the dotnet host, we could triage further.

@daniel-packard
Copy link

This affects me as well.

Command:
dotnet run in new c# console app, then ctrl-c to quit

lsof
Screen Shot 2022-01-07 at 2 38 24 PM

ps -ef | grep 6687

daniel@Magneto ~ % ps -ef | grep 6887
  501  6887     1   0  6:18PM ??         0:27.30 dotnet tool run dotnet-interactive -- notebook-parser
  501  6892  6887   0  6:18PM ??         2:39.16 /usr/local/share/dotnet/dotnet /Users/daniel/.nuget/packages/microsoft.dotnet-interactive/1.0.260601/tools/net6.0/any/Microsoft.DotNet.Interactive.App.dll notebook-parser

Not sure why dotnet-interactive is in the mix, or notebook-parser since this is not a "notebook" or "interactive" - It's just a regular console app.

@Bryke-Angar
Copy link

Bryke-Angar commented Jan 11, 2022

Same issue, on macOS Big Sur (11.6.2). Using dotnet 6.0.101 and commit ef49f62.
image

A single dotnet process uses 100% CPU and doesn't get below 96%. If I spin up another dotnet process at the same time, the same issue all dotnet processes sit around 99% CPU.
image

@LeonSolisPedro
Copy link

Happens with dotnet 5.0 as well...

image

I'm using Visual Studio 8.10, I though I was the only one...

@carmonac
Copy link

I just started my macbook i7 and I noticed my fan very active and the battery draining quick. I saw I had multiple processes of dotnet at 99% of CPU. I killed all of them.

@eighteentee
Copy link
Author

Does anyone have a workaround for this? I can't keep having to check Activity Monitor every time I run my apps to check stuff just to close these rogue DotNet processes. Every. Single. Time. It's really getting old now 😞

@carmonac
Copy link

do you have vscode with C# extension? I noticed that removing that extension it solved the problem.

@jakob753951
Copy link

jakob753951 commented Feb 4, 2022

For me, this originated from the C# extension for VS Code when trying to start a .NET Interactive notebook.
Even after closing all instances of VS Code, the botnet process persisted. The quick fix for now is to just kill the process.

Edit: This was not on an M1 MacBook, but an intel MacBook. (a 2019 13' MacBook Pro to be precise)

@ArquitetoMovel
Copy link

I have the same problema when I run VSCode for Mac with m1 running a dotnet project and close it. Always 2 dotnet6 processes remains with 100% of CPU consumption .
I tried upgrade the OmniSharp extension to a m1 support, but the problem still occur.

@danmoseley
Copy link
Member

So this requires VS Code to repro? If you disable omnisharp and all other extensions does it still repro?

What are the command lines of the errant processes?

If you attach a debugger what is the stack of the busy thread?

@eighteentee
Copy link
Author

Can confirm that disabling all MS C# extensions in VS Code eradicates the problem.

@danmoseley
Copy link
Member

danmoseley commented Feb 6, 2022

Can you enable one at a time to help find the culprit? Then we should move this issue there

@jakob753951
Copy link

The issue seems to stem from the extension ".NET Interactive Notebooks"
There is already an issue on the GitHub of that extension: dotnet/interactive#1650

@BD5WP
Copy link

BD5WP commented Feb 11, 2022

Definitely not ".NET Interactive Notebooks" for me as I don't have that extension installed. Similar to many other people here, I do have the C# extension installed. While I have yet to pinpoint the exact steps to reproduce, this problem definitely occurs when I'm working on C# console apps.

@danmoseley
Copy link
Member

If it's the C# extension this should be tracked in the Onnisharp repo.

@jakob753951
Copy link

Definitely not ".NET Interactive Notebooks" for me as I don't have that extension installed. Similar to many other people here, I do have the C# extension installed. While I have yet to pinpoint the exact steps to reproduce, this problem definitely occurs when I'm working on C# console apps.

That's certainly interesting, as I don't have the C# extension installed, but only the Python, Jupyter, and ".NET Interactive Notebooks" extensions installed

@jakob753951
Copy link

Perhaps both the extensions are doing a similar thing wrong? Or the issue really is from the dotnet sdk.

@LeonSolisPedro
Copy link

Pretty sure is dotnet sdk

@BD5WP
Copy link

BD5WP commented Feb 11, 2022

Perhaps both the extensions are doing a similar thing wrong?

Certainly possible, but...

Or the issue really is from the dotnet sdk.

...seems more likely.

@leolorenzoluis
Copy link

leolorenzoluis commented May 11, 2022

This looks like the .NET Interactive Notebooks extension for VS Code bug we fixed recently: dotnet/interactive#1005. The fix is in the current VS Code Insiders version of the extension should roll out to stable this week.

I am experiencing the same issue as @BD5WP mentioned. I don't have the Notebook extension installed, but yet high CPU usage. My guess is OmniSharp has a bug?

I have dotnet version: 6.0.201.

Screen Shot 2022-05-11 at 6 45 33 AM

@malah-code
Copy link

Same issue here in my MacBook Pro
image

after any dotnet run

@danmoseley
Copy link
Member

For everyone reporting here, please disable extensions in turn to figure out the problematic one by elimination.

If it's the notebook extension please update to the fix mentioned above.

If it's Omnisharp please open an issue in that repo.

If it is neither please share here with what extension it is or that it repros with zero extensions somehow.

@younky-yang
Copy link

I would like to say that for so long we haven't figure out this. I also have the issue not just from the interactive notebook, but also from console after I run dotnet build and dotnet run, there are always remained dotnet process which not terminated.

@LeonSolisPedro
Copy link

LeonSolisPedro commented May 24, 2022

Same here, But I'm using Visual Studio for Mac 2019.

I have noticed that the issue is no longer so frequent. So it doesn't bother me anymore...

Does anybody notice this? (That it's not so frequent anymore?)

@patricksadowski
Copy link

We run some of our dotnet test CI jobs on Mac M1 for multi-arch purposes. Each test job does the work in a fresh .NET6 SDK docker container. If two test jobs are running simultaneously the jobs hang and have to be aborted after 1h.

@clement128
Copy link

After I disable .Net Interactive Notebooks and restart vscode it seems much better now

image

@malah-code
Copy link

Same here
image
image
image

@hotyes
Copy link

hotyes commented Jul 28, 2022

image

image

I had disabled .Net Interactive Notebooks but it is still so high

@thanhdevapp
Copy link

same here, m1, MBP 2020

@boeremak
Copy link

boeremak commented Aug 4, 2022

Same issue M1 Air.

Removed all the Dotnet core stuff from my M1 Air (SDK and runtime) and installed the X64 version on it. It seems to work fine now. I don't know why, I am just happy it does, because it was unworkable.

I used the following script to remove everything: https://github.com/dotnet/sdk/blob/main/scripts/obtain/uninstall/dotnet-uninstall-pkgs.sh

I tried the ARM64 on its own but it seems to cause the same problem.

@lsmtom
Copy link

lsmtom commented Sep 29, 2022

Hard to believe. Switching to the X64 version solves the issue in my MBP with M1 Pro. I guess it is IO related. Except for dotnet run/build, using System.IO.File.Move also got stuck.

@damien122
Copy link

damien122 commented Oct 17, 2022

Same issue here. But in my case one dotnet process freeze with 100% CPU every time I try to debug my code. Just after calling the second time my REST API of asp.net app the process freeze without any output.
Tried with .net SDK 6.0.4 and .net SDK 7.0.100-rc.2.22477.23, same behavior. Here are two memory dumps and visual studio dumps.

dump_dotnet_6.txt
dump_dotnet_7.txt
VSMonitor-2022-10-17-14-28-38-e8a0dba.log
Ide.2022-10-17__14-28-38.log

Also the same build with debug configuration started vom terminal runs without problems and the same builded binaries started as debug session with rider or visual studio for Mac freeze after second REST API call.

@damien122
Copy link

@damien122
Copy link

installing the x64 SDK version didn't fix my problem.

@vikasjayaswal
Copy link

vikasjayaswal commented Nov 25, 2022

Same Issue: What do I need to provide besides my high-cpu load to help debug this issue? I am on a Monteray 12.5.1

@emirefeerez
Copy link

How can i remove all dotnet features on my mac?

@ArquitetoMovel
Copy link

run on term:

dotnet --list-sdks

This command will show you where all sdks of dotnet was installed on the machine.
Now you can go to the folder and remove all dotnet stuff.

@averichev
Copy link

in my case, the problem was solved by closing Rider

@qzeng2490
Copy link

same issue on M2 pro with dotnet 7

@mattjohnsonpint
Copy link

FWIW, this issue went away for me after disabling the C# extension in VS Code. Which sucks, but I haven't seen the problem reappear since. I mostly use Rider now for real work. I still use VS Code for its search features, but I don't expect any advanced features like code completion.

Given that others are still reporting the problem, I'm hesitant to turn it back on. But I'm reasonably certain the problem is OminiSharp, not the .NET SDK.

@onionhammer
Copy link

onionhammer commented May 2, 2023

Kinda crazy this is still happening.. Hopefully now that @davidfowl has a Mac maybe it'll get fixed :P

@tomassabol
Copy link

same here. M1 PRO and .net 7. I'm not even using .net for anything at the moment, just have it installed

@nguyentrungtu
Copy link

nguyentrungtu commented May 17, 2023

On Mac M1, high CPU usage from rzls process when using VSCode to browse a Razor project. Seems to happen intermittently, the only fix right now is to quit VSCode and reopen.

@payam49er
Copy link

This issue still exists on .Net 8 Latest Preview. My machine is MacBook Pro M1 Max with Ventura 13.4 OS. This is a critical issue and must be fixed!

@natdempk
Copy link

Also seeing this issue running a web application project (entirely independent of VS Code or any addons) under .Net 7 from the command line, where on startup CPU for the process is pinned at 100% and it never runs correctly when running dotnet run.

@vikasjayaswal
Copy link

vikasjayaswal commented Aug 21, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-MacOS untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests