[Kde-pim] mixedmaildir optimization suggestion

Andras Mantia amantia at kde.org
Thu Sep 20 09:26:26 BST 2012


David Faure wrote:

> From mixedmaildirstore.cpp:
>  370│
>  371│     bool isValidEntry( const QString &entry ) const {
>  372├>      return mMaildir.entryList().contains( entry );
>  373│     }
> 
> Why list a very very big directory, just to find out if ONE file exists?
> [entryList() is slow because it uses QDir::entryList(), which sorts by
> [name,
> case insensitively.... lots of toLower() calls and lots of sorting].
> 
> 
> Shouldn't this be
>    return !mMaildir.findRealKey(entry).isEmpty();
> ?

Looks ok for me, but I'm not that familiar with the mixedmaildir code and 
see below.

Note that it is still not that fast as with maildir, where the if the 
directory changes on the disk, there is one entryList() call that updates 
the file key cache, instead of one (or two) QFile::exists() calls like there 
will be with mixedmaildir, because here the cache is not updated 
automatically.
I'd also say that because of this, there could be problems if a mail is 
removed from mixedmaildir's maildir part without the cache being update.
For example, let's assume mail "foo.12345" is in a folder "bar". That would 
be on the disk "bar/cur/foo.12345".
Calling isValidEntry("foo.12345") would find it with a QFile.exists() and 
but in the cache (see the findRealKey implementation). Upcoming calls will 
not perform the exists() but get the info from the cache.
 Now if "bar/cur/foo.12345" is removed from anything else but through 
akonadi, isValidEntry("foo.12345") would still return true, as the entry is 
in the cache.
 Might not be a new problem, as probably the whole mixedmaildir is not 
prepared for outside modifications, but it is something to keep in mind.

Andras
-- 
** Qt Developer Conference: http://qtconference.kdab.com/ **
András Manția | andras.mantia at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list