虚空境界分享 http://blog.sciencenet.cn/u/depengchen 摄心神,致虚极,守静笃

博文

Qt5.9发布了,Qt 5.9长期支持版之性能改善

已有 12583 次阅读 2017-6-3 11:48 |系统分类:科研笔记

PerformanceImprovements with Qt 5.9 LTS

Qt5.9长期支持版之性能改善

PublishedWednesday May 31st, 2017
9 Commentson PerformanceImprovements with Qt 5.9 LTS
Posted in Biz Circuit & Dev Loop, Boot time, Embedded, Graphics, Qt, Qt Quick, Releases

Qt 5.9 LTS improves Qt Quick and QMLperformance significantly, especially with Linux on ARM. We have worked hard toimprove the performance in multiple areas: within the QML engine, Qt Quickgraphics, QML Compiler and in the Qt Quick Controls, to name some examples.Performance has improved significantly across all areas, with some items beingseveral times faster than with our previous long-term supported release Qt 5.6LTS.

显著改善了Qt Quick 和 QML之性能,尤其在ARM平台上之Linux。QML引擎,Qt Quick 图形,Qt QML编译器,Qt Quick 控件,相对于5.6,有些方面的性能提高了数倍。

Weare regularly running several different kinds of performance tests to see howthe various optimizations work across different platforms. Some of theseresults are visible at testsresults.qt.io,while some tests have not been automated yet. Whenever possible, we areaiming to optimize the performance of all supported operating systems and CPUarchitectures. For readability and because Linux on ARM has been an area ofparticular focus with Qt 5.9 LTS, it is the one discussed in this post.Typically, the other platforms have received roughly similar improvements.

测试了不同平台,有些结果于网站testsresults.qt.io可见,重点关注ARM平台上之LINUX优化,其它平台已得到了类似改善。

Qt Quick Application StartupTime


Startup time of a QtQuick application is often critical in the embedded space. This is truefor small single-process embedded systems, as well as for more complexmulti-process devices. We have offered a commercial-only tool called the QtQuick Compiler since Qt 5.3 to improve the startup time by leveraging the C++compiler to compile QML into a normal C++ binary(利用CPP编译器把QML编译为普通的CPP二进制文件). Between Qt 5.6 LTS and Qt 5.9LTS, the performance of the QML engine has improved with each new Qt release(Qt5.6~5.9之间,每一次发布,QML引擎均得到改善), resulting in improved application startup time. Qt 5.8 introducedQML caching(引入了QML缓存机制), whichmakes second and subsequent runs of the applications to be faster(使得第二次和后续应用程序运行更快). Qt 5.9 also offers a possibility to pre-populate the cache (预填充缓存机制来对已运行一次的应用改善性能)to reach improved performance already with the first run. With theQt Quick Compiler, the first run is also already fast(使用Qt Quick Compiler第一次运行也已变得更快。).(下面的图例,注意是越短标识性能越高)


64位ARM总是比32位性能好很多,值得关注的是64bit ARM硬件平台为NVIDIA TX1 Linux。

方法为通过编译器把

Eachapplication has unique characteristics so the exact benefit in startup time forusing Qt 5.9 LTS and/or the Qt Quick Compiler will vary. Typically, the moreQML used, the bigger the improvement is(QML用得越多,性能改善越大).In Qt 5.9 LTS we offer two alternative options(两种改善机制选项): the commercial-only Qt Quick Compiler (一种仅对商业化的Qt Quick Compiler)and a new tool to populatethe cache ahead-of-time(一个新工具来提前填充缓存), which isavailable for both open-source and commercial users.(这对开源和商业用户均可用) The performance and reduced startup time are in practice the samewith both approaches in Qt 5.9 LTS(在Qt 5.9LTS中两种方法的性能改善在实践中是相同的。).

Whencomparing the startup time for the same Qt Quick application with Qt 5.6LTS without the Qt Quick Compiler to the startup time of Qt 5.9 LTS using theQt Quick Compiler (or populated cache), the improvement is a whopping 60% onNXP i.MX6(对NXPi.MX6CPU 启动时间性能提高了60%). Whenusing the commercial-only Qt Quick Compiler of Qt 5.6 LTS the improvement instartup time is 54% (compared to Qt 5.6 LTS without the Qt Quick Compiler inuse)(带商业化Qt Quick Compiler相对于不带的Qt 5.6 LTS,启动性能提升了54%). Comparing the startup times of Qt 5.6 LTS and Qt 5.9 LTS when bothare using the Qt Quick Compiler the improvement is 14% on NXP i.MX6(都使用Qt Quick Compiler的5.6对5.9,性能提升了14%,对NXPi.MX6).

Theapplication used for the tests was the Qt Quick Controls 1 gallery and thetests were run with Linux on NXP i.MX6 and NVIDIA Tegra X1. We used theControls 1 example because they are much heavier than Controls 2, thus betterresembling a typical real-life Qt Quick application. For more measurements ofQt Quick application startup times, please check out the earlier blog post.For instructions to further optimize startup time of a Qt Quick application,please read the second post of ourearlier fastboot blog series.

用于测试的应用是Qt Quick Controls 1,测试平台为Linux on NXP i.MX6and NVIDIA Tegra X1。

Qt Quick ControlsPerformance

Qt5.6 LTS features Qt Quick Controls 1 while Qt 5.9 LTS features the Qt QuickControls 2 fullysupported. The main design principle of Qt Quick Controls 2 has been performance, as can be seen already from the blog post announcingthem. From the very beginning, the key focus area of the new Qt Quick Controls 2 has been for embeddeddevices and systems.However, these can equally well be used on all supported platforms.Compared to Qt Widgets or Qt Quick Controls 1, the key difference of Qt QuickControls 2 is that they do not adapt to platform style. We do offer multipledifferent styles for Qt Quick Controls 2 and it is easy to make your own styleas well. From an architectural viewpoint, the key difference of Qt QuickControls 2 is that they leverage C++ for everything that can be done with C++and offer just the QML API for applications to use.

Qt QuickControls 2 特别强调性能,关键关注领域为嵌入式设备和系统。相对于Qt Widgets or Qt QuickControls 1,它不是适应平台式样风格,而是提供多种风格式样Qt Quick Controls 2,容易创建自己的式样风格。从架构的观点来看,QtQuick Controls 2的关键不同点为对每一项能用C++的都利用C++来处理,仅为应用提供QMLAPI供其使用。


Asillustrated in the graph above, the performance improvement is huge (note: thehigher the bar, the better the performance is). We used NXP i.MX6 running Linuxfor the measurements. For some of the controls the performance is 14xbetter than before(最高性能高14倍), and on average the performance hasbeen improved 6x comparing Qt 5.9 LTS with Qt Quick Controls 2 to Qt 5.6 LTSwith Qt Quick Controls 1(平均性能提高6倍). To benefit from the improved performance, the application needs tobe ported to use Qt Quick Controls 2. This is typically quite straightforward (这往往十分简单)and Qt Quick Controls 2 offers most of the common controls(提供了绝大多数控件). Before porting, please check the documentation,as some controls, such as TableView, are not currently available with Qt QuickControls 2(移植前,请查看文档,诸如TableView的一些控件,在Qt Quick Controls 2中当前是不可用的。).

Shader Cache  着色器缓冲

Qt5.9 LTS introduces a new feature to cache OpenGL shaders to disk after thefirst run(引入了一个新特性,在第一次运行后,缓冲OpenGL 着色器), as explained in the blog post introducingthe shader cache. If your Qt Quick application is using OpenGLshaders, which is quite often the case这是常遇见的情形, itwill achieve a significant improvement in startup time comparedto earlier versions of Qt. When comparing the performance of Qt 5.6 LTS toQt 5.9 LTS using the same Qt Quick application with 10 shaders十个着色器, we can see a significant improvement in the initialization time ofthe shaders(着色器初始化时间). Some of the performanceimprovement observed in the measurement is due to the overall improvements inthe graphics performance, but most of the improvement can be attributedto the new shader cache feature.


Qt5.9 LTS is a whopping 7x faster than Qt 5.6 LTS on startup with the same exactQt Quick application running the same hardware(同样硬件和Qt Quick应用,快乐7倍。). Just like the previous measurementsdescribed in the blog post, this test has also been conducted usingNXP i.MX6 running Linux. The performance improvement is dependent on thehardware and especially the GPU plays a major role(性能的改善依赖于硬件,尤其是GPU扮演主要角色). Based on our measurements thereare significant improvements with every piece of hardware we have tested –including ones that implement cache feature already in the OpenGL driver.

Memory Footprint足印;占用空间;占地面积) Improvements 内存占用改善

In Qt5.8 we introduced a new configuration system and made other improvementsto reduce the binary size of the Qt framework libraries usedfor different applications(5.8中引入新的配置系统减少Qt框架库的二进制代码大小). This was developed as part of the Qt Lite project, which focusedspecifically on reducing the application size(特别关注减少应用程序是大小). With Qt 5.9 LTS we have further polished and tuned the availableconfigurations so that more and more different kinds of applications can reachtheir minimal Qt configuration(5.9中可达到最小之配置). Reducing the size of a Qt 5.6 LTS application is possible mainlyby just using the modules needed by the application and statically linking thebinary(5.6中主要使用为应用仅使用必要之模块,以及链接为静态二进制库). Because of dependencies within the Qt framework, the linker is notable to reach as small binary size as it is possible with Qt 5.9 LTS using thenew configuration tool.

由于Qt框架的依赖性,连接器不可能达到最小二进制程序大小。5.9使用了新配置工具


Weused a simple, but non-trivial, Qt Quick application (samegame) tocompare the needed binary size of the application itself as well as all the Qtlibraries it needs. With Qt 5.6 LTS the application requires 24,5MB whenlinking dynamically. Using static linking, the size is reduced to 13,8MB(still using Qt 5.6 LTS). Leveraging the new configuration tool in Qt 5.9LTS and with other Qt Lite improvements, the exact same application only needs5,4MB when static linking is used. Percentage-wise, the Qt 5.9 LTS binary sizeof the application is 61% smaller than the same application with Qt 5.6 LTS andstatic linking – without losing any functionality or making any changesto the application.(厉害了,我的Qt5.9)

Improvement in JavaScriptPerformance JavaScript性能之改善

Withthe improvements in the QML engine in Qt 5.9 LTS the performance of JavaScriptexecution has also improved(QML 引擎的改善,同时JavaScript的执行性能亦得到改善). If the Qt Quickapplication leverages JavaScript, there is a huge improvement in performancecompared to Qt 5.6 LTS, especially on 64-bit ARM. One example of heavilyleveraging JavaScript is using three.js on top of Canvas 3D, and smalleramounts of JavaScript are often used in Qt Quick applications.尤其是对64位AMR平台,如果Qt Quick应用利用了JavaScript,性能改善明显


Themeasurements are done with v8-bench, which can be found in the qtdeclarativerepository. Additional measurements are available at testresults.qt.io.With the v8-bench performance benchmark results of Qt 5.6 LTS compared to Qt5.9 LTS, the improvement on 32-bit ARM is 16%(32位ARM提升16%), but on 64-bit ARM the improvement is awhopping 302% (i.e. 4x improvement)(64位ARM提升302%). Thereasons for the huge improvements are that Qt 5.9 LTS fully supports64-bit ARM processors combined with the improvements in the QML engine.巨大改善之原因为Qt 5.9 LTS完全支持64bitARMCPU,结合QML引擎之改善。

Overall Qt Quick PerformanceImprovements 全面Qt Quick 性能之改善


The examples above arejust some of the highlights from many improvements we have done to theperformance of Qt Quick in Qt 5.9 LTS. We have tuned multiple individual areasand optimized the execution paths within the Qt framework. It is important tonote that we have also worked hard not to regress(后退,回归,退化) in any areas. To avoidregressions, we are regularly running a comprehensive Qt Quick benchmark suitecalled Qmlbench. With the Qmlbench tool we can see the performance of the mostcommonly used Qt Quick functionality as well as the functionality thatis used less frequently. For more details, please review the thorough explanationof how we are using Qmlbench to avoid regressions.

Whencomparing Qt 5.6 LTS and Qt 5.9 LTS in the same environment with thecomprehensive Qmlbench measurements, we can see  that some areas improvedup to 130% as shown in the graph above. Especially layout and complex textperformance has improved drastically尤其在布局和复杂文本性能的改善显著. The average improvement ofQt 5.9 LTS compared to Qt 5.6 LTS in all Qmlbench tests is 14% (measured onLinux)改善性能,基于Qmlbench测试,平均改善14%.Despite which functionality is used, the improvement in performance of a QtQuick application running Qt 5.9 LTS compared to Qt 5.6 LTS is clear andtangible for most applications.

Conclusions

Inthis blog post在本博客帖子中, I summarized some of the multiple performance improvementsavailable with Qt 5.9 LTS. Compared to Qt 5.6 LTS, the performance of the sameapplication running on Qt 5.9 LTS is significantly higher. Without making anychanges to the application, except for compiling it for the new Qt 5.9 LTS, theperformance is significantly improved. Ranging from improved applicationstartup time and smaller footprint through to increased graphicsperformance, Qt 5.9 LTS is a major step forward performance-wise. Taking someof the new features, such as Qt Quick Controls 2, into use even furthers theperformance improvements available with Qt 5.9 LTS.

Interestedin taking a closer look? Qt 5.9.0 has been released today. You can get it withyour online installer, from the Qt Account orfrom the Qt Downloads page (foropen-source users).

Formore details of Qt 5.9 LTS, please check the Qt 5.9 LTS releaseblog post.




https://blog.sciencenet.cn/blog-338872-1058803.html

上一篇:url inverse problem source code cpp
下一篇:Qt Creator 4.4.0 released 发布了。。。。。您值得关注。。...
收藏 IP: 202.197.76.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-20 09:47

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部