无法在 AWS c5.18xlarge 72 vpu 上使用 .NET 中的所有处理器

Unable to use all processors in .NET on AWS c5.18xlarge 72 vpu

如何在 AWS c5.18xlarge 实例上使用我的 .net 应用程序中的所有虚拟处理器?目前,该应用程序在 72 个虚拟处理器中占据了 36 个 (50%)。

在 AWS 上,我启动了一个 c5.18xlarge 实例,标榜有 72 个虚拟处理器。

示例应用程序 1:

Parallel.For(0, 1000, i =>
{
    var w = new Stopwatch();
    w.Start();
    Console.Write("#");
    while (w.ElapsedMilliseconds < 1000);
});

示例 2:

for (var i = 0; i < 72; i++)
{
    new System.Threading.Thread(() =>
    {
        var w = new Stopwatch();
        w.Start();
        Console.Write("#");
        while (w.ElapsedMilliseconds < 5000);
    }).Start();
}

我正在使用 Roslyn/C# 交互。

我找到的最匹配的文章没有帮助..

想通了..

要使 .NET 能够使用所有 NUMA 节点,请将以下内容添加到您的 app.config:

<configuration>
  <runtime>
    <Thread_UseAllCpuGroups enabled="true"/>  
      <GCCpuGroup enabled="true"/>  
      <gcServer enabled="true"/>  
</runtime>
</configuration>

现在它正以 100% 的速度鸣叫。

来源: