Skip to content

Commit 26adb7b

Browse files
committed
[Diagnostics][dotnet-trace] Revamp profiles
1 parent 16053b4 commit 26adb7b

File tree

1 file changed

+43
-22
lines changed

1 file changed

+43
-22
lines changed

docs/core/diagnostics/dotnet-trace.md

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ dotnet-trace collect
8686
[--diagnostic-port]
8787
[-o|--output <trace-file-path>]
8888
[-p|--process-id <pid>]
89-
[--profile <profile-name>]
89+
[--profiles <list-of-comma-separated-profile-names>]
9090
[--providers <list-of-comma-separated-providers>]
9191
[-- <command>] (for target applications running .NET 5 or later)
9292
[--show-child-io]
@@ -211,21 +211,24 @@ dotnet-trace collect
211211
> [!NOTE]
212212
> On Linux and macOS, using this option requires the target application and `dotnet-trace` to share the same `TMPDIR` environment variable. Otherwise, the command will time out.
213213
214-
- **`--profile <profile-name>`**
214+
- **`--profiles <list-of-comma-separated-profile-names>`**
215215

216-
A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly. The following profiles are available:
216+
A comma-separated list of named, pre-defined set of provider configurations for common tracing scenarios. The union of profiles and providers will be in effect.
217+
218+
Default behavior (when `--profiles`, `--providers`, and `--clrevents` are omitted): dotnet-trace enables a useful, low-overhead composition: `dotnet-common` + `dotnet-thread-time`.
219+
220+
Available profiles:
217221

218222
| Profile | Description |
219223
|---------|-------------|
220-
|`dotnet-default`|Combination of `dotnet-thread-time` and `dotnet-clr-default`. This is the default profile used when no other provider/event/profile options are specified.|
221-
|`dotnet-thread-time`|Useful for tracking .NET thread-time information. This is the default profile used when no other provider/event/profile options are specified.|
222-
|`dotnet-clr-default`|Useful for tracking a multitude of .NET events.|
224+
|`dotnet-common`|Lightweight .NET runtime diagnostics (GC, JIT, loader/assembly loader, threading, contention). Designed to stay low overhead.|
225+
|`dotnet-thread-time`|Samples .NET thread stacks (~100 Hz) to identify hotspots over time. Uses the runtime sample profiler with managed stacks.|
223226
|`gc-verbose`|Tracks GC collections and samples object allocations.|
224227
|`gc-collect`|Tracks GC collections only at very low overhead.|
225228

226229
- **`--providers <list-of-comma-separated-providers>`**
227230

228-
A comma-separated list of `EventPipe` providers to be enabled. These providers supplement any providers implied by `--profile <profile-name>`. If there's any inconsistency for a particular provider, this configuration takes precedence over the implicit configuration from the profile.
231+
A comma-separated list of `EventPipe` providers to be enabled. These providers supplement any providers implied by `--profiles <list-of-comma-separated-profile-names>`. If there's any inconsistency for a particular provider, this configuration takes precedence over the implicit configuration from the profiles.
229232

230233
This list of providers is in the form:
231234

@@ -278,6 +281,19 @@ Collects diagnostic traces using perf_events, a Linux OS technology. `collect-li
278281

279282
This Linux-only command includes the same .NET events as [`dotnet-trace collect`](#dotnet-trace-collect), and it uses the kernel’s user_events mechanism to emit .NET events as perf events, enabling unification of user-space .NET events with kernel-space system events.
280283

284+
### Default collection behavior
285+
286+
When `--profiles`, `--clrevents`, and `--providers` aren’t specified, `collect-linux` enables the default `profile` providing the comprehensive composition:
287+
288+
- `dotnet-common` — lightweight .NET runtime diagnostics.
289+
- `dotnet-thread-time` — runtime thread stack sampling.
290+
- `kernel-cpu` — kernel CPU sampling (perf-based) via `Universal.Events/cpu`.
291+
- `kernel-cswitch` — kernel context switches via `Universal.Events/cswitch` for on/off-CPU analysis.
292+
293+
By default, a machine-wide trace will be collected. .NET Processes are discovered through their diagnostics ports, which are located under the `TMPDIR` environment variable when set and otherwise under `/tmp`. `dotnet-trace` will need to share the same `TMPDIR` value as .NET Processes of interest, otherwise events will not be collected from those processes.
294+
295+
If collecting events from all .NET Processes is undesired, `-n, --name <name>` or `-p|--process-id <PID>` can be used to specify a particular process. **NOTE**: Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
296+
281297
### Prerequisites
282298

283299
- Linux kernel with `CONFIG_USER_EVENTS=y` support (kernel 6.4+)
@@ -295,7 +311,7 @@ dotnet-trace collect-linux
295311
[--clreventlevel <clreventlevel>]
296312
[--clrevents <clrevents>]
297313
[--perf-event-tracepoints <list-of-perf-event-tracepoints>]
298-
[--profile <profile-name>]
314+
[--profiles <list-of-comma-separated-profile-names>]
299315
300316
# Trace Collection
301317
[--format <Chromium|NetTrace|Speedscope>]
@@ -315,7 +331,7 @@ dotnet-trace collect-linux
315331

316332
- **`--providers <list-of-comma-separated-providers>`**
317333

318-
A comma-separated list of `EventPipe` providers to be enabled. These providers supplement any providers implied by `--profile <profile-name>`. If there's any inconsistency for a particular provider, this configuration takes precedence over the implicit configuration from the profile.
334+
A comma-separated list of `EventPipe` providers to be enabled. These providers supplement any providers implied by `--profiles <list-of-comma-separated-profile-names>`. If there's any inconsistency for a particular provider, this configuration takes precedence over the implicit configuration from the specified profiles.
319335

320336
This list of providers is in the form:
321337

@@ -393,18 +409,24 @@ dotnet-trace collect-linux
393409

394410
Example: `--perf-event-tracepoints syscalls:sys_enter_execve,sched:sched_switch,sched:sched_wakeup`
395411

396-
- **`--profile <profile-name>`**
412+
- **`--profiles <list-of-comma-separated-profile-names>`**
413+
414+
A named, pre-defined set of provider configurations for common tracing scenarios. You can specify multiple profiles as a comma-separated list. When multiple profiles are specified, the providers and settings are combined (union), and duplicates are ignored.
397415

398-
A named pre-defined set of provider configurations that allows common tracing scenarios to be specified succinctly. The following profiles are available:
416+
Available profiles:
399417

400418
| Profile | Description |
401419
|---------|-------------|
402-
|`dotnet-default`|Combination of `dotnet-thread-time` and `dotnet-clr-default`. This is the default profile used when no other provider/event/profile options are specified.|
403-
|`dotnet-thread-time`|Useful for tracking .NET thread-time information. This is the default profile used when no other provider/event/profile options are specified.|
404-
|`dotnet-clr-default`|Useful for tracking a multitude of .NET events.|
420+
|`dotnet-common`|Lightweight .NET runtime diagnostics (GC, JIT, loader/assembly loader, threading, contention). Designed to stay low overhead.|
421+
|`dotnet-thread-time`|Samples .NET thread stacks (~100 Hz) to identify hotspots over time. Uses the runtime sample profiler with managed stacks.|
422+
|`kernel-cpu`|Kernel CPU sampling (perf-based), emitted as `Universal.Events/cpu`, for precise on-CPU attribution.|
423+
|`kernel-cswitch`|Kernel thread context switches, emitted as `Universal.Events/cswitch`, for on/off-CPU and scheduler analysis.|
424+
|`kernel-precise-thread-time`|Combines `kernel-cpu` + `kernel-cswitch` for a precise thread-time view using kernel events only.|
405425
|`gc-verbose`|Tracks GC collections and samples object allocations.|
406426
|`gc-collect`|Tracks GC collections only at very low overhead.|
407-
|`cpu-sampling`|Useful for tracking CPU usage.|
427+
428+
> [!NOTE]
429+
> The former default `cpu-sampling` profile is now named as `dotnet-thread-time`.
408430
409431
#### Trace Collection Options
410432

@@ -422,22 +444,21 @@ dotnet-trace collect-linux
422444

423445
#### .NET Process Target Options
424446

425-
> ![NOTE]
426-
> The default behavior for collect-linux is to collect .NET events and perf event tracepoints from ALL discoverable processes.
447+
See [Default collection behavior](#default-collection-behavior)
427448

428449
- **`-n, --name <name>`**
429450

430451
The name of the process to collect the trace from.
431452

432453
> [!NOTE]
433-
> By default, `/tmp` will be searched to discover .NET processes diagnostics ports. Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
454+
> Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
434455
435456
- **`-p|--process-id <PID>`**
436457

437458
The process ID to collect the trace from.
438459

439460
> [!NOTE]
440-
> By default, `/tmp` will be searched to discover .NET processes diagnostics ports. Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
461+
> Should the target application have a `TMPDIR` enviornment variable set, `dotnet-trace` will need to share the same `TMPDIR` value, otherwise events will not be collected from the target application.
441462
442463
- **`-- <command>`**
443464

@@ -600,11 +621,11 @@ dotnet-trace collect -- hello.exe arg1 arg2
600621
The preceding command generates output similar to the following:
601622

602623
```output
603-
No profile or providers specified, defaulting to trace profile 'cpu-sampling'
624+
No profile or providers specified. Using default composition: dotnet-common + dotnet-thread-time
604625
605626
Provider Name Keywords Level Enabled By
606-
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
607-
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
627+
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profiles
628+
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profiles
608629
609630
Process : E:\temp\gcperfsim\bin\Debug\net5.0\gcperfsim.exe
610631
Output File : E:\temp\gcperfsim\trace.nettrace

0 commit comments

Comments
 (0)