渲染 QWidget 时出现大量页面错误
我注意到我的 Qt 应用程序中存在大量页面错误。我通过调整对接小部件(下面有数十个小部件的小部件树)的大小来重现它 2 秒,并使用 AQTime 跟踪该操作。此操作出现 2000 个页面错误。这是为什么?
在 Windows XP 32 位上使用 Qt 4.5.3
更新:它们是软页面错误
更新2:我在 Qt Designer 中创建了一个 ui,其中有 1 个组合框,其中有 2 个项目。如果我预览此内容,每次单击组合框选择其中一项时,都会出现 200 个页面错误。
Parents
Code Type Routine Name Faults Faults with Children Hit Count
x86 qt_memfill_template<unsigned int,unsigned int> 2416 2416 5160
x86 qt_memfill<unsigned int> 2416 2416 5160
x86 qt_rectfill<unsigned int> 0 2416 5160
x86 qt_rectfill_template<unsigned int> 0 2416 63
x86 qt_rectfill_quint32 3 2419 63
x86 fillRect_normalized 1 2420 63
x86 QRasterPaintEngine::fillRect 3 2423 63
x86 QRasterPaintEngine::fillRect 1 2424 63
x86 QPainter::fillRect 1 2427 63
x86 fillRegion 0 2427 15
x86 QWidgetPrivate::paintBackground 2 2430 12
x86 QWidgetPrivate::drawWidget 0 2430 12
x86 QWidgetBackingStore::sync 2 2596 12
x86 QWidgetPrivate::syncBackingStore 4 2610 12
x86 QETWidget::translateConfigEvent 0 2479 6
x86 QtWndProc 0 2495 12
I noticed a large amount of page faults in my Qt application. I reproduced it by resizing a docking widget (with a widget tree of dozens of widgets underneath) for 2 seconds and traced that operation using AQTime. I get 2000 page faults for this operation. Why is that?
Using Qt 4.5.3 on Windows XP 32 bit
UPDATE: They're soft page faults
UPDATE2: I created a ui in Qt Designer with 1 combobox with 2 items in it. If I preview this, I get 200 page faults each time I click the combobox to select one of these items.
Parents
Code Type Routine Name Faults Faults with Children Hit Count
x86 qt_memfill_template<unsigned int,unsigned int> 2416 2416 5160
x86 qt_memfill<unsigned int> 2416 2416 5160
x86 qt_rectfill<unsigned int> 0 2416 5160
x86 qt_rectfill_template<unsigned int> 0 2416 63
x86 qt_rectfill_quint32 3 2419 63
x86 fillRect_normalized 1 2420 63
x86 QRasterPaintEngine::fillRect 3 2423 63
x86 QRasterPaintEngine::fillRect 1 2424 63
x86 QPainter::fillRect 1 2427 63
x86 fillRegion 0 2427 15
x86 QWidgetPrivate::paintBackground 2 2430 12
x86 QWidgetPrivate::drawWidget 0 2430 12
x86 QWidgetBackingStore::sync 2 2596 12
x86 QWidgetPrivate::syncBackingStore 4 2610 12
x86 QETWidget::translateConfigEvent 0 2479 6
x86 QtWndProc 0 2495 12
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,Qt 分配了一个新的位图来保存小部件的外观,并且系统通过向进程分配新页面来满足此请求。第一次写入这些页面时,会发生软页面错误,并且实际页面会被映射到进程地址空间。通过在重绘调用之间缓存位图可以避免这种情况;然而,当调整大小时,所需位图的大小将会改变,因此这种优化不再适用;每次尺寸改变时,都必须重新分配位图(导致软页面错误)。
但这实际上会对性能产生影响吗?
Most likely, Qt allocated a new bitmap to hold the widget's appearance, and the system satisfied this request by allocating new pages to the process. Upon the first write to these pages, a soft page fault occurs, and the actual pages are mapped into the process address space. This could potentially be avoided by caching the bitmap between repaint calls; however, when resizing, the size of the bitmap needed will change, and so this optimization no longer applies; the bitmap must be reallocated (causing soft page faults) each time the dimensions change.
Is this actually having a performance impact, though?