Investigating CPU spikes for ASP.NET on Windows
Summary
Googling for solutions usually brings up with suggestions to get one of those CPU profilers like ANTS or JetBrains (or involves Voodoo magic with WinDbg). And while the tool has served us well for many years, it has one huge drawback: to investigate the expensive threads and call stacks it attaches to a process as a "debugger". While PerfView uses Windows built-in ETW ("event tracing") engine that is very efficient, adds little to no overhead, causing zero (0) extra CPU load for an already overwhelmed server. Then it checks if the CPU load is actually higher than 70%, and if it is - it launches PerfView (in the CLI-only mode) and runs it for 4 seconds. Open up an .etl log, and go to "CPU stacks", double click the "w3wp" process and - voila - youll get the list of your most expensive methods inside the app.