QML profiling

QML Profiling

' Document a Work in Progress '

Introduction

Profiling is the act of gathering data about the performance of a task with the ambition to improve the performance.

For CPUs, there are many standard tools to gather information about what the CPU is doing, allowing the developer to identify inefficient code and optimize it.

However the tooling for profiling tasks on GPUs is much less standardized, and the state is usually GPU-manufacturer specific. In addition the information these tools can gather is also much more limited, due to the design of OpenGL and GPUs in general. Some of these techniques and tools are described at GPU profiling

Ubuntu UI Toolkit logging

For applications using the Ubuntu UI Toolkit there is stdout logging that will warn if the frame rendering is being slow. Those values can be tweaked with environment variables

  • UC_PERFORMANCE_MONITOR_SINGLE_FRAME_THRESHOLD: Warns if a single frame took more or equal than this value to be rendered. Defaults to 32
  • UC_PERFORMANCE_MONITOR_MULTIPLE_FRAME_THRESHOLD: Warns if a count of consecutive frames took more or equal than this value to be rendered. Defaults to 17
  • UC_PERFORMANCE_MONITOR_FRAMES_COUNT_THRESHOLD: Consecutive number of frames that need to happen over or equal the multiple frame threshold time for a warning to be given. Defaults to 10
  • UC_PERFORMANCE_MONITOR_WARNING_COUNT_THRESHOLD: Maximum number of warnings that will be given. -1 means give all the warnings. Defaults to 30

QtQuick Scene Graph Render Loop logging

If you enable the QSG_RENDER_TIMING environment variable (set to 1) for your project you will get detailed per frame information on the time it takes to generate/draw the frames. The detailed information on what each line means can be found at http://doc.qt.io/qtcreator/creator-qml-performance-monitor.html#analyzing-scene-graph-events

This is interesting because the Ubuntu UI Toolkit logging does only monitor the render thread but not the GUI thread when using the threaded screen graph render loop.

The GUI thread can be slow in the polish step since it's where item views synchronously precreate delegates that are on the viewport.

If you find out that the polish step is slow you may want to recompile qtdeclarative with the following patches:

If you're specifically debugging Unity8 Dash you may also be interested in

qmlprofiler / Qt Creator

Profiling a binary directly

Works on the phone if qtdeclarative5-dev-tools is installed

qmlprofiler -fromStart qmlscene main.qml

type "q" on the qmlprofiler terminal when you want to stop profiling, be patient and it will tell you where it saved the .qtd file

Attaching to a running app

You need to start the app with -qmljsdebugger=port:3768,block e.g.

restart unity8-dash ARGS=-qmljsdebugger=port:3768,block

If you're running the app on the phone you may want to forward to the PC and run qmlprofiler there

adb forward tcp:11111 tcp:3768 qmlprofiler -fromStart -attach 127.0.0.1 -p 11111

type "q" on the qmlprofiler terminal when you want to stop profiling, be patient and it will tell you where it saved the .qtd file

Opening qtd files

You can open the qtd file in Qt Creator (Analize -> QML Profiler Options)

http://doc.qt.io/qtcreator/creator-qml-performance-monitor.html#analyzing-collected-data explains how to interpret the data

Memory concerns

QML debugging does not save any data until the end of the debugging session. This means that memory use of the profiled program increases indefinitely since it needs to store all the debugging information in memory. Writing the data to file takes time and memory since it needs to flush all the data at once, that's why it's recommended to run qmlprofiler in the PC.

Unity8 Dash KPI performance dashboard

We collect QML metrics on the KPI Performance dashboard at http://reqorts.qa.ubuntu.com/reports/qa/performance/dashboard/index.html#performance-subsection-dash

If you want to reproduce the results you can use the code at lp:ubuntu-performance-tests it has a comprehensive README file that explains how to run the KPI locally.

Touch/QML profiling (last edited 2016-07-01 09:22:59 by aacid)