-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Document DOTNET_Thread_DefaultStackSize environment variable and runtimeconfig.json property for .NET 10 #49657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
| **Note:** This setting does not affect threads for which a non-default stack size is specified at creation. | ||
|
|
||
| ... | ||
| ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot There’s no content here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 25a138b. Removed the placeholder ellipses (...) that had no actual content.
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
|
@copilot Please adjust the PR to be against main |
| ms.date: 11/04/2021 | ||
| ai-usage: ai-assisted | ||
| --- | ||
| # Runtime configuration options for threading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot keep all the old content, just add the new at the bottom
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit db3f8b3. Restored all original content and added the new DOTNET_Thread_DefaultStackSize section at the bottom.
I don't have the ability to change the base branch of the PR directly from this environment. You'll need to either:
The documentation changes are complete and ready - the file is standalone and should merge cleanly into main. |
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
|
|
||
| ## Default stack size for new threads | ||
|
|
||
| - Specifies the stack size (in bytes) for new VM threads that are created with the default stack size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Can you make this section match the format of the above examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit e6af8ed. Simplified the section to match the format used in other threading config sections:
- Concise 2-bullet description
- Complete table with all three configuration types (runtimeconfig.json, MSBuild property, Environment variable)
- Removed Examples subsection since there are no config file examples
- Used NOTE callout for the important caveat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds documentation for the DOTNET_Thread_DefaultStackSize environment variable, a new .NET 9 runtime configuration option that controls the default stack size for newly created threads. The documentation follows the established pattern used elsewhere in the threading configuration file.
- Adds the
ai-usage: ai-assistedfrontmatter metadata - Documents the new
DOTNET_Thread_DefaultStackSizeenvironment variable for .NET 9 - Provides examples for setting the environment variable across different platforms and shells
|
|
||
| | | Setting name | Values | Version introduced | | ||
| | - | - | - | - | | ||
| | **Environment variable** | `DOTNET_Thread_DefaultStackSize` | An integer value (bytes). Example: `1048576` for 1 MB | .NET 9 | |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example text in the 'Values' column should end with a period for consistency. Other tables in the document use periods when the content is more than three words (see line 189 for a similar pattern).
|
|
||
| ### Examples | ||
|
|
||
| Set the stack size to 2 MB for all new threads: |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instructions should use imperative mood starting with a verb, not descriptive statements. Change to 'To set the stack size to 2 MB for all new threads:' or rephrase as an imperative command.
| dotnet myapp.dll | ||
| ``` | ||
|
|
||
| #### In C# code (for reference, no runtimeconfig property): |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Headings should use sentence case and avoid gerunds or complex phrasing. Consider simplifying to 'C# code example' or 'Example with C# code'.
| set DOTNET_Thread_DefaultStackSize=2097152 | ||
|
|
||
| # PowerShell | ||
| $env:DOTNET_Thread_DefaultStackSize="2097152" |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PowerShell example uses double quotes while the Unix example doesn't quote the value. For consistency across all platforms and to match patterns used elsewhere in .NET documentation, consider removing quotes from the PowerShell example: $env:DOTNET_Thread_DefaultStackSize=2097152
| $env:DOTNET_Thread_DefaultStackSize="2097152" | |
| $env:DOTNET_Thread_DefaultStackSize=2097152 |
| thread.Start(); | ||
| ``` | ||
|
|
||
| **Note:** This setting does not affect threads for which a non-default stack size is specified at creation. |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word 'that' is preferred over 'which' for restrictive clauses in Microsoft documentation style. Change 'for which' to 'that have' or restructure as: 'This setting doesn't affect threads that explicitly specify a non-default stack size at creation.' Also consider using the contraction 'doesn't' for a more conversational tone.
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
|
|
||
| ## Default stack size for new threads | ||
|
|
||
| - Configures the default stack size (in bytes) for threads created by <xref:System.Threading.Thread> and other APIs that don't specify an explicit stack size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I believe the number is in hex. Also, I don't believe it applies to the main thread of the application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit a888838. Updated the documentation to:
- Clarify that the value is in hexadecimal bytes
- Note that the setting doesn't affect the main application thread
- Also improved the writing style with contractions and added a period to the Values column for consistency
|
|
||
| | | Setting name | Values | Version introduced | | ||
| | - | - | - | - | | ||
| | **runtimeconfig.json** | N/A | N/A | N/A | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I believe there is a runtimeconfig.json property: "System.Threading.DefaultStackSize"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 0ec2054e. Added the System.Threading.DefaultStackSize runtimeconfig.json property and included Examples section showing usage in both runtimeconfig.json and runtimeconfig.template.json files with a hexadecimal value (0x100000 for 1 MB).
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
| - If not specified, the default stack size is determined by the operating system. | ||
|
|
||
| | | Setting name | Values | Version introduced | | ||
| | - | - | - | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This is only available on all platforms starting in .NET 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 4892484. Updated both the runtimeconfig.json property and environment variable to show ".NET 10" as the version introduced.
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Summary
Adds documentation for the new
DOTNET_Thread_DefaultStackSizeenvironment variable andSystem.Threading.DefaultStackSizeruntimeconfig.json property introduced in .NET 10, which configures the default stack size for threads created without an explicitly specified stack size. The value is specified as a hexadecimal number representing bytes, and this setting does not affect the main application thread.The documentation follows the standard format used by other threading configuration sections in the file, including:
Changes Made
ai-usage: ai-assistedto the frontmatter as requiredSystem.Threading.DefaultStackSizeruntimeconfig.json property (.NET 10)DOTNET_Thread_DefaultStackSizeenvironment variable (.NET 10)Testing
The changes maintain consistency with the existing documentation style and structure.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews