1

I have an .NET Core application that starts up 512 Tasks that populate an AI network. I'm performing scaling tests and I've run benchmarks on 2, 4, 8, 16, 32 and 64 processor machines in Azure. All of the benchmark tests use 100% of the available vCPUs on the machine.

When I tried running the test on a M128 (128 vCPUs), the test ran at 50% CPU Utilization. I checked the environment variables and Environment.ProcessorCount told me there are only 64 processors (the documentation says this is the virtual processor count). Digging further, I find there's an architectural limit of 64 CPUs per 'Processor Group'. This machine apparently has 2 processor groups with 64 in each.

Is this a bug in .NET Core or is .NET Core limited to only one processor group?

Quark Soup
  • 4,272
  • 3
  • 42
  • 74
  • https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element – Hans Passant Apr 09 '20 at 19:45

2 Answers2

3

As per this documentation, you can enable execution on more than 64 logical processors in a single process. You need to set the following in your app.config:

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

Verified working with .net framework 4.8 on windows with an AMD EPYC 7713P, which has 128 cores in total. Previously, it was only running on 64 cores; it works after adding the config.

Next, I've just got to work on the IO bottleneck...

Connor Low
  • 5,900
  • 3
  • 31
  • 52
  • 1
    Thank you. I think the real answer is "if you need more than 64 K processors, you need to break the problem up and distribute it with Kubernetes." – Quark Soup Aug 27 '21 at 14:57
1

The documentation for Environment.ProcessorCount says

If the current machine contains multiple processor groups, this property returns the number of logical processors that are available for use by the common language runtime (CLR).

I think you may need to run multiple processes (and therefor multiple instances of the CLR) to take advantage of the second group.

pquest
  • 3,151
  • 3
  • 27
  • 40
  • How do I do that? Run another instance of the web service? – Quark Soup Apr 09 '20 at 19:03
  • @Quarkly, if the threads don't need to communicate with each other, that would probably be the best way to do it. At that point it might make more sense to just use several 64 cpu vms rather than run 2 instances on one bigger VM. If they do need to coordinate in some way, you will probably have to write the code to do that coordination between the processes. – pquest Apr 09 '20 at 19:08