From 0c0c4469e3502b5df666f6f48ef59c5175835e74 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 27 Apr 2026 19:56:03 +0200 Subject: [PATCH 1/4] DOTNET_EventPipeThreadSamplingRate --- docs/core/diagnostics/dotnet-trace.md | 3 +++ docs/core/runtime-config/debugging-profiling.md | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/core/diagnostics/dotnet-trace.md b/docs/core/diagnostics/dotnet-trace.md index 2f5a53de22f71..8322bb5847260 100644 --- a/docs/core/diagnostics/dotnet-trace.md +++ b/docs/core/diagnostics/dotnet-trace.md @@ -233,6 +233,9 @@ dotnet-trace collect |--------------|----------------------------------------------------------| | `dotnet-common` | Lightweight .NET runtime diagnostics designed to stay low overhead.
Includes GC, AssemblyLoader, Loader, JIT, Exceptions, Threading, JittedMethodILToNativeMap, and Compilation events
Equivalent to `--providers "Microsoft-Windows-DotNETRuntime:0x100003801D:4"`. | | `dotnet-sampled-thread-time` | Samples .NET thread stacks (~100 Hz) to identify hotspots over time. Uses the runtime sample profiler with managed stacks. | + + > [!TIP] + > The sampling rate used by `dotnet-sampled-thread-time` can be changed with the `DOTNET_EventPipeThreadSamplingRate` environment variable (value in milliseconds). This setting is process-global and affects all EventPipe sessions. See [EventPipe thread sampling rate](../runtime-config/debugging-profiling.md#eventpipe-thread-sampling-rate) for details. | `gc-verbose` | Tracks GC collections and samples object allocations. | | `gc-collect` | Tracks GC collections only at very low overhead. | | `database` | Captures ADO.NET and Entity Framework database commands. | diff --git a/docs/core/runtime-config/debugging-profiling.md b/docs/core/runtime-config/debugging-profiling.md index 8cf36fbd94f48..7f48ce5725cb2 100644 --- a/docs/core/runtime-config/debugging-profiling.md +++ b/docs/core/runtime-config/debugging-profiling.md @@ -81,6 +81,17 @@ The following table compares perf maps and jit maps. | **runtimeconfig.json** | N/A | N/A | | **Environment variable** | `DOTNET_PerfMapEnabled` | `0` - disabled
`1` - perf maps and jit dumps both enabled
`2` - jit dumps enabled
`3` - perf maps enabled | +## EventPipe thread sampling rate + +- Overrides the default interval for the EventPipe thread time sampling profiler. The value is specified in milliseconds. +- When set to `0` (or omitted), the runtime uses its built-in default (1 ms on most platforms, 5 ms on WebAssembly). +- This setting is process-global: it affects **all** EventPipe sessions in the process, including on-demand traces collected by tools such as [dotnet-trace](../diagnostics/dotnet-trace.md). There is currently no way to configure a per-session sampling rate. Setting a very large interval will reduce the resolution of any `dotnet-trace` session started later. + +| | Setting name | Values | +|--------------------------|-----------------------------------------|-----------------------------------------------| +| **runtimeconfig.json** | N/A | N/A | +| **Environment variable** | `DOTNET_EventPipeThreadSamplingRate` | Interval in milliseconds. `0` = use default. | + ## Perf log markers - Enables or disables the specified signal to be accepted and ignored as a marker in the perf logs. From ce938adcb9d0bfd8b6f53091edb3a7f6ffa70300 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Mon, 27 Apr 2026 20:00:40 +0200 Subject: [PATCH 2/4] more --- docs/core/diagnostics/eventpipe.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/core/diagnostics/eventpipe.md b/docs/core/diagnostics/eventpipe.md index 2c43045032866..81192d258e412 100644 --- a/docs/core/diagnostics/eventpipe.md +++ b/docs/core/diagnostics/eventpipe.md @@ -84,6 +84,8 @@ However, you can use the following environment variables to set up an EventPipe * `DOTNET_EventPipeProcNumbers`: Set this to `1` to enable capturing processor numbers in EventPipe event headers. The default value is `0`. +* `DOTNET_EventPipeThreadSamplingRate`: Sets the interval, in milliseconds, for the EventPipe thread time sampling profiler. When set to `0` or omitted, the runtime uses its built-in default (1 ms on most platforms, 5 ms on WebAssembly). This setting is process-global and affects all EventPipe sessions, including on-demand traces started by tools such as [dotnet-trace](./dotnet-trace.md). Setting a large value reduces sampling overhead but also reduces the resolution of any trace collected during the process lifetime. + * `DOTNET_EventPipeConfig`: Sets up the EventPipe session configuration when starting an EventPipe session with `DOTNET_EnableEventPipe`. The syntax is as follows: From a46dbad9c045a46e0b15eba7b6e641b49a27f96d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Tue, 28 Apr 2026 21:18:37 +0200 Subject: [PATCH 3/4] feedback --- docs/core/diagnostics/dotnet-trace.md | 2 +- docs/core/diagnostics/eventpipe.md | 2 +- docs/core/runtime-config/debugging-profiling.md | 11 +---------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/core/diagnostics/dotnet-trace.md b/docs/core/diagnostics/dotnet-trace.md index 8322bb5847260..7c6e9be38f960 100644 --- a/docs/core/diagnostics/dotnet-trace.md +++ b/docs/core/diagnostics/dotnet-trace.md @@ -235,7 +235,7 @@ dotnet-trace collect | `dotnet-sampled-thread-time` | Samples .NET thread stacks (~100 Hz) to identify hotspots over time. Uses the runtime sample profiler with managed stacks. | > [!TIP] - > The sampling rate used by `dotnet-sampled-thread-time` can be changed with the `DOTNET_EventPipeThreadSamplingRate` environment variable (value in milliseconds). This setting is process-global and affects all EventPipe sessions. See [EventPipe thread sampling rate](../runtime-config/debugging-profiling.md#eventpipe-thread-sampling-rate) for details. + > The sampling rate used by `dotnet-sampled-thread-time` can be changed with the `DOTNET_EventPipeThreadSamplingRate` environment variable (value in milliseconds). This setting is process-global and affects all EventPipe sessions. See [Trace using environment variables](./eventpipe.md#trace-using-environment-variables) for details. | `gc-verbose` | Tracks GC collections and samples object allocations. | | `gc-collect` | Tracks GC collections only at very low overhead. | | `database` | Captures ADO.NET and Entity Framework database commands. | diff --git a/docs/core/diagnostics/eventpipe.md b/docs/core/diagnostics/eventpipe.md index 81192d258e412..960263ec36449 100644 --- a/docs/core/diagnostics/eventpipe.md +++ b/docs/core/diagnostics/eventpipe.md @@ -84,7 +84,7 @@ However, you can use the following environment variables to set up an EventPipe * `DOTNET_EventPipeProcNumbers`: Set this to `1` to enable capturing processor numbers in EventPipe event headers. The default value is `0`. -* `DOTNET_EventPipeThreadSamplingRate`: Sets the interval, in milliseconds, for the EventPipe thread time sampling profiler. When set to `0` or omitted, the runtime uses its built-in default (1 ms on most platforms, 5 ms on WebAssembly). This setting is process-global and affects all EventPipe sessions, including on-demand traces started by tools such as [dotnet-trace](./dotnet-trace.md). Setting a large value reduces sampling overhead but also reduces the resolution of any trace collected during the process lifetime. +* `DOTNET_EventPipeThreadSamplingRate`: Available in .NET 11+. Sets the interval, in milliseconds, for the EventPipe thread time sampling profiler. When set to `0` or omitted, the runtime uses its built-in default of 10 ms (~100 Hz). This setting is process-global and affects all EventPipe sessions, including on-demand traces started by tools such as [dotnet-trace](./dotnet-trace.md). Setting a large value reduces sampling overhead but also reduces the resolution of any trace collected during the process lifetime. * `DOTNET_EventPipeConfig`: Sets up the EventPipe session configuration when starting an EventPipe session with `DOTNET_EnableEventPipe`. The syntax is as follows: diff --git a/docs/core/runtime-config/debugging-profiling.md b/docs/core/runtime-config/debugging-profiling.md index 7f48ce5725cb2..42c0fa52e130a 100644 --- a/docs/core/runtime-config/debugging-profiling.md +++ b/docs/core/runtime-config/debugging-profiling.md @@ -81,16 +81,7 @@ The following table compares perf maps and jit maps. | **runtimeconfig.json** | N/A | N/A | | **Environment variable** | `DOTNET_PerfMapEnabled` | `0` - disabled
`1` - perf maps and jit dumps both enabled
`2` - jit dumps enabled
`3` - perf maps enabled | -## EventPipe thread sampling rate - -- Overrides the default interval for the EventPipe thread time sampling profiler. The value is specified in milliseconds. -- When set to `0` (or omitted), the runtime uses its built-in default (1 ms on most platforms, 5 ms on WebAssembly). -- This setting is process-global: it affects **all** EventPipe sessions in the process, including on-demand traces collected by tools such as [dotnet-trace](../diagnostics/dotnet-trace.md). There is currently no way to configure a per-session sampling rate. Setting a very large interval will reduce the resolution of any `dotnet-trace` session started later. - -| | Setting name | Values | -|--------------------------|-----------------------------------------|-----------------------------------------------| -| **runtimeconfig.json** | N/A | N/A | -| **Environment variable** | `DOTNET_EventPipeThreadSamplingRate` | Interval in milliseconds. `0` = use default. | +For EventPipe-related environment variables (including `DOTNET_EventPipeThreadSamplingRate`), see [Trace using environment variables](../diagnostics/eventpipe.md#trace-using-environment-variables). ## Perf log markers From 641896245e93edd8a35cd741b544a6570e993d60 Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 29 Apr 2026 08:06:45 +0200 Subject: [PATCH 4/4] Update docs/core/runtime-config/debugging-profiling.md Co-authored-by: Jan Kotas --- docs/core/runtime-config/debugging-profiling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/runtime-config/debugging-profiling.md b/docs/core/runtime-config/debugging-profiling.md index 42c0fa52e130a..bdd35a89ce9b5 100644 --- a/docs/core/runtime-config/debugging-profiling.md +++ b/docs/core/runtime-config/debugging-profiling.md @@ -81,7 +81,7 @@ The following table compares perf maps and jit maps. | **runtimeconfig.json** | N/A | N/A | | **Environment variable** | `DOTNET_PerfMapEnabled` | `0` - disabled
`1` - perf maps and jit dumps both enabled
`2` - jit dumps enabled
`3` - perf maps enabled | -For EventPipe-related environment variables (including `DOTNET_EventPipeThreadSamplingRate`), see [Trace using environment variables](../diagnostics/eventpipe.md#trace-using-environment-variables). +For EventPipe-related environment variables, see [Trace using environment variables](../diagnostics/eventpipe.md#trace-using-environment-variables). ## Perf log markers