[Development] FW: Tracing for applications

Adam Light aclight at gmail.com
Tue Dec 10 15:53:43 CET 2019


On Mon, Dec 9, 2019 at 1:06 PM Lukast dev <lukast.dev at gmail.com> wrote:

> But stack sampling sometimes sucks because you don't see if the function
> was called million times and thus it shows up in the profile
> or it is called once and is expensive and thus it shows up as hot spot.
> That's the benefit of tracing where you see number of calls and also
> can observe some meta data about the traced event like current memory
> consumption or any other counter you are interested in.
>
>
With respect to ETW tracing on Windows, it's not clear to me that you
really even need to be able to emit your own data.

I just wrote a post about ETW in a thread on the Qt Interest mailing list (
https://lists.qt-project.org/pipermail/interest/2019-December/034275.html).
As long as you have PDB symbol files available for the Qt libraries and
your own application, you can use the data collected with the default
settings of UIforETW to do most performance related analysis. You can
easily see if a function was called a million times or if it was called
once and was just slow. There is definitely a learning curve on the
analysis side, but as I mentioned in my other post there are a lot of
really good tutorials and examples of how to analyze the data.

You might want to emit your own tracing data if you want to store specific
intervals where it is not otherwise straightforward to measure the length
of the interval by looking at function calls, or if you want to store some
data to help you interpret the profiling information better (eg. size of
some object like a QImage). If you do need to emit your own tracing data,
it's not that difficult to do this yourself, at least with ETW.

The "old" way of doing this is crazy complicated. The overview
documentation is at
https://docs.microsoft.com/en-us/windows-hardware/test/weg/instrumenting-your-code-with-etw
.

But if you only need to emit data when running on Windows 10 and can meet a
few other requirements, you can use the much simpler approach described at
https://docs.microsoft.com/en-us/windows/win32/tracelogging/tracelogging-native-quick-start.
This is what is being used in the Qt commit you pointed out earlier. Here
are a couple other links that I found helpful using the tracelogging
features:
https://blogs.msdn.microsoft.com/dcook/2015/09/08/etw-provider-names-and-guids/
https://github.com/tpn/winsdk-10/blob/master/Include/10.0.14393.0/shared/TraceLoggingProvider.h


If you decide to go this route and are using UIforETW to collect your
traces, you can easily configure it to record the data from your own
provider. Here are the notes in our sources for how to do this:
// To record data from this provider, I use UIforETW. Click the Settings
button
// and in the "Extra user mode providers:" field, enter:
// *MyTraceLoggingProvider
// Note that the "*" is required.

MyTraceLoggingProvider is the name you use in the call
to TRACELOGGING_DEFINE_PROVIDER.

Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20191210/be45d722/attachment.html>


More information about the Development mailing list