Skip to content

Add config var to allow disabling automatic CPU group assignment for threads - #38568

Merged
kouvel merged 1 commit into
dotnet:masterfrom
kouvel:AssignCpuGroupConfig
Jul 29, 2020
Merged

Add config var to allow disabling automatic CPU group assignment for threads#38568
kouvel merged 1 commit into
dotnet:masterfrom
kouvel:AssignCpuGroupConfig

Conversation

@kouvel

Copy link
Copy Markdown
Contributor
  • When CPU groups are enabled through config, some new threads (Thread.Start, thread pool threads) are automatically assigned to a CPU group, starting with the process' CPU group and once it is filled up, assigning new threads to a different CPU group. An app may have native components that also use threads, and may want to do its own thread-spreading (for instance in DllMain), this config allows such apps to disable the automatic CPU group assignment which would otherwise override an assignment made in DllMain. The new config var does not affect GC threads.
  • This was requested for .NET Framework, porting to .NET Core as well

…threads
- When CPU groups are enabled through config, some new threads (Thread.Start, thread pool threads) are automatically assigned to a CPU group, starting with the process' CPU group and once it is filled up, assigning new threads to a different CPU group. An app may have native components that also use threads, and may want to do its own thread-spreading (for instance in DllMain), this config allows such apps to disable the automatic CPU group assignment which would otherwise override an assignment made in DllMain. The new config var does not affect GC threads.
- This was requested for .NET Framework, porting to .NET Core as well
@kouvelkouvel added this to the Future milestone Jun 29, 2020
@kouvel
kouvel requested review from jkotas and mangod9June 29, 2020 19:22
@kouvelkouvel self-assigned this Jun 29, 2020
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadCountThresholdForGCTrigger, W("Thread_DeadThreadCountThresholdForGCTrigger"), 75, "In the heuristics to clean up dead threads, this threshold must be reached before triggering a GC will be considered. Set to 0 to disable triggering a GC based on dead threads.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadGCTriggerPeriodMilliseconds, W("Thread_DeadThreadGCTriggerPeriodMilliseconds"), 1000 * 60 * 30, "In the heuristics to clean up dead threads, this much time must have elapsed since the previous max-generation GC before triggering another GC will be considered")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_UseAllCpuGroups, W("Thread_UseAllCpuGroups"), 0, "Specifies whether to query and use CPU group information for determining the processor count.")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_AssignCpuGroups, W("Thread_AssignCpuGroups"), 1, "Specifies whether to automatically distribute threads created by the CLR across CPU Groups. Effective only when Thread_UseAllCpuGroups and GCCpuGroup are enabled.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these get auto documented, or needs manual doc updates?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it will need manual update to https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/thread-useallcpugroups-element and to add a similar element in the docs repo

Comment threadsrc/coreclr/src/utilcode/util.cpp
@kouvelkouvel added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 2, 2020
@kouvel

Copy link
Copy Markdown
ContributorAuthor

Flagged as no-merge for now, waiting for the change to go into .NET Framework first

@kouvelkouvel removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jul 24, 2020
@kouvel
kouvel merged commit b262f0b into dotnet:masterJul 29, 2020
@kouvel
kouvel deleted the AssignCpuGroupConfig branch July 29, 2020 18:51
Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
…threads (dotnet#38568)
- When CPU groups are enabled through config, some new threads (Thread.Start, thread pool threads) are automatically assigned to a CPU group, starting with the process' CPU group and once it is filled up, assigning new threads to a different CPU group. An app may have native components that also use threads, and may want to do its own thread-spreading (for instance in DllMain), this config allows such apps to disable the automatic CPU group assignment which would otherwise override an assignment made in DllMain. The new config var does not affect GC threads.
- This was requested for .NET Framework, porting to .NET Core as well
@ghostghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kouvel@mangod9