Hey all,

for a customer I looked into the performance of a model/view application with 
many (and I mean, many!) add/remove/modify operations on a model with a 
QSortFilterProxyModel on top. The obvious solution to speed things up is 
batching, which works nicely paired with layout{AboutToBe,}Changed. So far so 
good, but the issue that was now reported comes when one now *also* wants to 
enable MultiSelection in the view, and the user "accidentally" presses
CTRL + A to select all items in the view. This then completely kills the 
performance, due to bottlenecks inside QAbstractItemModel, all related to 
QPersistentModelIndex.

Some questions now from my side:

a) Why is the hash of indexes in QAbstractItemModelPrivate::Persistent not 
unique - i.e. why is insertMulti required? I ask, b/c the "it + 1" operation 
in QAbstractItemModelPrivate::Persistent::insertMultiAtEnd is _extremely_ slow 
for large lists of persistent model indices, due to the cache misses etc. pp. 
involved. The documentation says:

    "There should be only one instance QPersistentModelIndexData per index, 
but in some intermediate state there may be severals of PersistantModelIndex 
pointing to the same index, ..."

What intermediate state is that? When I look at the uses of this function, 
they always use the pattern

persistent.indexes.erase(...);
...
persistent.insertMultiAtEnd(...);

I fail to see how/where this intermediate state can occur.

b) Changing that function to just use insert() and returning early, the big 
bottleneck above is gone, but it's still very slow, mostly due to the 
inefficiencies built-in to QPersistentModelIndex, e.g. operator= required in 
the merge sort step. I wonder what to do there...

Has anyone had similar experiences, and if so - what where the workarounds 
applied to make this fast?

Thanks
-- 
Milian Wolff | milian.wo...@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to