Tools

Diagnosing thread pool starvation from a .NET dump with an AI agent

Gérald Barré (Meziantou's blog) Gérald Barré
Tools

Gérald Barré walks through diagnosing thread pool starvation — slow responses with an idle CPU and no obviously slow query — by feeding a dotnet-counters timeline and a dotnet-dump dump to an AI agent. Having the agent merge hundreds of identical stacks is where the workflow saves real time.

Key points

  • Collect a 20-second `--format json` counters timeline plus a `--type Heap` dump; a Full dump already hits 1.6 GB here.
  • Counter names ending in `/ N sec` are deltas per interval, not absolute values — misreading them describes a healthy pool.
  • The `threadpool` command settles it: 184 workers, 184 running, 0 idle, 0% CPU.
  • `parallelstacks` collapses 184 near-identical stacks and shows `Task<T>.GetResultCore` and `QueueUserWorkItemCallbackDefaultContext.Execute()` with counts.
  • `dumpasync --stats` reports 184 pending `GetCustomerAsync` state machines, closing the loop.
  • The fix is `await` instead of `.Result`; `ThreadPool.SetMinThreads` only buys time and leaves the cause in place.

Real-world use

  • An ASP.NET Core service that gets slow under load while CPU stays near zero
  • MVC actions or constructors that block a pool thread through `.Result` or `.Wait()`
  • Separating a genuine slow dependency from the sync-over-async bug it exposes
  • Summarizing hundreds of similar stacks from a production dump instead of scrolling by hand

This summary was generated by the agent from the original post on Gérald Barré (Meziantou's blog). The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message