Visual Studio 2022 上的 F# 非常慢

F# on Visual Studio 2022 very slow

这仅适用于 Visual Studio 2022。我已经卸载了 VS2019 和预览,其中 F# 工作得非常好 (F# 5.0)。我正在用VS2022来使用F#6.0,不想回到F#5.0.

此问题特定于 F#。我也用 C# 没问题 运行 最新的 C# 在 VS2022 下。

近乎连续的 DevEnv 进程 运行 消耗了我 CPU 的 4 个超线程中的 1 到 4 个。我已经关闭了在 F# 设置中可以找到的所有实验选项。

有时有 2 个或更多后台进程 运行,有时暂停,有时 none - 这似乎与后台 CPU 消耗之间没有关联

有时我会弹出一个对话框,等待完成编辑过程或编译过程。

当 devenev.exe 在属性下消耗 CPU 个周期时,我看到总是有一个 clr.dllCoUnInitializeEE+0x6790 是罪魁祸首。我虽然这是一个短暂的过程?有时有两个或三个消耗大部分超线程(有相同的其他但消耗非常低或没有 CPU 消耗)。有罪线程上的堆栈如下:

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

我只为 windows C# 和 F# 项目重新安装了 VS2022。

希望这些信息足以提供有关正在发生的事情的线索。

更新

查看我在 tidyups 方面的进一步努力的评论,并拥有我认为需要的框架 4.6 和 4.7 dot net dlls/runtimes 并且只有一个 dot net 核心,我认为它是 6.0 但被列为 Microsoft .NET Core SDK - 2.1.202(x64) - 如果这是问题所在。

问题似乎仍然是 CoUninitialize,它应该是一个用于卸载 COM 对象的短期线程 - 请参阅 https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-couninitializeF# 的哪一部分正在使用无法卸载的 Com 对象,因为在 editing/compiling C# 项目中不会发生这种情况?

更新 2

我重新安装了 VS2022 和最小的点网络库 IIRC 它需要 4.6 和 4.7 框架来安装一些 C# 和 F#。现在一切都恢复了,而我什么也没做,包括没有自动更新等。这是来自 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.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]

再次使用 dotnet-core-uninstall 后,一些 skds/runtimes 神奇地重新出现在这里,当前输出:

    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:

请使用 windows 中的人脉应用或 visual studio 安装程序向 Microsoft 报告。

目前只有一个选择:使用 visual studio 2019。 或尝试寻找替代品。网络周围应该有什么地方

我建议改用 Rider IDE(直到开发人员修复错误):Download Rider IDE

我并不是真的想在这里做广告,只是建议 IDE 太编译和 运行 你的程序。

我不知道为什么,但我 运行 Chris Titus' Windows debloat 并进行了一般清理,例如启动、服务和删除 old/unused 程序和一些东西解决了这个问题!对其他人来说不是真正的答案,但也许这也可以帮助别人。