Skip to content

.NET and .NET Core missing Processor Group on Process.Start #30124

@nick2893

Description

@nick2893

Here:
corefx/src/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs

https://github.com/dotnet/corefx/blob/8c5260061b11323dfd97fbab614d54402405513f/src/Common/src/Interop/Windows/Kernel32/Interop.CreateProcess.cs

And here:

https://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/Process.cs,c50d8ac0eb7bc0d6,references

system/diagnosticts/Process.cs - StartWithCreateProcess

I have a problem because I spent a lot of money on machines with a lot of CPUs. Specifically, I have more than 1 NUMA Processor group. In C++ I was able to deal with this as,

GROUP_AFFINITY aff;
RtlZeroMemory(&aff, sizeof(GROUP_AFFINITY));
aff.Group = iProcessorGroup;
aff.Mask = 0xffffffff;
LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
lpAttributeList = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>
(HeapAlloc(GetProcessHeap(), 0, size));
fSuccess = InitializeProcThreadAttributeList(lpAttributeList, 1, 0, &size);
fSuccess = UpdateProcThreadAttribute(lpAttributeList,
0, PROC_THREAD_ATTRIBUTE_PREFERRED_NODE, &aff.Group, sizeof(aff.Group), NULL, NULL);
STARTUPINFOEX info;
ZeroMemory(&info, sizeof(info));
ZeroMemory(&info.StartupInfo, sizeof(STARTUPINFO));
info.StartupInfo.cb = sizeof(info);
info.lpAttributeList = lpAttributeList;

And then, when calling CreateProcess with &info.StartupInfo - it would correctly start on the processor group where I want it to start. However, in .NET, this cannot be done, I cannot specify on which NUMA node / processor group to start my process. (Sometimes I use round-robin, sometimes the least utilized group, sometimes whatever the GUI provides). However, in .NET 4.8 or Core, this option doesn't exist.

Can we add STARTUPINFOEX to CreateProcess so that I'm not wasting CPU (groups) or running through piles of Win32 API code to start a .NET Process?

Metadata

Metadata

Assignees

Labels

api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.ProcessuntriagedNew issue has not been triaged by the area owner

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions