Getting Started with PerfView: A Beginner’s Guide
What PerfView is
PerfView is a free Microsoft tool for collecting and analyzing performance data from .NET applications and Windows systems. It focuses on CPU sampling, memory allocation/GC analysis, and event tracing (ETW).
When to use it
- Investigating high CPU usage or performance regressions
- Finding memory leaks or excessive allocations
- Analyzing startup or long-running operation latency
- Collecting ETW traces for I/O, thread, and system-level events
Quick setup (Windows)
- Download PerfView from the official Microsoft GitHub releases page and unzip.
- Run PerfView.exe (no install required). If UAC blocks collection, run as Administrator when needed.
- Ensure the target app is available and reproduce the performance issue during capture.
Basic workflow
- Capture a trace: click “Collect” → choose options (default is usually fine) → “Start Collection” → run the workload → “Stop Collection.”
- Open the generated .etl file shown in PerfView.
- Use the “CPU Stacks” view to inspect hotspots (stack traces with inclusive/exclusive times).
- Use the “Heap” and “GC Stats” views to analyze allocations, object types, and GC pauses.
- Use “Events” or “Thread Time” for tracing I/O, thread waits, and system events.
Key views explained
- CPU Stacks: shows where CPU time is spent with call stacks and JIT inlining awareness.
- Processes/Threads: overview of thread activity and blocking.
- Heap (GC Heap: Allocation stacks and top allocating types; helpful for finding large or frequent allocations.
- GC Stats: GC pause times and generation details.
- Event Viewer/Events: raw ETW events for advanced investigations.
Practical tips
- Use sampling mode for CPU (lower overhead) and tracing for allocations when you need exact allocation stacks.
- Enable “Include .NET Runtime” and “Clr” providers for richer managed data.
- Symbol files (.pdb) improve stack frame names—point PerfView to symbol servers (Microsoft symbol server + your private symbols).
- Start with a short capture to verify reproducibility, then increase duration as needed.
- Save and share the .etl/.zip file for collaboration.
Common pitfalls
- Capturing too much data can produce large ETL files—filter providers and events.
- Running without symbols yields obfuscated/missing method names.
- Interpreting samples as exact timing—sampling estimates hotspots, not precise per-call durations.
Short checklist to run now
- Download and run PerfView.exe.
- Reproduce the issue.
- Collect a short trace.
- Open CPU Stacks and Heap views.
- Save and inspect the ETL; enable symbols if needed.
Further learning resources
- Official PerfView GitHub README and documentation.
- Microsoft blog posts and sample walkthroughs on .NET performance analysis.