Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Summary

Adds documentation for the new DOTNET_Thread_DefaultStackSize environment variable and System.Threading.DefaultStackSize runtimeconfig.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:

  • Concise 2-bullet description explaining the setting's purpose, format, and default behavior
  • Complete configuration table showing all three configuration types (runtimeconfig.json, MSBuild property, and Environment variable)
  • Examples section demonstrating usage in runtimeconfig.json and runtimeconfig.template.json files
  • NOTE callout explaining that threads with explicit stack size specifications are unaffected by this setting

Changes Made

  • Added ai-usage: ai-assisted to the frontmatter as required
  • Added "Default stack size for new threads" section at the bottom of existing content
  • Preserved all original documentation content (267 lines)
  • Followed the established format pattern used throughout the threading.md file
  • Configuration table includes:
    • System.Threading.DefaultStackSize runtimeconfig.json property (.NET 10)
    • DOTNET_Thread_DefaultStackSize environment variable (.NET 10)
    • MSBuild property marked as N/A (not available)
  • Added Examples section with runtimeconfig.json and runtimeconfig.template.json usage examples showing hexadecimal value format (0x100000 for 1 MB)
  • Used xref to link to System.Threading.Thread API documentation
  • Clarified that the value is specified as a hexadecimal number representing bytes
  • Documented that the setting does not affect the main application thread
  • Used conversational tone with contractions for consistency with Microsoft documentation style
  • Updated version information to reflect .NET 10 availability across all platforms

Testing

  • ✅ Markdown linting passes with no errors
  • ✅ Section format matches other threading configuration sections in the file
  • ✅ Code review passes with no critical issues
  • ✅ All original content preserved and new section added at the end (file is now 306 lines)

The changes maintain consistency with the existing documentation style and structure.

Original prompt

Update docs/core/runtime-config/threading.md to include documentation for the new environment variable DOTNET_Thread_DefaultStackSize=val, which sets the stack size, in bytes, for new VM threads created with the default stack size. Add a section describing what it does, a configuration table, usage examples for several platforms, and a note that threads created with an explicit stack size are unaffected. Include this in the appropriate section following the style of the current threading configuration documentation. Make sure to add the frontmatter ai-usage: ai-assisted.

Example table entry:

Setting name Values Version introduced
Environment variable DOTNET_Thread_DefaultStackSize An integer value (bytes). Example: 1048576 for 1 MB .NET 9

This pull request was created as a result of the following prompt from Copilot chat.

Update docs/core/runtime-config/threading.md to include documentation for the new environment variable DOTNET_Thread_DefaultStackSize=val, which sets the stack size, in bytes, for new VM threads created with the default stack size. Add a section describing what it does, a configuration table, usage examples for several platforms, and a note that threads created with an explicit stack size are unaffected. Include this in the appropriate section following the style of the current threading configuration documentation. Make sure to add the frontmatter ai-usage: ai-assisted.

Example table entry:

Setting name Values Version introduced
Environment variable DOTNET_Thread_DefaultStackSize An integer value (bytes). Example: 1048576 for 1 MB .NET 9

💡 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

📄 File 🔗 Preview link
docs/core/runtime-config/threading.md docs/core/runtime-config/threading

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title [WIP] Update threading documentation for new environment variable Document DOTNET_Thread_DefaultStackSize environment variable for .NET 9 Nov 7, 2025
Copilot finished work on behalf of agocke November 7, 2025 00:48
Copilot AI requested a review from agocke November 7, 2025 00:48
**Note:** This setting does not affect threads for which a non-default stack size is specified at creation.

...
...
Copy link
Member

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

Copy link
Contributor Author

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 finished work on behalf of agocke November 7, 2025 17:47
Copilot AI requested a review from agocke November 7, 2025 17:47
@agocke
Copy link
Member

agocke commented Nov 7, 2025

@copilot Please adjust the PR to be against main

@agocke agocke changed the base branch from doc/thread-stacksize-envvar to main November 7, 2025 17:53
ms.date: 11/04/2021
ai-usage: ai-assisted
---
# Runtime configuration options for threading
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Copilot AI commented Nov 7, 2025

@copilot Please adjust the PR to be against main

I don't have the ability to change the base branch of the PR directly from this environment. You'll need to either:

  1. Change the base branch using GitHub's UI (there's a button in the PR that says "Edit" next to the branches)
  2. Or rebase the branch against main manually

The documentation changes are complete and ready - the file is standalone and should merge cleanly into main.

Copilot AI requested a review from agocke November 7, 2025 17:55
Copilot finished work on behalf of agocke November 7, 2025 17:55
Copilot AI and others added 2 commits November 7, 2025 18:01
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot finished work on behalf of agocke November 7, 2025 18:06
@agocke agocke marked this pull request as ready for review November 7, 2025 19:53
@agocke agocke requested review from a team and gewarren as code owners November 7, 2025 19:53
Copilot AI review requested due to automatic review settings November 7, 2025 19:53

## Default stack size for new threads

- Specifies the stack size (in bytes) for new VM threads that are created with the default stack size.
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor

Copilot AI left a 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-assisted frontmatter metadata
  • Documents the new DOTNET_Thread_DefaultStackSize environment 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 |
Copy link

Copilot AI Nov 7, 2025

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).

Copilot generated this review using guidance from repository custom instructions.

### Examples

Set the stack size to 2 MB for all new threads:
Copy link

Copilot AI Nov 7, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
dotnet myapp.dll
```

#### In C# code (for reference, no runtimeconfig property):
Copy link

Copilot AI Nov 7, 2025

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'.

Copilot generated this review using guidance from repository custom instructions.
set DOTNET_Thread_DefaultStackSize=2097152

# PowerShell
$env:DOTNET_Thread_DefaultStackSize="2097152"
Copy link

Copilot AI Nov 7, 2025

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

Suggested change
$env:DOTNET_Thread_DefaultStackSize="2097152"
$env:DOTNET_Thread_DefaultStackSize=2097152

Copilot uses AI. Check for mistakes.
thread.Start();
```

**Note:** This setting does not affect threads for which a non-default stack size is specified at creation.
Copy link

Copilot AI Nov 7, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
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.
Copy link
Member

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.

Copy link
Contributor Author

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

Copilot AI requested a review from agocke November 7, 2025 20:02
Copilot finished work on behalf of agocke November 7, 2025 20:02

| | Setting name | Values | Version introduced |
| - | - | - | - |
| **runtimeconfig.json** | N/A | N/A | N/A |
Copy link
Member

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"

Copy link
Contributor Author

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).

Copilot AI and others added 2 commits November 7, 2025 20:05
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI requested a review from agocke November 7, 2025 20:10
Copilot finished work on behalf of agocke November 7, 2025 20:10
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title Document DOTNET_Thread_DefaultStackSize environment variable for .NET 9 Document DOTNET_Thread_DefaultStackSize environment variable and runtimeconfig.json property for .NET 9 Nov 7, 2025
Copilot finished work on behalf of agocke November 7, 2025 20:16
- If not specified, the default stack size is determined by the operating system.

| | Setting name | Values | Version introduced |
| - | - | - | - |
Copy link
Member

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

Copy link
Contributor Author

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>
Copilot AI changed the title Document DOTNET_Thread_DefaultStackSize environment variable and runtimeconfig.json property for .NET 9 Document DOTNET_Thread_DefaultStackSize environment variable and runtimeconfig.json property for .NET 10 Nov 7, 2025
Copilot AI requested a review from agocke November 7, 2025 20:25
Copilot finished work on behalf of agocke November 7, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants