@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,84 @@
|
|
|
1
|
+
# dotnet-trace collect-linux (.NET 10+)
|
|
2
|
+
|
|
3
|
+
**Purpose**: Collects diagnostic traces using `perf_events`, a Linux OS technology. Provides native call stacks, kernel events, and machine-wide tracing that standard `dotnet-trace collect` cannot.
|
|
4
|
+
|
|
5
|
+
| Attribute | Value |
|
|
6
|
+
|-----------|-------|
|
|
7
|
+
| OS | Linux only (kernel >= 6.4 with `CONFIG_USER_EVENTS=y`) |
|
|
8
|
+
| Runtime | .NET 10+ only |
|
|
9
|
+
| .NET Framework | ❌ Not supported |
|
|
10
|
+
| Admin required | Yes (root) |
|
|
11
|
+
| Container | Works inside container (requires root) |
|
|
12
|
+
| glibc | >= 2.35 (not supported on Alpine 3.22, CentOS Stream 9, or RHEL 9-based distros) |
|
|
13
|
+
|
|
14
|
+
## Key Differences from `dotnet-trace collect`
|
|
15
|
+
|
|
16
|
+
| Feature | `collect` | `collect-linux` |
|
|
17
|
+
|---------|-----------|-----------------|
|
|
18
|
+
| Trace all processes simultaneously | No | Yes (default — no PID required) |
|
|
19
|
+
| Capture native library and kernel events | No | Yes |
|
|
20
|
+
| Event callstacks include native frames | No | Yes |
|
|
21
|
+
| Requires admin/root | No | Yes |
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Machine-wide trace (all processes, no PID needed)
|
|
27
|
+
sudo dotnet-trace collect-linux
|
|
28
|
+
|
|
29
|
+
# Trace a specific process
|
|
30
|
+
sudo dotnet-trace collect-linux -p <PID>
|
|
31
|
+
|
|
32
|
+
# Trace a process by name
|
|
33
|
+
sudo dotnet-trace collect-linux -n <process-name>
|
|
34
|
+
|
|
35
|
+
# Trace for a specific duration
|
|
36
|
+
sudo dotnet-trace collect-linux --duration 00:00:30
|
|
37
|
+
|
|
38
|
+
# Trace with specific providers
|
|
39
|
+
sudo dotnet-trace collect-linux --providers Microsoft-Windows-DotNETRuntime
|
|
40
|
+
|
|
41
|
+
# Trace with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
42
|
+
sudo dotnet-trace collect-linux --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
43
|
+
|
|
44
|
+
# Trace with networking providers and thread-time profile
|
|
45
|
+
sudo dotnet-trace collect-linux --profile thread-time --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
46
|
+
|
|
47
|
+
# Trace with specific profiles
|
|
48
|
+
sudo dotnet-trace collect-linux --profile gc-verbose
|
|
49
|
+
sudo dotnet-trace collect-linux --profile thread-time
|
|
50
|
+
|
|
51
|
+
# Trace with additional Linux perf events
|
|
52
|
+
sudo dotnet-trace collect-linux --perf-events <list-of-perf-events>
|
|
53
|
+
|
|
54
|
+
# Output to a specific file
|
|
55
|
+
sudo dotnet-trace collect-linux -o /tmp/trace.nettrace
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When `--providers`, `--profile`, `--clrevents`, and `--perf-events` are not specified, `collect-linux` enables these profiles by default: `dotnet-common` (lightweight .NET runtime diagnostics) and `cpu-sampling` (kernel CPU sampling).
|
|
59
|
+
|
|
60
|
+
## Container Usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Inside container (machine-wide — captures all processes in the container)
|
|
64
|
+
sudo dotnet-trace collect-linux -o /tmp/trace.nettrace
|
|
65
|
+
|
|
66
|
+
# Inside container (specific process)
|
|
67
|
+
sudo dotnet-trace collect-linux -p 1 -o /tmp/trace.nettrace
|
|
68
|
+
|
|
69
|
+
# Copy trace out
|
|
70
|
+
kubectl cp <pod>:/tmp/trace.nettrace ./trace.nettrace
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Trade-offs
|
|
74
|
+
|
|
75
|
+
- ✅ Machine-wide tracing without specifying a PID
|
|
76
|
+
- ✅ Native (unmanaged) call stacks — essential for diagnosing native interop or runtime issues
|
|
77
|
+
- ✅ Captures kernel events and native library events
|
|
78
|
+
- ✅ Designed for Linux-first workflows
|
|
79
|
+
- ❌ Requires root privileges
|
|
80
|
+
- ❌ Only available on .NET 10 and later
|
|
81
|
+
- ❌ Linux only (kernel >= 6.4)
|
|
82
|
+
- ❌ Requires glibc >= 2.35 (not all supported Linux distros qualify)
|
|
83
|
+
- ❌ Native code symbols must be present on disk next to the binary (or in a standard location) during trace capture for symbol resolution
|
|
84
|
+
- ❌ Unable to trace cross-namespace processes
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# dotnet-trace collect
|
|
2
|
+
|
|
3
|
+
**Purpose**: Collect EventPipe traces for CPU profiling, event analysis, and runtime diagnostics.
|
|
4
|
+
|
|
5
|
+
| Attribute | Value |
|
|
6
|
+
|-----------|-------|
|
|
7
|
+
| OS | Windows, Linux, macOS |
|
|
8
|
+
| Runtime | Modern .NET (.NET Core 3.0+) |
|
|
9
|
+
| .NET Framework | ❌ Not supported |
|
|
10
|
+
| Admin required | No |
|
|
11
|
+
| Container | Works inside container; use `--diagnostic-port` for sidecar |
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# As a .NET global tool (requires .NET SDK)
|
|
17
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
18
|
+
dotnet tool install -g dotnet-trace
|
|
19
|
+
|
|
20
|
+
# Direct download via aka.ms (no SDK required — useful in containers)
|
|
21
|
+
# Linux x64
|
|
22
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
23
|
+
curl -JL https://aka.ms/dotnet-trace/linux-x64 -o dotnet-trace
|
|
24
|
+
chmod +x dotnet-trace
|
|
25
|
+
|
|
26
|
+
# Linux Arm64
|
|
27
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
28
|
+
curl -JL https://aka.ms/dotnet-trace/linux-arm64 -o dotnet-trace
|
|
29
|
+
chmod +x dotnet-trace
|
|
30
|
+
|
|
31
|
+
# Linux musl x64 (Alpine)
|
|
32
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
33
|
+
curl -JL https://aka.ms/dotnet-trace/linux-musl-x64 -o dotnet-trace
|
|
34
|
+
chmod +x dotnet-trace
|
|
35
|
+
|
|
36
|
+
# Windows x64
|
|
37
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
38
|
+
curl -JL https://aka.ms/dotnet-trace/win-x64 -o dotnet-trace.exe
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Common Commands
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# List running .NET processes
|
|
45
|
+
dotnet-trace ps
|
|
46
|
+
|
|
47
|
+
# Collect a trace with the default profiles (dotnet-common and dotnet-sampled-thread-time)
|
|
48
|
+
dotnet-trace collect -p <PID>
|
|
49
|
+
|
|
50
|
+
# Collect with a specific profile
|
|
51
|
+
dotnet-trace collect -p <PID> --profile dotnet-sampled-thread-time
|
|
52
|
+
dotnet-trace collect -p <PID> --profile gc-verbose
|
|
53
|
+
|
|
54
|
+
# Collect with specific providers
|
|
55
|
+
dotnet-trace collect -p <PID> --providers Microsoft-DotNETCore-SampleProfiler,Microsoft-Windows-DotNETRuntime
|
|
56
|
+
|
|
57
|
+
# Collect with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
58
|
+
dotnet-trace collect -p <PID> --providers System.Net.Http,System.Net.NameResolution,System.Net.Security,System.Net.Sockets
|
|
59
|
+
|
|
60
|
+
# Collect for a fixed duration (time span in hh:mm:ss format)
|
|
61
|
+
dotnet-trace collect -p <PID> --duration 00:00:30
|
|
62
|
+
|
|
63
|
+
# Output in Speedscope format for web-based viewing
|
|
64
|
+
dotnet-trace collect -p <PID> --format speedscope
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Output Formats
|
|
68
|
+
|
|
69
|
+
| Format | Extension | Analysis Tool |
|
|
70
|
+
|--------|-----------|---------------|
|
|
71
|
+
| `nettrace` (default) | `.nettrace` | PerfView, Visual Studio, `dotnet-trace report` |
|
|
72
|
+
| `speedscope` | `.speedscope.json` | Speedscope |
|
|
73
|
+
| `chromium` | `.chromium.json` | Chrome DevTools (chrome://tracing) |
|
|
74
|
+
|
|
75
|
+
## Container Usage
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Inside container (process is typically PID 1)
|
|
79
|
+
dotnet-trace collect -p 1 -o /tmp/trace.nettrace
|
|
80
|
+
|
|
81
|
+
# Copy trace out of container
|
|
82
|
+
kubectl cp <pod>:/tmp/trace.nettrace ./trace.nettrace
|
|
83
|
+
# or
|
|
84
|
+
docker cp <container>:/tmp/trace.nettrace ./trace.nettrace
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Trade-offs
|
|
88
|
+
|
|
89
|
+
- ✅ Cross-platform, no admin needed, lightweight
|
|
90
|
+
- ❌ No native (unmanaged) call stacks — only managed frames
|
|
91
|
+
- ❌ Less system-level detail than ETW (PerfView) or perf (perfcollect)
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# perfcollect
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Installation
|
|
6
|
+
- Common Commands
|
|
7
|
+
- Container Usage
|
|
8
|
+
- Kubernetes Usage
|
|
9
|
+
- Analyzing perfcollect Output
|
|
10
|
+
- Trade-offs
|
|
11
|
+
|
|
12
|
+
**Purpose**: Wrapper script for `perf` and `LTTng` on Linux. Collects CPU profiles with native call stacks.
|
|
13
|
+
|
|
14
|
+
> **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
15
|
+
|
|
16
|
+
| Attribute | Value |
|
|
17
|
+
|-----------|-------|
|
|
18
|
+
| OS | Linux only |
|
|
19
|
+
| Runtime | Modern .NET (.NET Core 2.0+) |
|
|
20
|
+
| .NET Framework | ❌ Not supported |
|
|
21
|
+
| Admin required | Yes (root) |
|
|
22
|
+
| Container | Needs `SYS_ADMIN` / `--privileged` |
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Download the script
|
|
28
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
29
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
30
|
+
curl -OL https://aka.ms/perfcollect
|
|
31
|
+
chmod +x perfcollect
|
|
32
|
+
|
|
33
|
+
# Install prerequisites (perf, LTTng)
|
|
34
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
35
|
+
sudo ./perfcollect install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Common Commands
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Collect a trace (runs until Ctrl+C)
|
|
42
|
+
sudo ./perfcollect collect mytrace
|
|
43
|
+
|
|
44
|
+
# Collect for a specific duration
|
|
45
|
+
sudo timeout 30 ./perfcollect collect mytrace
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Container Usage
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Docker — run with privileged mode
|
|
52
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
53
|
+
docker run --privileged ...
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Kubernetes Usage
|
|
57
|
+
|
|
58
|
+
In Kubernetes, use a **diagnostics sidecar container** to avoid modifying your application image. The sidecar runs alongside your app, shares its process namespace and `/tmp` directory, and contains the diagnostic tools.
|
|
59
|
+
|
|
60
|
+
### Step 1: Add a privileged diagnostics sidecar
|
|
61
|
+
|
|
62
|
+
Add a diagnostics container to your deployment and mark it as privileged:
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
- name: diagnostics-container
|
|
66
|
+
image: ubuntu
|
|
67
|
+
command: ["/bin/sh", "-c", "sleep infinity"]
|
|
68
|
+
securityContext:
|
|
69
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
70
|
+
privileged: true
|
|
71
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
72
|
+
allowPrivilegeEscalation: true
|
|
73
|
+
volumeMounts:
|
|
74
|
+
- name: shared-tmp
|
|
75
|
+
mountPath: /tmp
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 2: Enable shared process namespace
|
|
79
|
+
|
|
80
|
+
Set `shareProcessNamespace: true` in the pod spec so the sidecar can see and profile the app's processes:
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
spec:
|
|
84
|
+
shareProcessNamespace: true
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Step 3: Share /tmp between containers
|
|
88
|
+
|
|
89
|
+
Create an `emptyDir` volume mounted at `/tmp` in both the app and sidecar containers. This is needed for perf map files (`perf-$pid.map`), perfcollect logs, and other profiling artifacts:
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
volumes:
|
|
93
|
+
- name: shared-tmp
|
|
94
|
+
emptyDir: {}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Mount it in both containers:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
volumeMounts:
|
|
101
|
+
- name: shared-tmp
|
|
102
|
+
mountPath: /tmp
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 4: Set environment variables in the app container
|
|
106
|
+
|
|
107
|
+
Enable perf map generation and LTTng event logging in the application container:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
env:
|
|
111
|
+
- name: COMPlus_PerfMapEnabled
|
|
112
|
+
value: "1"
|
|
113
|
+
- name: COMPlus_EnableEventLog
|
|
114
|
+
value: "1"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Step 5: Collect the trace
|
|
118
|
+
|
|
119
|
+
Connect to the cluster node, exec into the diagnostics sidecar, install perfcollect, and capture:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Exec into the diagnostics sidecar
|
|
123
|
+
kubectl exec -it <pod-name> -c diagnostics-container -- /bin/bash
|
|
124
|
+
|
|
125
|
+
# Inside the sidecar: install perfcollect
|
|
126
|
+
# Cratis: Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
127
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
128
|
+
curl -OL https://aka.ms/perfcollect
|
|
129
|
+
chmod +x perfcollect
|
|
130
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
131
|
+
./perfcollect install
|
|
132
|
+
|
|
133
|
+
# Capture a trace
|
|
134
|
+
./perfcollect collect mytrace
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This produces `mytrace.trace.zip`, which can be copied out and analyzed.
|
|
138
|
+
|
|
139
|
+
### End-to-end Kubernetes deployment example
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
apiVersion: apps/v1
|
|
143
|
+
kind: Deployment
|
|
144
|
+
metadata:
|
|
145
|
+
name: sample
|
|
146
|
+
spec:
|
|
147
|
+
replicas: 1
|
|
148
|
+
selector:
|
|
149
|
+
matchLabels:
|
|
150
|
+
app: sample
|
|
151
|
+
template:
|
|
152
|
+
metadata:
|
|
153
|
+
labels:
|
|
154
|
+
app: sample
|
|
155
|
+
spec:
|
|
156
|
+
shareProcessNamespace: true
|
|
157
|
+
volumes:
|
|
158
|
+
- name: shared-tmp
|
|
159
|
+
emptyDir: {}
|
|
160
|
+
containers:
|
|
161
|
+
- name: sample-app
|
|
162
|
+
image: myapp:latest
|
|
163
|
+
ports:
|
|
164
|
+
- containerPort: 80
|
|
165
|
+
env:
|
|
166
|
+
- name: COMPlus_PerfMapEnabled
|
|
167
|
+
value: "1"
|
|
168
|
+
- name: COMPlus_EnableEventLog
|
|
169
|
+
value: "1"
|
|
170
|
+
volumeMounts:
|
|
171
|
+
- name: shared-tmp
|
|
172
|
+
mountPath: /tmp
|
|
173
|
+
- name: diagnostics-container
|
|
174
|
+
image: ubuntu
|
|
175
|
+
command: ["/bin/sh", "-c", "sleep infinity"]
|
|
176
|
+
securityContext:
|
|
177
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
178
|
+
privileged: true
|
|
179
|
+
# Cratis: Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
180
|
+
allowPrivilegeEscalation: true
|
|
181
|
+
volumeMounts:
|
|
182
|
+
- name: shared-tmp
|
|
183
|
+
mountPath: /tmp
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Analyzing perfcollect Output
|
|
187
|
+
|
|
188
|
+
The output is a `*.trace.zip` file containing `perf.data.nl`. To analyze:
|
|
189
|
+
|
|
190
|
+
1. Copy the `.trace.zip` to a Windows machine
|
|
191
|
+
2. Open with PerfView — it can read perfcollect output and display flame graphs
|
|
192
|
+
|
|
193
|
+
## Trade-offs
|
|
194
|
+
|
|
195
|
+
- ✅ Captures native (unmanaged) call stacks — essential for diagnosing native interop or runtime issues
|
|
196
|
+
- ✅ Uses kernel-level `perf` for accurate CPU profiling
|
|
197
|
+
- ❌ Requires root/admin privileges
|
|
198
|
+
- ❌ Linux only
|
|
199
|
+
> **Cratis:** Requires the user's explicit approval: downloads and runs a script as root / changes container security.
|
|
200
|
+
- ❌ In containers, requires `SYS_ADMIN` or `--privileged`
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# PerfView
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Installation
|
|
6
|
+
- Common Commands
|
|
7
|
+
- Trigger Arguments for Long-Running Repros
|
|
8
|
+
- Windows Container Usage
|
|
9
|
+
- Trade-offs
|
|
10
|
+
|
|
11
|
+
**Purpose**: ETW-based tracing on Windows. The richest diagnostic tool for .NET on Windows.
|
|
12
|
+
|
|
13
|
+
| Attribute | Value |
|
|
14
|
+
|-----------|-------|
|
|
15
|
+
| OS | Windows only |
|
|
16
|
+
| Runtime | .NET Framework ✅, Modern .NET ✅ |
|
|
17
|
+
| Admin required | Yes |
|
|
18
|
+
| Container | ✅ Windows containers (Hyper-V and process-isolation) |
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
> **Cratis:** Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
23
|
+
Download from [https://github.com/microsoft/perfview/releases](https://github.com/microsoft/perfview/releases). PerfView is a standalone `.exe` — no installation required.
|
|
24
|
+
|
|
25
|
+
## Common Commands
|
|
26
|
+
|
|
27
|
+
Always include `/BufferSizeMB:1024 /CircularMB:2048` for short traces to ensure adequate buffer space.
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
# Collect a CPU trace (default providers)
|
|
31
|
+
PerfView collect /BufferSizeMB:1024 /CircularMB:2048
|
|
32
|
+
|
|
33
|
+
# Collect for slow request / latency investigation (ThreadTime adds thread-level wait/block detail)
|
|
34
|
+
PerfView /ThreadTime collect /BufferSizeMB:1024 /CircularMB:2048
|
|
35
|
+
|
|
36
|
+
# Collect with GC and allocation events
|
|
37
|
+
PerfView collect /GCCollectOnly /BufferSizeMB:1024 /CircularMB:2048
|
|
38
|
+
|
|
39
|
+
# Collect with specific providers
|
|
40
|
+
PerfView collect /Providers:Microsoft-Windows-DotNETRuntime /BufferSizeMB:1024 /CircularMB:2048
|
|
41
|
+
|
|
42
|
+
# Collect with networking providers (HTTP status codes, DNS, TLS, sockets)
|
|
43
|
+
PerfView /ThreadTime collect /BufferSizeMB:1024 /CircularMB:2048 /Providers:*System.Net.Http,*System.Net.NameResolution,*System.Net.Security,*System.Net.Sockets
|
|
44
|
+
|
|
45
|
+
# Collect with Kestrel/ASP.NET providers for slow inbound requests
|
|
46
|
+
PerfView /ThreadTime collect /BufferSizeMB:1024 /CircularMB:2048 /Providers:*Microsoft.AspNetCore.Hosting,*Microsoft-AspNetCore-Server-Kestrel
|
|
47
|
+
|
|
48
|
+
# Collect for a specific duration (seconds)
|
|
49
|
+
PerfView collect /MaxCollectSec:30 /BufferSizeMB:1024 /CircularMB:2048
|
|
50
|
+
|
|
51
|
+
# Collect from command line without GUI
|
|
52
|
+
PerfView /nogui collect /MaxCollectSec:30 /BufferSizeMB:1024 /CircularMB:2048
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Trigger Arguments for Long-Running Repros
|
|
56
|
+
|
|
57
|
+
When the issue takes a long time to reproduce, use trigger arguments with a circular buffer to capture the issue without generating huge trace files.
|
|
58
|
+
|
|
59
|
+
**Important**: The `/StopOn` trigger should fire on the **symptom you want to capture** — not on the recovery. PerfView uses a circular buffer (`/CircularMB`) that continuously overwrites old data, so the most recent data before the stop trigger fires is what gets preserved. When a `/StopOn` trigger fires, PerfView checks the condition a few times over several seconds before actually stopping, so the trigger event and surrounding context are reliably captured.
|
|
60
|
+
|
|
61
|
+
Use `/StartOn` only when you know the start event happens **before** the stop event (e.g., to avoid recording idle time before the issue begins). If in doubt, omit `/StartOn` and just use `/StopOn` with a circular buffer.
|
|
62
|
+
|
|
63
|
+
**Note**: For **slow requests**, do not include a stop trigger by default — the right trigger depends on the specific scenario. Provide the collection command without a trigger and let the user design one based on what they're seeing.
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
# Stop when CPU spikes — captures the high-CPU window
|
|
67
|
+
PerfView collect /StopOnPerfCounter:"Processor:% Processor Time:_Total>80" /BufferSizeMB:2048 /CircularMB:4096
|
|
68
|
+
|
|
69
|
+
# Stop on a GC event (e.g. Gen2 collection)
|
|
70
|
+
PerfView collect /StopOnGCEvent /BufferSizeMB:2048 /CircularMB:4096
|
|
71
|
+
|
|
72
|
+
# Stop when a specific exception is thrown (not recommended for memory leaks — capture during growth instead)
|
|
73
|
+
PerfView collect /StopOnException:"System.OutOfMemoryException" /BufferSizeMB:2048 /CircularMB:4096
|
|
74
|
+
|
|
75
|
+
# StartOn + StopOn — only when the start event is known to precede the stop event
|
|
76
|
+
# Here: start recording when CPU goes above 50%, stop when the spike hits 90%
|
|
77
|
+
PerfView collect /StartOnPerfCounter:"Processor:% Processor Time:_Total>50" /StopOnPerfCounter:"Processor:% Processor Time:_Total>90" /BufferSizeMB:2048 /CircularMB:4096
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Key trigger parameters:
|
|
81
|
+
|
|
82
|
+
| Parameter | Description |
|
|
83
|
+
|-----------|-------------|
|
|
84
|
+
| `/StopOnPerfCounter:"Category:Counter:Instance>Threshold"` | Stop when a performance counter crosses a threshold. **Use this on the symptom you want to capture.** |
|
|
85
|
+
| `/StartOnPerfCounter:"Category:Counter:Instance>Threshold"` | Start collection when a counter crosses a threshold. Only use when you know this fires before the stop trigger. |
|
|
86
|
+
| `/StopOnGCEvent` | Stop when a GC event occurs |
|
|
87
|
+
| `/StopOnException:"ExceptionType"` | Stop when a specific exception is thrown |
|
|
88
|
+
| `/BufferSizeMB:N` | In-memory buffer size (increase for long collections) |
|
|
89
|
+
| `/CircularMB:N` | Circular log size on disk (keeps only the last N MB of data) |
|
|
90
|
+
|
|
91
|
+
## Windows Container Usage
|
|
92
|
+
|
|
93
|
+
PerfView works with both types of Windows containers. Most Windows containers (including Kubernetes on Windows) use **process-isolation** by default.
|
|
94
|
+
|
|
95
|
+
> **Cratis:** Downloads or installs a tool: requires the user's approval; prefer a pinned version (`dotnet tool install <tool> --version <x>`)
|
|
96
|
+
> **PerfView inside containers**: `PerfView.exe` does not run in many slimmed-down Windows container images. To run PerfView inside a container (needed for the merge step in process-isolation, or for direct collection in Hyper-V), build **PerfViewCollect** from [https://github.com/microsoft/perfview](https://github.com/microsoft/perfview) as a self-contained publish, then copy the output binaries into the container.
|
|
97
|
+
|
|
98
|
+
### Process-isolation containers (default)
|
|
99
|
+
|
|
100
|
+
Process-isolation containers share the host kernel. Collect from **outside** the container (on the host) using `/EnableEventsInContainers`:
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
# On the host — captures all processes including those inside containers
|
|
104
|
+
PerfView collect /EnableEventsInContainers /MaxCollectSec:30 /BufferSizeMB:1024 /CircularMB:2048
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The resulting trace can be analyzed immediately on the host while the container is still running — PerfView can reach into the container to fetch binaries for symbol resolution.
|
|
108
|
+
|
|
109
|
+
**To analyze on another machine**, you must complete a merge step inside the container **before the container shuts down**. Without this, binaries inside the container won't have their symbol lookup information saved in the trace:
|
|
110
|
+
|
|
111
|
+
```powershell
|
|
112
|
+
# 1. Copy the .etl.zip into the container
|
|
113
|
+
docker cp trace.etl.zip <container>:C:\trace.etl.zip
|
|
114
|
+
|
|
115
|
+
# 2. Inside the container — complete the merge to embed symbol info
|
|
116
|
+
PerfViewCollect merge /ImageIDsOnly C:\trace.etl.zip
|
|
117
|
+
|
|
118
|
+
# 3. Copy the merged trace back out
|
|
119
|
+
docker cp <container>:C:\trace.etl.zip ./trace-merged.etl.zip
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The merged trace can now be analyzed on any machine with full symbol resolution. If you skip the in-container merge step, symbols for binaries that live only inside the container will be unresolvable on other machines because the Windows merge component cannot reach into the container's filesystem.
|
|
123
|
+
|
|
124
|
+
### Hyper-V containers
|
|
125
|
+
|
|
126
|
+
Hyper-V containers are less common and are effectively lightweight VMs. Collect traces from **inside** the container the same way you would on a regular machine:
|
|
127
|
+
|
|
128
|
+
```powershell
|
|
129
|
+
# Inside the Hyper-V container
|
|
130
|
+
PerfView collect /MaxCollectSec:30 /BufferSizeMB:1024 /CircularMB:2048
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Trade-offs
|
|
134
|
+
|
|
135
|
+
- ✅ Richest diagnostic data available on Windows (ETW kernel + CLR providers)
|
|
136
|
+
- ✅ Works with both .NET Framework and modern .NET
|
|
137
|
+
- ✅ Powerful trigger system for capturing hard-to-reproduce issues
|
|
138
|
+
- ✅ Works with Windows containers (Hyper-V and process-isolation)
|
|
139
|
+
- ❌ Windows only
|
|
140
|
+
- ❌ Requires admin privileges
|
|
141
|
+
- ⚠️ **For .NET Framework without admin**: PerfView is the only trace tool for .NET Framework, and it requires admin. Without admin, there is **no way to investigate high CPU, slow requests, or excessive GC** on .NET Framework. Dumps can help with hangs and memory leaks (delegate to the `dump-collect` skill), but trace-based investigation requires admin access.
|