microsoft / vcperf

A build analysis tool for the MSVC toolchain.
MIT License
296 stars 35 forks source link

Feature request: flag for starting vcperf regardless of previous trace #50

Open zsd4yr opened 6 days ago

zsd4yr commented 6 days ago

If there is already a vcperf trace running, you cannot start a new one. This is problematic for scenarios where the trace itself can be interrruputed, like during a scheduled restart. The output shows a way to shut down the last session, but I would love to avoid jumping through the hoops to find the windows sdk install dir, find the latest version, find tracelog.exe, call it, grep the output to find the name of the previous session, and finally call vcperf /stop and wait for the trace to save to a file, even if you don't care about it at all. The last session is completely useless to me.

Current:

vcperf /start SessionName Microsoft (R) Visual C++ (R) Performance Analyzer 2.2.22080401 Starting tracing session AllZoe... Failed to start trace. A trace that is currently being collected on your system is preventing vcperf from starting a new one. This can occur if you forgot to stop a vcperf trace prior to running the start command, or if processes other than vcperf have started ETW traces of their own. Please try running the vcperf /stop or /stopnoanalyze commands on your previously started trace. If you do not remember the session name that was used for starting a previous vcperf trace, or if you don't recall starting one at all, you can use the 'tracelog -l' command from an elevated command prompt to list all ongoing tracing sessions on your system. Your currently ongoing vcperf trace will show up as MSVC_BUILD_INSIGHTSSESSION<session name that was passed to vcperf /start>. You can then issue a vcperf /stop or /stopnoanalyze command with the identified session name (the part between the angle brackets). If no MSVC_BUILD_INSIGHTSSESSION is found, it could mean a kernel ETW trace is currently being collected. This trace will show up as 'NT Kernel Logger' in your tracelog output, and will also prevent you from starting a new trace. You can stop the 'NT Kernel Logger' session by running 'xperf -stop' from an elevated command prompt.

I'd like a flag I can pair with vcperf /start to throw away whatever state vcperf might already have and whatever session is currently being tracked immediately.

Desired:

vcperf /start SessionName /force Microsoft (R) Visual C++ (R) Performance Analyzer 2.2.22080401 Found previous session PreviousSessionName. Force option will throw away this trace. If you want to avoid this behavior, remove the force flag. Starting tracing session SessionName... Tracing session started successfully!

zsd4yr commented 6 days ago

Probably this would involving adding this flag to TRACING_SESSION_OPTIONS struct

zsd4yr commented 6 days ago

Just making notes incase anyone comes here later -- in powershell, using Stop-EtwTraceSession "MSVC_BUILD_INSIGHTS_SESSION_*" from https://learn.microsoft.com/en-us/powershell/module/eventtracingmanagement/stop-etwtracesession is waaaaaaay easier