Revision d789339...

Go back to digest for 9th November 2014

Optimization in KDE-PIM

Gerrit Test Instance Operator committed changes in [trojita] /:

Use QVector for passing lists of UIDs

OK, this is a big patch. Stuff started when I was profiling quite a slow
operation of mass expunges which was reported by Luke-jr on IRC. Some
profiling indicated that quite a lot of time was spent within
QListData::append. Adding a call to QList::reserve didn't help that
much, while replacing this with a QVector led to interesting results.
The cache format stays the same -- QDataStream uses the same
serialization format for both, which is cool.

Unfortunately, this change propagated into quite a few places. As I was
modifying the code anyway, I decoded to do it properly, with typedefs
and what not. Of course, QVector and QList have slightly different APIs,
especially the removeOne/removeAll/removeAt vs. just remove (until Qt
5.4 which actually added compatibility API, but we cannot depend on 5.4
yet).

The speed improvements suggest going from 2.5 to 1.5s on a synthetic
benchmark, Looking at callgrind's output, the total time spent in
Imap::Mailbox::Model::saveUidMap went from 34% to ~17%, which is IMHO a
pretty cool improvement.

Majority of time is now spent in comparing strings when determining
unread status of flags -- that's the next item on my list, because this
test exercises that code path a lot, again in an O(n^2) manner.

Change-Id: Ifb86903118b996c4bf5764965c06f4145eda6e07

File Changes

Modified 41 files
  •   src/Composer/ComposerAttachments.cpp
  •   tests/Imap/test_Imap_CopyAndFlagOperations.cpp
  •   tests/Imap/test_Imap_Parser_parse.cpp
  •   tests/Imap/test_Imap_Responses.cpp
  •   tests/Imap/test_Imap_SelectedMailboxUpdates.cpp
  •   tests/Imap/test_Imap_Tasks_ObtainSynchronizedMailbox.cpp
  •   tests/Imap/test_Imap_Threading.cpp
  •   tests/Imap/test_Imap_Threading.h
  •   tests/Utils/LibMailboxSync.cpp
  •   tests/Utils/LibMailboxSync.h
  •   src/Imap/Model/Cache.h
  •   src/Imap/Model/CombinedCache.cpp
  •   src/Imap/Model/CombinedCache.h
  •   src/Imap/Model/MailboxModel.cpp
  •   src/Imap/Model/MailboxTree.cpp
  •   src/Imap/Model/MemoryCache.cpp
  •   src/Imap/Model/MemoryCache.h
  •   src/Imap/Model/Model.cpp
  •   src/Imap/Model/Model.h
  •   src/Imap/Model/SQLCache.cpp
  •   src/Imap/Model/SQLCache.h
  •   src/Imap/Model/TaskFactory.cpp
  •   src/Imap/Model/TaskFactory.h
  •   src/Imap/Model/ThreadingMsgListModel.cpp
  •   src/Imap/Model/ThreadingMsgListModel.h
  •   src/Imap/Parser/LowLevelParser.cpp
  •   src/Imap/Parser/LowLevelParser.h
  •   src/Imap/Parser/Response.cpp
  •   src/Imap/Parser/Response.h
  •   src/Imap/Parser/Sequence.cpp
  •   src/Imap/Parser/Sequence.h
  •   src/Imap/Tasks/AppendTask.cpp
  •   src/Imap/Tasks/FetchMsgMetadataTask.cpp
  •   src/Imap/Tasks/FetchMsgMetadataTask.h
  •   src/Imap/Tasks/FetchMsgPartTask.cpp
  •   src/Imap/Tasks/FetchMsgPartTask.h
  •   src/Imap/Tasks/KeepMailboxOpenTask.cpp
  •   src/Imap/Tasks/KeepMailboxOpenTask.h
  •   src/Imap/Tasks/ObtainSynchronizedMailboxTask.cpp
  •   src/Imap/Tasks/ObtainSynchronizedMailboxTask.h
  •   src/Imap/Tasks/SortTask.h
41 files changed in total