简体   繁体   中英

F# on Visual Studio 2022 very slow

This only applies to Visual Studio 2022. I had uninstalled VS2019 and Preview where F# worked absolutely fine (F# 5.0). I am using VS2022 to use F# 6.0 and do not want to go back to F# 5.0.

The issue is specific to F#. I also use C# and I have no issues running the latest C# under VS2022.

There are near continual DevEnv processes running consuming anywhere from 1 to 4 of my CPU's 4 Hyperthreads. I have switched off all experimental options I can find in F# settings.

Sometimes there are 2 or more background processes running, sometimes paused and sometimes none - there appears to be no correlation between this and the background CPU consumption

Sometimes I have a pop up Dialog about waiting to complete an editor process or a compile process.

When devenev.exe is consuming CPU cycles under the properties I see there is always one clr.dllCoUnInitializeEE+0x6790 that is the culprit. I though this was meant to be a short-lived process? Sometimes there are two or three of these consuming most of a HyperThread (There are identical others but with very low or no CPU consumption). The stack on the guilty thread is as follows:

1, Microsoft.FSharp.Collections.SeqModule+Zip@633[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Invoke(System.__Canon, System.__Canon) + 0x50 <-- FSharp.Core.ni.dll+0x83f430
2, Microsoft.FSharp.Collections.Internal+IEnumerator+map2@103[[System.__Canon, mscorlib],[System.__Canon, mscorlib],[System.__Canon, mscorlib]].DoMoveNext(System.__Canon ByRef) + 0xca <-- FSharp.Core.ni.dll+0x8476ba
3, Microsoft.FSharp.Collections.Internal+IEnumerator+MapEnumerator`1[[System.__Canon, mscorlib]].System.Collections.IEnumerator.MoveNext() + 0x40 <-- FSharp.Core.ni.dll+0x847270
4, Microsoft.FSharp.Collections.SeqModule.ForAll[[System.__Canon, mscorlib]](Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Boolean>, System.Collections.Generic.IEnumerable`1<System.__Canon>) + 0x76 <-- FSharp.Core.ni.dll+0x753466
5, FSharp.Compiler.Symbols.SymbolHelpers+ItemDisplayPartialEquality@485.System.Collections.Generic.IEqualityComparer<FSharp.Compiler.NameResolution.Item>.Equals(Item, Item) + 0x24 <-- FSharp.Compiler.Service.ni.dll+0x2900294
6, System.Collections.Generic.Dictionary`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].Insert(System.__Canon, System.__Canon, Boolean) + 0x200 <-- mscorlib.ni.dll+0x57bea0
7, Internal.Utilities.Library.IPartialEqualityComparer+partialDistinctBy@1001[[System.__Canon, mscorlib]].Invoke(System.__Canon) + 0xb0 <-- FSharp.Compiler.Service.ni.dll+0x2bc9540
8, Microsoft.FSharp.Primitives.Basics.List.filterToFreshConsTail[[System.__Canon, mscorlib]](Microsoft.FSharp.Collections.FSharpList`1<System.__Canon>, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Boolean>, Microsoft.FSharp.Collections.FSharpList`1<System.__Canon>) + 0x4e <-- FSharp.Core.ni.dll+0x76060e
9, Microsoft.FSharp.Primitives.Basics.List.filter[[System.__Canon, mscorlib]](Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Boolean>, Microsoft.FSharp.Collections.FSharpList`1<System.__Canon>) + 0xe7 <-- FSharp.Core.ni.dll+0x760747
10, FSharp.Compiler.EditorServices.DeclarationListInfo.Create(InfoReader, AccessorDomain, FSharp.Compiler.Text.Range, DisplayEnv, Microsoft.FSharp.Core.FSharpFunc`2<Item,FSharp.Compiler.Symbols.FSharpAccessibility>, Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.EditorServices.CompletionItem>, Microsoft.FSharp.Core.FSharpOption`1<System.String[]>, Boolean) + 0x2a0 <-- FSharp.Compiler.Service.ni.dll+0x274a830
11, <StartupCode$FSharp-Compiler-Service>.$FSharpCheckerResults+GetDeclarations@1088.Invoke(Microsoft.FSharp.Core.Unit) + 0x2a0 <-- FSharp.Compiler.Service.ni.dll+0x289c0b0
12, FSharp.Compiler.Diagnostics.ErrorScope.Protect[[System.__Canon, mscorlib]](FSharp.Compiler.Text.Range, Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,System.__Canon>, Microsoft.FSharp.Core.FSharpFunc`2<System.String,System.__Canon>) + 0x58 <-- FSharp.Compiler.Service.ni.dll+0x24a7d28
13, FSharp.Compiler.CodeAnalysis.TypeCheckInfo.GetDeclarations(Microsoft.FSharp.Core.FSharpOption`1<FSharp.Compiler.CodeAnalysis.FSharpParseFileResults>, Int32, System.String, FSharp.Compiler.EditorServices.PartialLongName, Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.EditorServices.AssemblySymbol>>) + 0x101 <-- FSharp.Compiler.Service.ni.dll+0x27b3831
14, <StartupCode$FSharp-Compiler-Service>.$FSharpCheckerResults+GetDeclarationListInfo@1953-1.Invoke(FSharp.Compiler.CodeAnalysis.TypeCheckInfo) + 0x31 <-- FSharp.Compiler.Service.ni.dll+0x28a33d1
15, <StartupCode$FSharp-Editor>.$CompletionProvider+ProvideCompletionsAsyncAux@110-6.Invoke(Microsoft.CodeAnalysis.Text.SourceText) + 0x143 <-- 0x7ffdb4beacd3
16, Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[[System.__Canon, mscorlib],[System.__Canon, mscorlib]](Microsoft.FSharp.Control.AsyncActivation`1<System.__Canon>, System.__Canon, Microsoft.FSharp.Core.FSharpFunc`2<System.__Canon,Microsoft.FSharp.Control.FSharpAsync`1<System.__Canon>>) + 0x3e <-- FSharp.Core.ni.dll+0x7c756e
17, clr.dll+0x42b6
18, Microsoft.FSharp.Control.Trampoline.Execute(Microsoft.FSharp.Core.FSharpFunc`2<Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Control.AsyncReturn>) + 0x60 <-- FSharp.Core.ni.dll+0x7c5420
19, <StartupCode$FSharp-Core>.$Async+AwaitWaitHandle@1661-3.Invoke(System.Object, Boolean) + 0xc5 <-- FSharp.Core.ni.dll+0x824265
20, System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) + 0x172 <-- mscorlib.ni.dll+0x58df12
21, System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) + 0x15 <-- mscorlib.ni.dll+0x58dd95
22, System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(System.Object, Boolean) + 0xed <-- mscorlib.ni.dll+0xf3676d
23, clr.dll!CoUninitializeEE+0x1b73
24, clr.dll!CoUninitializeEE+0x1a88
25, clr.dll!DllRegisterServerInternal+0x19f43
26, clr.dll!TranslateSecurityAttributes+0x298b3
27, clr.dll!CoUninitializeEE+0x2f30
28, clr.dll!CoUninitializeEE+0x2ea3
29, clr.dll!CoUninitializeEE+0x2de2
30, clr.dll!CoUninitializeEE+0x2fc7
31, clr.dll!TranslateSecurityAttributes+0x296ff
32, clr.dll!ReOpenMetaDataWithMemoryEx+0x1252
33, clr.dll!ReOpenMetaDataWithMemoryEx+0x4090
34, clr.dll!GetMetaDataPublicInterfaceFromInternal+0x1bde5
35, clr.dll!CoUninitializeEE+0x6815
36, kernel32.dll!BaseThreadInitThunk+0x14
37, ntdll.dll!RtlUserThreadStart+0x21

I have reinstalled VS2022 just for windows C# and F# projects and nothing else.

Hopefully this is enough information to provide clues as to what is going on.

Update

See comments for my further efforts at tidyups and have what I think are needed Framework 4.6 and 4.7 dot net dlls/runtimes and only one dot net core which I think is 6.0 but is listed as Microsoft .NET Core SDK - 2.1.202(x64) - if that is the issue.

The issue still seems to be CoUninitialize which should be a short-lived thread to unload COM objects - see https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-couninitialize . What bit of F# is using Com Objects that are failing to unload, as this does not happen when editing/compiling C# projects?

Update 2

I re-installed VS2022 again with minimal dot net libraries IIRC it needed 4.6 and 4.7 Framework for some C# and F# to be installed. Now everything is back whilst I have done nothing else including no auto-updates etc. Here is the latest dump from dotnet --info :

PS ..> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  3.1.413 [C:\Program Files\dotnet\sdk]
  5.0.302 [C:\Program Files\dotnet\sdk]
  5.0.403 [C:\Program Files\dotnet\sdk]
  6.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

After using dotnet-core-uninstall again, some skds/runtimes magically re-appeared here it the current output:

    PS C:\WINDOWS\system32> dotnet-core-uninstall list

This tool cannot uninstall versions of the runtime or SDK that are 
    - SDKs installed using Visual Studio 2019 Update 3 or later.
    - SDKs and runtimes installed via zip/scripts.
    - Runtimes installed with SDKs (these should be removed by removing that SDK).
The versions that can be uninstalled with this tool are:

.NET Core SDKs:
  5.0.403  x64    [Used by Visual Studio. Specify individually or use --force to remove]
  2.1.202  x64    [Used by Visual Studio. Specify individually or use --force to remove]

.NET Core Runtimes:

ASP.NET Core Runtimes:
  5.0.12  x86
  5.0.10  x64
  3.1.21  x64
  2.1.30  x64

.NET Core Runtime & Hosting Bundles:

Please report to Microsoft either using the people app in windows or the visual studio installer.

for now, there is only one option: use visual studio 2019. or try finding alternatives. there should be somewhere around the net

I suggest using Rider IDE instead(until the devs fix the bug): Download Rider IDE

I'm not really trying to advertise here, just suggesting an IDE Too compile and run you rprogram.

I do not know why but I ran Chris Titus' Windows debloat and did general cleanups eg for StartUp, Services and removing old/unused programs and something in that fixed the issue. Not really an answer for anyone else but maybe this can help someone too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM