Lila25mila
Lila25milaJan. 21, 2019, 6:48 a.m.

Qt 5.12 LTS - The Way to Faster Launching QML Applications

Qt has a long history of using benchmarks like QMLBench to help us know when a change causes performance degradation, but it's also important to see how Qt works at a higher level, allowing components to interact in ways that detailed tests like QMLBench don't can show us this. In this article, we will look at the test results of running a new application from a more real QML testing application.


Benchmark

For these tests, a relatively simple QML application was developed that uses many QtDeclarative and QtGraphicalEffects objects. The application code was written as a regular developer would write it, without optimizations for startup, memory consumption, or performance. Because we're benchmarking, the app doesn't use interactive elements or user input. The application has low complexity, with no divergent logic, so results are as consistent as possible between test runs. While no benchmark can truly mimic real-life user interaction performance, the benchmark discussed aims to more accurately represent a real QML workload than either QMLBench or the QtQuickControls "Galery" example.

Test application. It integrates textures, animations, QML shapes, repeaters, complex text, particle effects, and GL shaders to simulate a heavier, more realistic application than other QML benchmarks like QMLBench.

Test application. It combines textures, animations, QML shapes, repeaters, complex text, particle effects, and GL shaders to simulate a heavier, more real application than other QML benchmarks like QMLBench.

Download the source code here.

Lars has previously written about Qt's commitment to improving Qt's performance, and with the recent release of Qt 5.12 LTS, the efforts made really show this, especially in QML. Among the improvements, a large number were aimed at improving startup performance. Of the platforms tested, the biggest improvement in startup performance was seen on the low power device we tested, the Toradex Apalis i.MX6. Let's take a look at this.

Performance at startup

The diagram above shows how the Qt 5.12 LTS features really hurt startup performance, reducing the time to first frame from 5912ms in Qt 5.6 to just 1258ms in Qt 5.12.0, a 79% improvement! This is thanks to a number of new features that can be combined to improve startup performance. Let's go through each.

The diagram above shows how the Qt 5.12 LTS features really hurt startup performance, reducing the time to first frame from 5912ms in Qt 5.6 to just 1258ms in Qt 5.12.0, a 79% improvement! This is thanks to a number of new features that can be combined to improve startup performance. Let's go through each.

  • Shader cache implemented in Qt 5.9 LTS

    The shader cache saves compiled OpenGL shaders to disk, so you can avoid recompiling GL shaders on every run.

Pros: Reduces startup time and avoids application delay when a new shader is found if the shader is already in the cache.

Cons: Systems with little storage may occasionally clear the shader cache. If your application uses very complex shaders and runs on a low-powered device, where shader compilation can result in unwanted startup times, it may be recommended to use precompiled shaders to avoid caching issues. There is no performance difference between cached shaders and precompiled shaders.

Difficulty of use: no! This process is automatic and does not require manual execution.

  • Compiled QML

    Without the use of the fast Qt compiler detailed below, QML applications built on versions of Qt prior to 5.9 LTS will always be compiled at runtime each time the application is run. Depending on the size of the application and the processing capabilities of the host, this action can result in undesirably long startup times. Two improvements in Qt now make it possible to significantly speed up the launch of complex QML applications. Both of them provide the same performance boost at startup.
    This is Qt Quick Cache and pre-generated QML (Qt Quick Compiler)

    Qt Quick Cache - Introduced in Qt 5.9 LTS
    Qt Quick Cache saves run-time compiled QML to disk in a temporary location so that after the first run, when QML is compiled, it can be directly loaded on subsequent runs instead of doing expensive compilations each time.

    Pros : Can significantly speed up complex applications with large number of QML files.

    Cons: If your device has very little storage, the operating system can automatically clear caches, which sometimes results in unexpectedly long startup times.

    Difficulty of use: no! This process is automatic and does not require manual execution.

    Pre-generated QML (Qt Quick Compiler) - Introduced in Qt 5.3 for commercial licensees, both commercial and open source, in Qt 5.11
    The Fast Compiler allows you to package and use a precompiled QML application. Initially available under a commercial license since Qt 5.3, it has been available to both commercial and open source users since Qt 5.11.

    Pros: The advantage of using Quick Compiler is that it doesn't have to rely on the generated QML cache at runtime, so you don't have to worry about unexpectedly long startup times after a particular application host cleans up its temporary files.

    Cons: No!

    Difficulties of use: low. See related documentation. Often this is as simple as adding "qtquickcompiler" to CONFIG in your project's .pro file!

  • Distance Fields - implemented in Qt 5.12 LTS

    While Qt has been using distance fields in font rendering for a long time to have cleaner, crisper, animated fonts, Qt 5.12 introduces a method to precompute distance fields.

    Pros: Using pre-generated fonts for the distance field can significantly slow down startup performance when using complex fonts such as decorative Latin, Chinese, Japanese, or Sanskrit fonts. If your application uses a lot of text, multiple fonts, or complex fonts, pre-generation of distance fields can take a huge amount of startup time.

    Cons: Generated spacing font files will be slightly larger on disk than standard fonts. This can be optimized by selecting only those symbols that will be displayed in your application when using the Distance Field Generator tool. Unselected glyphs will be calculated as needed at runtime.

    Difficulties of use: low. See related documentation. No additional code is required and it takes seconds to generate spacing fields for your font.

  • Compressed textures - implemented in Qt 5.11

    Providing OpenGL with compressed textures ready to be loaded into video memory directly from the gateway eliminates the need for Qt to prepare other types of files (jpg, png, etc.) for loading.

    Pros: Using compressed textures provides faster startup times, reduced memory usage. It might even improve performance a bit depending on how heavily your texture is being used and how heavily you're using compression.

    Cons: Although the compression algorithms used for textures inherently require some compromise in visual fidelity, all but the most extreme compression schemes will typically not experience any visible loss in fidelity. Choosing the right compression scheme for your application's use case is an important consideration.

    Difficulties of use: low. Almost no coding is required, just change the texture file extensions in your qt code.

Findings

I.MX6 is a great introduction to mid-range embedded hardware, and the performance improvements included in Qt 5.12 LTS. Put all the improvements together and you can really reduce the startup time required for low power devices.

With these latest test results for low power hardware, Qt 5.12 can help your development by significantly reducing startup time, especially when running on low to mid-range embedded devices. These new performance improvements are easy to implement with only minor changes to your codebase, so there is very little reason not to start using Qt 5.12 right away, especially if your project is cramming heavy QML applications into a small SoC. The table below is an indication of what is possible with Qt 5.12 LTS.

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
e
  • ehot
  • March 31, 2024, 9:29 p.m.

C++ - Тест 003. Условия и циклы

  • Result:78points,
  • Rating points2
B

C++ - Test 002. Constants

  • Result:16points,
  • Rating points-10
B

C++ - Test 001. The first program and data types

  • Result:46points,
  • Rating points-6
Last comments
k
kmssrFeb. 9, 2024, 2:43 a.m.
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
EVA
EVADec. 25, 2023, 6:30 p.m.
Boost - static linking in CMake project under Windows Ошибка LNK1104 часто возникает, когда компоновщик не может найти или открыть файл библиотеки. В вашем случае, это файл libboost_locale-vc142-mt-gd-x64-1_74.lib из библиотеки Boost для C+…
J
JonnyJoDec. 25, 2023, 4:38 p.m.
Boost - static linking in CMake project under Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
G
GvozdikDec. 19, 2023, 5:01 a.m.
Qt/C++ - Lesson 056. Connecting the Boost library in Qt for MinGW and MSVC compilers Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Now discuss on the forum
a
a_vlasovApril 14, 2024, 1:41 p.m.
Мобильное приложение на C++Qt и бэкенд к нему на Django Rest Framework Евгений, добрый день! Такой вопрос. Верно ли следующее утверждение: Любое Android-приложение, написанное на Java/Kotlin чисто теоретически (пусть и с большими трудностями) можно написать и на C+…
Павел Дорофеев
Павел ДорофеевApril 14, 2024, 9:35 a.m.
QTableWidget с 2 заголовками Вот тут есть кастомный QTableView с многорядностью проект поддерживается, обращайтесь
f
fastrexApril 4, 2024, 11:47 a.m.
Вернуть старое поведение QComboBox, не менять индекс при resetModel Добрый день! У нас много проектов в которых используется QComboBox, в версии 5.5.1, когда модель испускает сигнал resetModel, currentIndex не менялся. В версии 5.15 при resetModel происходит try…
AC
Alexandru CodreanuJan. 19, 2024, 7:57 p.m.
QML Обнулить значения SpinBox Доброго времени суток, не могу разобраться с обнулением значение SpinBox находящего в делегате. import QtQuickimport QtQuick.ControlsWindow { width: 640 height: 480 visible: tr…

Follow us in social networks