VS 2022 CPU profiling not giving meaningful results when using TPL Dataflow

452 views Asked by At

I am trying to figure out where my bottlenecks are in an application that uses TPL Dataflow, and I'm not finding any meaningful results. When I break in my application and look at the CPU usage this is what I'm seeing.

MyPipelinePopulator (PID 12345) 100%`
[External Call] System.Threading.ThreadPoolWorkQueue.Dispatch() 99.65%
[Unwalkable] 0.34%

My pipeline isn't that complex and consists of three blocks, a batch block to collect data into batches, a processing transform block that can be run concurrently and out of order, and a writing action block that can't run concurrently and must run in order.

I'm assuming that most of my CPU time is spent in the processing block, and I was wanting a breakdown of time spent there, but saying that 99.65% of the CPU time is spent in the ThreadPoolWorkQueue Dispatch is not very helpful.

Is there a way to configure my project so that CPU Usage shows something more helpful?

1

There are 1 answers

1
TJR On

I was able to get useful CPU profiling information by going to Debug -> Performance Profiler... and then starting the project with CPU Usage checked.

The first time I did this, the diagnostic session failed to start and just sat waiting forever for the diagnostic session to start.

I found the solution to that problem on Microsoft's forums https://learn.microsoft.com/en-us/answers/questions/592556/diagnostics-session-failed-to-start and apparently there is a service Visual Studio Standard Collector Service 150 that is sometimes disabled or in my case set to manually start, and it wasn't started. After manually starting that service, then the diagnostic session was able to start.