perfview icon indicating copy to clipboard operation
perfview copied to clipboard

Command line for Thread time (with Tasks) Stacks

Open ashishnegi opened this issue 5 years ago • 15 comments

From command line, if I use :

PerfView.exe /BufferSizeMB:1024 /InMemoryCircularBuffer /zip:false /merge:false /circularmb:2048 /nogui /ThreadTime collect perfdetails.etl

And then if I open perfdetails.etl in PerfView, I don’t see Thread time (with Tasks) Stacks. I only see Thread Time Stacks.

What is the command line parameter for generating etl that can show Tasks stack in PerfView ?

ashishnegi avatar Jun 21 '19 19:06 ashishnegi

If, like me, you were looking for the Thread Time checkbox in the UI, it's waaaaayyyy out of sequence. It's near the top. The switch is /threadTime.

See:

image

And:

image

windhandel avatar Jul 08 '21 20:07 windhandel

Same problem here Thread time (with Tasks) Stacks is missing, only Thread Time Stacks...

kirsan31 avatar Mar 26 '22 13:03 kirsan31

@kirsan31, you will also need to enable the TPL events. These are not enabled by default as they are quite verbose and can impact CPU sampling results.

brianrob avatar Apr 01 '22 18:04 brianrob

@brianrob

you will also need to enable the TPL events. These are not enabled by default as they are quite verbose and can impact CPU sampling results.

Yes, sure. I tested it now from gui (with test app + Visual studio running) and have it. But in trace from our app it's absent 🤷‍♂️ Command line was: [EXECUTING: PerfView /DataFile:D:\MMExtData\PerfView\4.81.8091.30106_2022.03.02.11.02.19.etl /Merge:true /zip:true /BufferSizeMB:256 /StackCompression /CircularMB:500 /MaxCollectSec:20 /KernelEvents:ThreadTime /TplEvents:Default /FocusProcess:13748 /logFile=D:\MMExtData\PerfView\perfViewRun.log /AcceptEula collect] image

kirsan31 avatar Apr 01 '22 19:04 kirsan31

Interesting. Are you by chance able to share the trace? It looks like this view should show up as long as you specify /ThreadTime and TPL events.

brianrob avatar Apr 05 '22 21:04 brianrob

@brianrob do you need full trace or only log? If full - can I some how send it to you in private manner?

kirsan31 avatar Apr 06 '22 06:04 kirsan31

Yes, I will need the full trace. Feel free to post it to a site such as OneDrive and then send a link to me at brianrob [at] microsoft.

brianrob avatar Apr 06 '22 16:04 brianrob

Yes, I will need the full trace. Feel free to post it to a site such as OneDrive and then send a link to me at brianrob [at] microsoft.

Sent from golikova at gmail.

kirsan31 avatar Apr 06 '22 17:04 kirsan31

Got it. Thanks.

The issue is that you are capturing the TPL events, but it appears that stacks are not being collected, and this view requires stacks on these events in order to be useful. When I test this on my local machine, I do get the views that you're expecting:

image

Looking at the code, we filter the set of stacks to enable down to just TaskScheduled, TaskWaitSend, and AwaitTaskContinuationScheduled to avoid additional stack walking overhead since this provider is quite verbose. This is done by a Win8+ API that we check for by checking the version number of %Windir%\system32\Kernel32.dll. Given that you captured this trace on Win 10, I have to believe that something is going wrong with this check - perhaps PerfView isn't properly opening the file, or something like that.

One thing that you can try is rather than specifying /TPLEvents:Default, specify /Providers:.NETTasks:0x1ff:@StacksEnabled=true. This will turn on stacks for all of the TPL events, and will bypass the check that seems to be failing on this machine.

brianrob avatar Apr 06 '22 17:04 brianrob

Thank you!

This is done by a Win8+ API that we check for by checking the version number of %Windir%\system32\Kernel32.dll. Given that you captured this trace on Win 10, I have to believe that something is going wrong with this check - perhaps PerfView isn't properly opening the file, or something like that.

Maybe this is due to the fact that we have a rare version of the OS - win 10 for workstation?

kirsan31 avatar Apr 06 '22 18:04 kirsan31

That's a good question - I don't know, and I'm not even quite sure where to get a copy to check.

brianrob avatar Apr 06 '22 19:04 brianrob

That's a good question - I don't know, and I'm not even quite sure where to get a copy to check.

I think I can do some experiments, if you interested and have any ideas about this...

kirsan31 avatar Apr 06 '22 20:04 kirsan31

Yes, if you're able, it would be awesome to see what happens here in a debugger. This line ends up opening kernel32.dll and that's where I think things are going wrong on your machine. If you're able to build a copy of PerfView and debug it, that would be great.

brianrob avatar Apr 07 '22 00:04 brianrob

@brianrob I've build a version from perfview-3.0 branch (because I have only vs2022) with extra debug logging. Result: winDir C:\WINDOWS; kernel32 C:\WINDOWS\system32\Kernel32.dll versionInfo 10.0.19041.1503 (WinBuild.160101.0800) check have passed and Thread time (with Tasks) Stacks is present. Then I reverted to def. version and collected traces several times - Thread time (with Tasks) Stacks was always present. So this is intermittent problem 🤷‍♂️

kirsan31 avatar Apr 09 '22 11:04 kirsan31

Interesting. That one I can't explain...

brianrob avatar Apr 12 '22 17:04 brianrob