[Development] QTBUG-43096 - QML instantiation performance decadence
Uwe Rathmann
Uwe.Rathmann at tigertal.de
Fri May 25 21:14:35 CEST 2018
On Fri, 25 May 2018 14:30:05 +0200, Robin Burchell wrote:
> I have over the years avoided using QQC1 in several projects as
> I knew that the performance simply wasn't up to the task without ever
> trying it "seriously", instead developing custom controls ...
Please let me give a detailed answer to this one:
On the Qt Conn 2016 Andrew ( Knight ) presented our very first results,
when comparing 4 different implementations of an average button.
a) a button from Quick Controls 1
b) a button from Quick Controls 2
c) a custom button composed in QML ( this is your approach )
d) a button from QSkinny
All implementations have been done in QML with very similar code.
Unfortunately the presentation has not been recorded, but out of my
memory one of our statistics was:
a) > 30 QObjects
b + c ) 7 QObjects
d) 1 QObject
The reason why QSkinny is more lightweight is because it does scene graph
node composition, where all other implementations are composing more
heavy Quick items.
( But we also noticed stuff like that: QQuickGradient is a QObject and
even QQuickGradientStop is one. So for the definition of a gradient with
2 colors you need 3 QObjects: > 400 bytes. These little things could
easily being fixed by using Q_GADGET - but obviously nobody cares. )
--
Another example I can give is related to new code: the page indicator
from Quick Controls 2. IMHO all what should be needed to describe such a
control is the number of the bullets, the index of the current one, the
shape of the bullets and maybe some color information - all in all maybe
~50 bytes.
But the way how it is implemented is having a Quick Item for each bullet.
IIRC an item has a minimum of 320 bytes ( usually more ) and has an extra
transform node on top of its paint node. So we end up with something like
n * 400 instead of ~50. Might be interesting to count the exact numbers
being consumed with the existing styles - I would expect to end up with
something scary.
I don't want to insist too much on the page indicator example as this is
usually not a control that is instantiated many times in the same
application. But to me it is symptomatic and you find a similar situation
almost everywhere.
Uwe
More information about the Development
mailing list