[Development] How to speed up QML for KDE5 without QML compiler

Robin Burchell robin+qt at viroteck.net
Wed Sep 16 12:41:53 CEST 2015


On Wed, Sep 16, 2015, at 06:03 AM, Leslie Zhai wrote:
> For a new PC,  there is no sharp difference between QML and QWidget, but 
> in a very very old PC, how old? about 7 years ago, QML is very slow! and 
> it needs to close all effects for KDE5, even that when clicked, for 
> example, calendar applet, it hang about 3+ seconds to showPopup.

This may be an obvious statement, but QML's capabilities (like that of
any other software) are dependent on the hardware you run it on. The
slower the CPU/GPU, the less you can accomplish in the same amount of
wallclock time.

The key to good performance when using QML is to do the minimal amount
possible at any given time. This means:
* Not having useless wrapper items, e.g: Item { OtherThing { } } <- this
is creating an item to do absolutely nothing
* Having bindings be as simple as possible
* Aggressively delay loading of items (using Loader, make sure to keep
them in seperate source files too to minimize the amount of time spent
parsing)

All of these points are multiplied depending on how often you do them,
e.g. in a ListView's delegate, you construct a lot of delegates, so any
inefficiencies there will be multiplied by however many delegates you
create.

Keep in mind that the things you use to write your application matters
quite a bit, too. For example, QtQuickControls' Button is a lot more
complicated & heavy than something like Rectangle + MouseArea (this
example may not hold as relevant with QtQuickControls 2, I haven't
looked into it much).

You can take a look at https://github.com/sletta/qmlbench to get a sense
for how expensive different parts of QML are (and how many of certain
items you can create per frame, and such).

In addition to all that: I agree with what Konstantin said. Before
trying to fix performance, you first need to understand what's wrong
with it, which involves profiling and understanding the problem "under
the hood".

> There is commercial QML compiler, a very small example tried to use it 
> https://github.com/AOSC-Dev/AOSC-VersionHelper2
> But is it suitable for huge projects just like KDE5 if bought a 
> commercial license? because not all KF5 components follow the Qt Quick 
> Compiler`s resource.qrc way, so is it able to compile? for example, 
> kickoff applet (the start menu of KDE5).

Probably not. IIRC the compiler ties you to a particular Qt version: you
must use the same Qt version at runtime as you compiled the sources
with. So unless it was used as part of the distribution's build setup
(for instance) it probably wouldn't work at all.



More information about the Development mailing list