@cratis/pi 7.102.0 → 7.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
- package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
- package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
- package/package/corpus/hooks/README.md +11 -1
- package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
- package/package/corpus/rules/profiles.md +10 -1
- package/package/corpus/rules/pull-requests.md +2 -0
- package/package/corpus/rules/secrets.md +4 -0
- package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
- package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
- package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
- package/package/corpus/skills/binlog-generation/LICENSE +23 -0
- package/package/corpus/skills/binlog-generation/NOTICE +22 -0
- package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
- package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
- package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
- package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
- package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
- package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
- package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
- package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
- package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
- package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
- package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
- package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
- package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
- package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
- package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
- package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
- package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
- package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
- package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
- package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
- package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
- package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
- package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
- package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
- package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
- package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
- package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
- package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
- package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
- package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
- package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
- package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
- package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
- package/package/corpus/skills/dump-collect/LICENSE +23 -0
- package/package/corpus/skills/dump-collect/NOTICE +40 -0
- package/package/corpus/skills/dump-collect/SKILL.md +97 -0
- package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
- package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
- package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
- package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
- package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
- package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
- package/package/corpus/skills/extension-points/LICENSE +23 -0
- package/package/corpus/skills/extension-points/NOTICE +18 -0
- package/package/corpus/skills/extension-points/SKILL.md +248 -0
- package/package/corpus/skills/filter-syntax/LICENSE +23 -0
- package/package/corpus/skills/filter-syntax/NOTICE +17 -0
- package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
- package/package/corpus/skills/including-generated-files/LICENSE +23 -0
- package/package/corpus/skills/including-generated-files/NOTICE +17 -0
- package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
- package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
- package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
- package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
- package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
- package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
- package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
- package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
- package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
- package/package/corpus/skills/msbuild/LICENSE +23 -0
- package/package/corpus/skills/msbuild/NOTICE +55 -0
- package/package/corpus/skills/msbuild/SKILL.md +117 -0
- package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
- package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
- package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
- package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
- package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
- package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
- package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
- package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
- package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
- package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
- package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
- package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
- package/package/corpus/skills/orleans/LICENSE +21 -0
- package/package/corpus/skills/orleans/NOTICE +64 -0
- package/package/corpus/skills/orleans/SKILL.md +140 -0
- package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
- package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
- package/package/corpus/skills/orleans/references/examples.md +66 -0
- package/package/corpus/skills/orleans/references/grain-api.md +784 -0
- package/package/corpus/skills/orleans/references/grains.md +75 -0
- package/package/corpus/skills/orleans/references/hosting.md +71 -0
- package/package/corpus/skills/orleans/references/implementation.md +591 -0
- package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
- package/package/corpus/skills/orleans/references/patterns.md +811 -0
- package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
- package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
- package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
- package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
- package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
- package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
- package/package/corpus/skills/platform-detection/LICENSE +23 -0
- package/package/corpus/skills/platform-detection/NOTICE +17 -0
- package/package/corpus/skills/platform-detection/SKILL.md +230 -0
- package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
- package/package/corpus/skills/profiling/LICENSE +21 -0
- package/package/corpus/skills/profiling/NOTICE +50 -0
- package/package/corpus/skills/profiling/SKILL.md +144 -0
- package/package/corpus/skills/profiling/references/commands.md +439 -0
- package/package/corpus/skills/profiling/references/patterns.md +586 -0
- package/package/corpus/skills/profiling/references/profiling.md +190 -0
- package/package/corpus/skills/run-tests/LICENSE +23 -0
- package/package/corpus/skills/run-tests/NOTICE +19 -0
- package/package/corpus/skills/run-tests/SKILL.md +305 -0
- package/package/corpus/skills/target-authoring/LICENSE +23 -0
- package/package/corpus/skills/target-authoring/NOTICE +17 -0
- package/package/corpus/skills/target-authoring/SKILL.md +165 -0
- package/package/corpus/skills/vectorization/LICENSE +23 -0
- package/package/corpus/skills/vectorization/NOTICE +17 -0
- package/package/corpus/skills/vectorization/SKILL.md +189 -0
- package/package/profile-catalog.json +85 -1
- package/package.json +1 -1
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
# .NET Profiling CLI Commands Reference
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Tool Installation
|
|
6
|
+
- dotnet-counters
|
|
7
|
+
- dotnet-trace
|
|
8
|
+
- dotnet-dump
|
|
9
|
+
- dotnet-gcdump
|
|
10
|
+
- Process Discovery
|
|
11
|
+
- Environment Variables for Diagnostics
|
|
12
|
+
- CI/CD Integration
|
|
13
|
+
|
|
14
|
+
This reference covers the official .NET diagnostics CLI tools for profiling and runtime investigation.
|
|
15
|
+
|
|
16
|
+
## Tool Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install all profiling tools globally
|
|
20
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
21
|
+
dotnet tool install --global dotnet-counters --version <x>
|
|
22
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
23
|
+
dotnet tool install --global dotnet-trace --version <x>
|
|
24
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
25
|
+
dotnet tool install --global dotnet-dump --version <x>
|
|
26
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
27
|
+
dotnet tool install --global dotnet-gcdump --version <x>
|
|
28
|
+
|
|
29
|
+
# Verify installations
|
|
30
|
+
dotnet-counters --version
|
|
31
|
+
dotnet-trace --version
|
|
32
|
+
dotnet-dump --version
|
|
33
|
+
dotnet-gcdump --version
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## dotnet-counters
|
|
39
|
+
|
|
40
|
+
Real-time monitoring of .NET runtime metrics and custom counters.
|
|
41
|
+
|
|
42
|
+
### List Available Counters
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Find a target process, then monitor the selected counters
|
|
46
|
+
dotnet-counters ps
|
|
47
|
+
dotnet-counters monitor --process-id <PID> --counters System.Runtime
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Monitor Live Counters
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Monitor System.Runtime counters
|
|
54
|
+
dotnet-counters monitor --process-id <PID> --counters System.Runtime
|
|
55
|
+
|
|
56
|
+
# Monitor with custom refresh interval (in seconds)
|
|
57
|
+
dotnet-counters monitor --process-id <PID> --refresh-interval 2
|
|
58
|
+
|
|
59
|
+
# Monitor multiple counter providers
|
|
60
|
+
dotnet-counters monitor --process-id <PID> \
|
|
61
|
+
--counters System.Runtime,Microsoft.AspNetCore.Hosting
|
|
62
|
+
|
|
63
|
+
# Monitor specific counters from a provider
|
|
64
|
+
dotnet-counters monitor --process-id <PID> \
|
|
65
|
+
--counters "System.Runtime[cpu-usage,working-set,gc-heap-size]"
|
|
66
|
+
|
|
67
|
+
# Monitor by process name (attach to first match)
|
|
68
|
+
dotnet-counters monitor --name MyApp --counters System.Runtime
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Collect Counters to File
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Collect counters to CSV
|
|
75
|
+
dotnet-counters collect --process-id <PID> \
|
|
76
|
+
--counters System.Runtime \
|
|
77
|
+
--output counters.csv \
|
|
78
|
+
--format csv
|
|
79
|
+
|
|
80
|
+
# Collect counters to JSON
|
|
81
|
+
dotnet-counters collect --process-id <PID> \
|
|
82
|
+
--counters System.Runtime \
|
|
83
|
+
--output counters.json \
|
|
84
|
+
--format json
|
|
85
|
+
|
|
86
|
+
# Collect for a specific duration (in seconds)
|
|
87
|
+
dotnet-counters collect --process-id <PID> \
|
|
88
|
+
--counters System.Runtime \
|
|
89
|
+
--output counters.csv \
|
|
90
|
+
--format csv \
|
|
91
|
+
--duration 60
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Common Counter Providers
|
|
95
|
+
|
|
96
|
+
| Provider | Description |
|
|
97
|
+
|----------|-------------|
|
|
98
|
+
| `System.Runtime` | GC, thread pool, exception, and general runtime metrics |
|
|
99
|
+
| `Microsoft.AspNetCore.Hosting` | ASP.NET Core request metrics |
|
|
100
|
+
| `Microsoft.AspNetCore.Http.Connections` | SignalR connection metrics |
|
|
101
|
+
| `System.Net.Http` | HTTP client metrics |
|
|
102
|
+
| `System.Net.Sockets` | Socket-level metrics |
|
|
103
|
+
| `Microsoft.EntityFrameworkCore` | EF Core query and save metrics |
|
|
104
|
+
|
|
105
|
+
### Key System.Runtime Counters
|
|
106
|
+
|
|
107
|
+
| Counter | Description |
|
|
108
|
+
|---------|-------------|
|
|
109
|
+
| `cpu-usage` | CPU usage percentage |
|
|
110
|
+
| `working-set` | Working set memory in MB |
|
|
111
|
+
| `gc-heap-size` | GC heap size in MB |
|
|
112
|
+
| `gen-0-gc-count` | Generation 0 GC count |
|
|
113
|
+
| `gen-1-gc-count` | Generation 1 GC count |
|
|
114
|
+
| `gen-2-gc-count` | Generation 2 GC count |
|
|
115
|
+
| `threadpool-thread-count` | Thread pool thread count |
|
|
116
|
+
| `threadpool-queue-length` | Thread pool work item queue length |
|
|
117
|
+
| `exception-count` | Number of exceptions thrown |
|
|
118
|
+
| `alloc-rate` | Allocation rate in bytes per second |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## dotnet-trace
|
|
123
|
+
|
|
124
|
+
Collect detailed performance traces for CPU profiling, events, and diagnostics.
|
|
125
|
+
|
|
126
|
+
### List Running .NET Processes
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
dotnet-trace ps
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### List Available Profiles
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
dotnet-trace list-profiles
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Collect Traces
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Collect with default profile (cpu-sampling)
|
|
142
|
+
dotnet-trace collect --process-id <PID>
|
|
143
|
+
|
|
144
|
+
# Collect with specific profile
|
|
145
|
+
dotnet-trace collect --process-id <PID> --profile cpu-sampling
|
|
146
|
+
|
|
147
|
+
# Collect with multiple profiles
|
|
148
|
+
dotnet-trace collect --process-id <PID> \
|
|
149
|
+
--profile cpu-sampling \
|
|
150
|
+
--profile gc-verbose
|
|
151
|
+
|
|
152
|
+
# Collect for a specific duration (in seconds)
|
|
153
|
+
dotnet-trace collect --process-id <PID> \
|
|
154
|
+
--duration 00:00:30
|
|
155
|
+
|
|
156
|
+
# Collect with custom output path
|
|
157
|
+
dotnet-trace collect --process-id <PID> \
|
|
158
|
+
--output mytrace.nettrace
|
|
159
|
+
|
|
160
|
+
# Collect with specific providers
|
|
161
|
+
dotnet-trace collect --process-id <PID> \
|
|
162
|
+
--providers "Microsoft-DotNETCore-SampleProfiler,Microsoft-Windows-DotNETRuntime"
|
|
163
|
+
|
|
164
|
+
# Collect with high-frequency CPU sampling
|
|
165
|
+
dotnet-trace collect --process-id <PID> \
|
|
166
|
+
--profile cpu-sampling \
|
|
167
|
+
--clrevents gc,jit,exception,contention
|
|
168
|
+
|
|
169
|
+
# Attach to process by name
|
|
170
|
+
dotnet-trace collect --name MyApp
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Built-in Profiles
|
|
174
|
+
|
|
175
|
+
| Profile | Description |
|
|
176
|
+
|---------|-------------|
|
|
177
|
+
| `cpu-sampling` | CPU sampling for hotspot analysis |
|
|
178
|
+
| `gc-verbose` | Detailed GC events |
|
|
179
|
+
| `gc-collect` | GC collection events only |
|
|
180
|
+
| `none` | No predefined providers (use --providers) |
|
|
181
|
+
|
|
182
|
+
### Convert Trace Format
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Convert to SpeedScope format for web viewer
|
|
186
|
+
dotnet-trace convert mytrace.nettrace --format Speedscope
|
|
187
|
+
|
|
188
|
+
# Convert to Chromium format
|
|
189
|
+
dotnet-trace convert mytrace.nettrace --format Chromium
|
|
190
|
+
|
|
191
|
+
# Convert with custom output
|
|
192
|
+
dotnet-trace convert mytrace.nettrace \
|
|
193
|
+
--format Speedscope \
|
|
194
|
+
--output mytrace.speedscope.json
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Common Provider Keywords
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Detailed GC events
|
|
201
|
+
--providers "Microsoft-Windows-DotNETRuntime:0x1:5"
|
|
202
|
+
|
|
203
|
+
# JIT compilation events
|
|
204
|
+
--providers "Microsoft-Windows-DotNETRuntime:0x10:5"
|
|
205
|
+
|
|
206
|
+
# Exception events
|
|
207
|
+
--providers "Microsoft-Windows-DotNETRuntime:0x8000:5"
|
|
208
|
+
|
|
209
|
+
# Contention events
|
|
210
|
+
--providers "Microsoft-Windows-DotNETRuntime:0x4000:5"
|
|
211
|
+
|
|
212
|
+
# Thread pool events
|
|
213
|
+
--providers "Microsoft-Windows-DotNETRuntime:0x10000:5"
|
|
214
|
+
|
|
215
|
+
# All runtime events (verbose)
|
|
216
|
+
--providers "Microsoft-Windows-DotNETRuntime:0xFFFFFFFFFFFFFFFF:5"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## dotnet-dump
|
|
222
|
+
|
|
223
|
+
Capture and analyze memory dumps for debugging crashes and memory issues.
|
|
224
|
+
|
|
225
|
+
### Collect Dumps
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Collect a full memory dump
|
|
229
|
+
dotnet-dump collect --process-id <PID>
|
|
230
|
+
|
|
231
|
+
# Collect with specific dump type
|
|
232
|
+
dotnet-dump collect --process-id <PID> --type Full
|
|
233
|
+
dotnet-dump collect --process-id <PID> --type Heap
|
|
234
|
+
dotnet-dump collect --process-id <PID> --type Mini
|
|
235
|
+
|
|
236
|
+
# Collect with custom output path
|
|
237
|
+
dotnet-dump collect --process-id <PID> \
|
|
238
|
+
--output mydump.dmp
|
|
239
|
+
|
|
240
|
+
# Collect from process by name
|
|
241
|
+
dotnet-dump collect --name MyApp
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Dump Types
|
|
245
|
+
|
|
246
|
+
| Type | Description |
|
|
247
|
+
|------|-------------|
|
|
248
|
+
| `Full` | Complete process memory (largest) |
|
|
249
|
+
| `Heap` | GC heap and type information |
|
|
250
|
+
| `Mini` | Minimal dump with stack traces |
|
|
251
|
+
|
|
252
|
+
### Analyze Dumps
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Start interactive analysis
|
|
256
|
+
dotnet-dump analyze mydump.dmp
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Analysis Commands (Interactive)
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Show all managed threads
|
|
263
|
+
clrthreads
|
|
264
|
+
|
|
265
|
+
# Show call stacks for all threads
|
|
266
|
+
clrstack -all
|
|
267
|
+
|
|
268
|
+
# Show call stack for current thread
|
|
269
|
+
clrstack
|
|
270
|
+
|
|
271
|
+
# Show exceptions on all threads
|
|
272
|
+
pe -all
|
|
273
|
+
|
|
274
|
+
# Dump heap statistics
|
|
275
|
+
dumpheap -stat
|
|
276
|
+
|
|
277
|
+
# Dump heap by type
|
|
278
|
+
dumpheap -type System.String
|
|
279
|
+
|
|
280
|
+
# Dump specific object
|
|
281
|
+
dumpobj <address>
|
|
282
|
+
|
|
283
|
+
# Find GC roots for an object
|
|
284
|
+
gcroot <address>
|
|
285
|
+
|
|
286
|
+
# Dump method table
|
|
287
|
+
dumpmt <address>
|
|
288
|
+
|
|
289
|
+
# Dump module information
|
|
290
|
+
dumpmodule <address>
|
|
291
|
+
|
|
292
|
+
# Show GC heap information
|
|
293
|
+
gcheapstat
|
|
294
|
+
|
|
295
|
+
# Show finalizer queue
|
|
296
|
+
finalizequeue
|
|
297
|
+
|
|
298
|
+
# Show sync blocks (locks)
|
|
299
|
+
syncblk
|
|
300
|
+
|
|
301
|
+
# Exit analysis
|
|
302
|
+
exit
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Scripted Analysis
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Run commands from a script
|
|
309
|
+
dotnet-dump analyze mydump.dmp --command "clrthreads" --command "dumpheap -stat"
|
|
310
|
+
|
|
311
|
+
# Output to file
|
|
312
|
+
dotnet-dump analyze mydump.dmp --command "dumpheap -stat" > heap-stats.txt
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## dotnet-gcdump
|
|
318
|
+
|
|
319
|
+
Capture GC heap snapshots for memory analysis without full dumps.
|
|
320
|
+
|
|
321
|
+
### Collect GC Dumps
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
# Collect GC dump
|
|
325
|
+
dotnet-gcdump collect --process-id <PID>
|
|
326
|
+
|
|
327
|
+
# Collect with custom output
|
|
328
|
+
dotnet-gcdump collect --process-id <PID> \
|
|
329
|
+
--output myheap.gcdump
|
|
330
|
+
|
|
331
|
+
# Collect with timeout (in seconds)
|
|
332
|
+
dotnet-gcdump collect --process-id <PID> \
|
|
333
|
+
--timeout 60
|
|
334
|
+
|
|
335
|
+
# Collect by process name
|
|
336
|
+
dotnet-gcdump collect --name MyApp
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Generate Heap Reports
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
# Generate report to console
|
|
343
|
+
dotnet-gcdump report myheap.gcdump
|
|
344
|
+
|
|
345
|
+
# Generate report with specific type filter
|
|
346
|
+
dotnet-gcdump report myheap.gcdump --type System.String
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Important Notes
|
|
350
|
+
|
|
351
|
+
- GC dumps cause a GC and briefly pause the process
|
|
352
|
+
- Smaller than full memory dumps
|
|
353
|
+
- Captures type information and reference graphs
|
|
354
|
+
- Open `.gcdump` files in Visual Studio or PerfView for analysis
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Process Discovery
|
|
359
|
+
|
|
360
|
+
### Find .NET Process IDs
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# List all .NET processes with dotnet-trace
|
|
364
|
+
dotnet-trace ps
|
|
365
|
+
|
|
366
|
+
# List all .NET processes with dotnet-counters
|
|
367
|
+
dotnet-counters ps
|
|
368
|
+
|
|
369
|
+
# Platform-specific alternatives
|
|
370
|
+
# Linux/macOS
|
|
371
|
+
ps aux | grep dotnet
|
|
372
|
+
|
|
373
|
+
# Windows PowerShell
|
|
374
|
+
Get-Process | Where-Object { $_.ProcessName -like "*dotnet*" }
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Environment Variables for Diagnostics
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
# Enable diagnostic port (for sidecar collection)
|
|
383
|
+
export DOTNET_DiagnosticPorts=/tmp/diag.sock
|
|
384
|
+
|
|
385
|
+
# Enable startup diagnostics
|
|
386
|
+
export DOTNET_StartupHooks=/path/to/hook.dll
|
|
387
|
+
|
|
388
|
+
# Force GC server mode
|
|
389
|
+
export DOTNET_gcServer=1
|
|
390
|
+
|
|
391
|
+
# Enable GC stress testing
|
|
392
|
+
export DOTNET_GCStress=0x3
|
|
393
|
+
|
|
394
|
+
# Enable ETW events on Windows
|
|
395
|
+
export DOTNET_PerfMapEnabled=1
|
|
396
|
+
|
|
397
|
+
# Enable perf maps on Linux
|
|
398
|
+
export DOTNET_EnableEventLog=1
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## CI/CD Integration
|
|
404
|
+
|
|
405
|
+
### Capture Startup Trace
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Start app with trace collection from launch
|
|
409
|
+
dotnet-trace collect \
|
|
410
|
+
--output startup-trace.nettrace \
|
|
411
|
+
-- dotnet run --project MyApp.csproj
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Automated Counter Collection
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
#!/bin/bash
|
|
418
|
+
# Collect counters during load test
|
|
419
|
+
APP_PID=$(dotnet-trace ps | grep MyApp | awk '{print $1}')
|
|
420
|
+
|
|
421
|
+
dotnet-counters collect \
|
|
422
|
+
--process-id $APP_PID \
|
|
423
|
+
--counters System.Runtime,Microsoft.AspNetCore.Hosting \
|
|
424
|
+
--output load-test-counters.csv \
|
|
425
|
+
--format csv \
|
|
426
|
+
--duration 300
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Automated Dump on Crash
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Configure automatic dump collection
|
|
433
|
+
export DOTNET_DbgEnableMiniDump=1
|
|
434
|
+
export DOTNET_DbgMiniDumpType=4
|
|
435
|
+
export DOTNET_DbgMiniDumpName=/tmp/coredump.%p
|
|
436
|
+
|
|
437
|
+
# Run application
|
|
438
|
+
dotnet run
|
|
439
|
+
```
|