[Development] FW: Tracing for applications
Arnaud Clère
arnaud.clere at moulinarso.fr
Fri Dec 6 19:12:32 CET 2019
> -----Original Message-----
> From: Milian Wolff <mail at milianw.de>
>
> On Mittwoch, 4. Dezember 2019 12:23:00 CET Lukast dev wrote:
> > is there some Qt solution for producing traces used for performance
> > analysis?
> >
> > There is on-going work for LTTNG and ETW in Qt I noticed, e.g. here
> > https://codereview.qt-project.org/c/qt/qtbase/+/185287. Can that
> > solution be re-used in Qt applications?
> > If so, is there some documentation for this?
>
> We at KDAB are currently experimenting with this inside Qt itself.
> As such, we aren't confident enough to publish what we have as public API yet.
> That said, I would more than welcome more eyes on this.
> There is no documentation other than the sources.
> If you have any concrete questions, don't hesitate to ask.
It looks to me like tracegen can indeed be used from inside users
applications using the commit as an example.
With tracegen, you define tracepoints in an external file that is
translated to very efficient code that will output events with a few
basic data and you insert these tracepoints at specific places in your
code.
It is designed for maximal throughput and minimal impact on
performance, not really to instrument a lot of functions though.
Minitrace seems rather different and more akin to QDebug traces, just,
in a specific JSON format that can be consumed by chrome://tracing.
You may be able to write a QMessageHandler achieving the same purpose.
You will not be able to put integer event arguments as JSON number but
only string.
But at least you may be able to use QMessageLogContext file and line,
or maybe function, to get a unique id that chrome://tracing can use to
collate begin/end events.
See the example below:
https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler
And minitrace event formatting here:
https://github.com/hrydgard/minitrace/blob/master/minitrace.c#L302
Now, since the minitrace example seems to target MSVC, may I ask if
you tried Visual Studio performance analysis?
It samples stack traces to provide a rough estimate of performance
bottlenecks without having to modify the source code at all.
Hope it helps,
Arnaud
More information about the Development
mailing list