The new Qt Quick Compiler - get QML to run at a speed close to native

As most of you know, QML is an interpreted language. The flexibility of any interpreted language always comes with a potential decrease in performance. As we are very convinced of many other potentials of QML, we strive to reduce - if not to completely eliminate - this unpleasant potential. We implemented changes in the last Qt5 releases and especially in Qt6 helping to take a significant step towards our long term goal: make QML run at a speed close to native. This blog post explains what is new. The upcoming two blog posts will elaborate the technology and its development history.

QML speed-up-1

Today, we are proud to announce that we will introduce the new Qt Quick Compiler™ with Qt 6.3. The new Qt Quick Compiler will consist of two components: the QML Type Compiler and QML Script Compiler. The QML Type Compiler will compile QML object structures into C++ classes. The QML Script Compiler will compile functions and expressions in QML files of an application into C++ code. As much as possible, since there will be some limits set by the nature of JavaScript. If certain statements cannot be compiled, regular interpretation and caching will be used. Some changes in the code of the application might be needed to achieve the best possible results over time. New QML tools will help you detect these. For example, the new QML Lint, for example, will tell you which parts of the code cause fallbacks into interpretation. We will expand and improve QML tools in the future in our aim of making them a guide to Best Practices for all components in Qt Quick. The closer you follow the recommendations reported by these tools, the more QML code can be compiled and, thus, run faster. Speaking of "faster": one of the future blog posts will also show the first benchmark results.

As an initial step we are providing a Technology Preview of the QML Script Compiler for commercial customers. It is available as of today in the "Qt for Device Creation" package released with Qt 6.2.1. This Technology Preview will continue in 6.2.x releases of "Qt for Device Creation". Starting with Qt 6.3, the base components of the Qt Quick Compiler will also be integrated in the QtDeclarative module. This is an important step for us to ensure the creation of better and faster QML code by all users in the Qt community. While the QML Script Compiler might pass its Technology Preview already in 6.3, the Technology Preview for the QML Type Compiler will only start with 6.3. Depending on the results of these preview phases, we will later decide about a first general release.

Starting with Qt 6.3, we will additionally make Qt Quick Compiler Extensions available for Qt commercial users. Qt Quick Compiler Extensions will decrease the refactoring effort to improve coverage of compilation. Qt Quick Compiler Extensions are also planned to offer additional tooling or integrations for existing tools meant to provide a better understanding of how specific parts of the code influence execution performance of the application in the project and which changes in the code are needed to make these parts compile. More extensions are in development. In total, we expect that up to 30% speed-up can be achieved in the startup and execution over time.

Any compiler needs code to work with. This is the only way to evolve and get better and better, faster and faster. Please reach out to us! Ideally, via Qt Bug Reports and with samples of code which you expected to compile. The relevant component on the "QTBUG" project is "QML: Compiler". 


Blog Topics:

Comments