From 7fc191e7a4553c67e7398f5232da58ad350025cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 25 Jul 2025 11:50:04 +0200 Subject: [PATCH 1/5] Document new threading settings Added in https://github.com/dotnet/runtime/pull/110455. --- docs/core/runtime-config/threading.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index b2806433ca0a2..acef9b08082ef 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -31,6 +31,18 @@ This article details the settings you can use to configure threading in .NET. | **runtimeconfig.json** | N/A | N/A | | **Environment variable** | `COMPlus_Thread_AssignCpuGroups` or `DOTNET_Thread_AssignCpuGroups` | `0` - disabled
`1` - enabled | +## Set the size of stack for VM-created threads + +- The default size of stack is dictated by VM and OS policies. +- This setting allows overriding the default. +- The specified size should be between 64 kB and 2 GB and a multiple of the natural allocation granularity of the OS. + +| | Setting name | Values | Version introduced | +| - | - | - | - | +| **runtimeconfig.json** | `System.Threading.DefaultStackSize` | A decimal integer that specifies the size of stack | .NET 10 | +| **Environment variable** | `DOTNET_Thread_DefaultStackSize` | A hexadecimal integer that specifies the size of stack | .NET 10 | + + ## Minimum threads - Specifies the minimum number of threads for the worker thread pool. From 2c938ed595a64ff9bbfa715d073589018b24a802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 25 Jul 2025 11:58:00 +0200 Subject: [PATCH 2/5] Update threading.md --- docs/core/runtime-config/threading.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index acef9b08082ef..cde6e9f1cf262 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -42,7 +42,6 @@ This article details the settings you can use to configure threading in .NET. | **runtimeconfig.json** | `System.Threading.DefaultStackSize` | A decimal integer that specifies the size of stack | .NET 10 | | **Environment variable** | `DOTNET_Thread_DefaultStackSize` | A hexadecimal integer that specifies the size of stack | .NET 10 | - ## Minimum threads - Specifies the minimum number of threads for the worker thread pool. From d9cc7464ac9a24adadc6957fe60502a5d53a1599 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 15 Aug 2025 10:12:28 -0700 Subject: [PATCH 3/5] Update docs/core/runtime-config/threading.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/runtime-config/threading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index cde6e9f1cf262..668c1b70aae7a 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -33,7 +33,7 @@ This article details the settings you can use to configure threading in .NET. ## Set the size of stack for VM-created threads -- The default size of stack is dictated by VM and OS policies. +- The default stack size is dictated by .NET and OS policies. The default stack size for .NET apps is 1.5 MB on Windows and macOS, and 8 MB on Linux. The default stack size when .NET runtime is hosted (for example, COM components) is dictated by the hosting process. - This setting allows overriding the default. - The specified size should be between 64 kB and 2 GB and a multiple of the natural allocation granularity of the OS. From 50b6ae07e3cd5a7e82e580c77dadf11223c76aab Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 15 Aug 2025 10:12:51 -0700 Subject: [PATCH 4/5] Update docs/core/runtime-config/threading.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/runtime-config/threading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index 668c1b70aae7a..60f090073fd37 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -34,7 +34,7 @@ This article details the settings you can use to configure threading in .NET. ## Set the size of stack for VM-created threads - The default stack size is dictated by .NET and OS policies. The default stack size for .NET apps is 1.5 MB on Windows and macOS, and 8 MB on Linux. The default stack size when .NET runtime is hosted (for example, COM components) is dictated by the hosting process. -- This setting allows overriding the default. +- This setting allows overriding the default for threads created by .NET runtime. For example, threads created by the API. - The specified size should be between 64 kB and 2 GB and a multiple of the natural allocation granularity of the OS. | | Setting name | Values | Version introduced | From 63c259c23e398b8cfaf7a5bc6683481810672ad1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 15 Aug 2025 10:14:00 -0700 Subject: [PATCH 5/5] Update docs/core/runtime-config/threading.md --- docs/core/runtime-config/threading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/runtime-config/threading.md b/docs/core/runtime-config/threading.md index 60f090073fd37..661ac4edeaa58 100644 --- a/docs/core/runtime-config/threading.md +++ b/docs/core/runtime-config/threading.md @@ -31,7 +31,7 @@ This article details the settings you can use to configure threading in .NET. | **runtimeconfig.json** | N/A | N/A | | **Environment variable** | `COMPlus_Thread_AssignCpuGroups` or `DOTNET_Thread_AssignCpuGroups` | `0` - disabled
`1` - enabled | -## Set the size of stack for VM-created threads +## Set the stack size for threads created by the .NET runtime - The default stack size is dictated by .NET and OS policies. The default stack size for .NET apps is 1.5 MB on Windows and macOS, and 8 MB on Linux. The default stack size when .NET runtime is hosted (for example, COM components) is dictated by the hosting process. - This setting allows overriding the default for threads created by .NET runtime. For example, threads created by the API.