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
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
Evgenii Legotckoi
Evgenii LegotckoiOct. 31, 2024, 9:37 p.m.
Django - Lesson 064. How to write a Python Markdown extension Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup
A
ALO1ZEOct. 19, 2024, 3:19 p.m.
Fb3 file reader on Qt Creator Подскажите как это запустить? Я не шарю в программировании и кодинге. Скачал и установаил Qt, но куча ошибок выдается и не запустить. А очень надо fb3 переконвертировать в html
ИМ
Игорь МаксимовOct. 5, 2024, 2:51 p.m.
Django - Lesson 064. How to write a Python Markdown extension Приветствую Евгений! У меня вопрос. Можно ли вставлять свои классы в разметку редактора markdown? Допустим имея стандартную разметку: <ul> <li></li> <li></l…
d
dblas5July 5, 2024, 6:02 p.m.
QML - Lesson 016. SQLite database and the working with it in QML Qt Здравствуйте, возникает такая проблема (я новичок): ApplicationWindow неизвестный элемент. (М300) для TextField и Button аналогично. Могу предположить, что из-за более новой верси…
k
kmssrFeb. 9, 2024, 2:43 a.m.
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
Now discuss on the forum
Evgenii Legotckoi
Evgenii LegotckoiJune 24, 2024, 10:11 p.m.
добавить qlineseries в функции Я тут. Работы оень много. Отправил его в бан.
t
tonypeachey1Nov. 15, 2024, 2:04 p.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
NSProject
NSProjectJune 4, 2022, 10:49 a.m.
Всё ещё разбираюсь с кешем. В следствии прочтения данной статьи. Я принял для себя решение сделать кеширование свойств менеджера модели LikeDislike. И так как установка evileg_core для меня не была возможна, ибо он писался…
9
9AnonimOct. 25, 2024, 4:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks