[Interest] QSortFilterProxyModel is slow in Qt-5.15.2
sivan nanthiran
nanthiran2005 at gmail.com
Mon Oct 21 09:55:57 CEST 2024
Hi,
I am currently using Qt-5.15.2 on MacOS 14.5 (MacBook Pro M1) and creating
a feature that uses QSortFilterProxyModel. This feature is part of an
existing complex application and upgrading to Qt 6 is not a choice at the
moment. I noticed that whenever I tried to filter items, the process was
extremely slow.
Here is my test case. I used customsortFilterModel example in Qt and
simplified it.
- The original model is a simple model inherited from QAbstractItemModel.
- In this model, the rowCount is 25000 while columnCount is only 3.
- Removed the proxy view (QTreeView) from the example as it was very slow
to even launch the app.
- Connected a button to do the filtering on proxyModel
(QSortFilterProxyModel). In the slot of the button click, I called
invalidateFilter() on the proxyModel.
- Override filterAcceptRow function to return true/false for even/odd rows
respectively.
Observations - Whenever the model is filtering data, it's extremely slow.
It takes about 5 seconds plus. It is not even because of the view since I
removed the proxy view. I have attached screenshot from time profile
I backported the following fixes, and used invalidateRowsFilter() instead
https://github.com/qt/qtbase/commit/8455bfee76ed3f1bd3bba8bd3688a7afa94ae0bb
https://github.com/qt/qtbase/commit/b5f6a85d274
It improved the performance from 5 seconds to 3 seconds plus. But I still
find it slow. Finally, I tried it with Qt6. And that improved the
performance tremendously (~200ms). However, I am not able to find any other
commits that would contribute to this performance improvement. I am
suspecting the replacement of QVector to QList, but I am not sure.
Could any expert here please advise on what contributes to the performance
improvement in Qt6. Thanks in advance.
Regards,
Sivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241021/43fa925f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2024-10-21 at 12.58.54?PM.png
Type: image/png
Size: 385908 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241021/43fa925f/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot 2024-10-21 at 12.58.43?PM.png
Type: image/png
Size: 182260 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241021/43fa925f/attachment-0003.png>
More information about the Interest
mailing list