[Kde-pim] mixedmaildir optimization suggestion

Andras Mantia amantia at kde.org
Thu Sep 20 14:30:40 BST 2012


Kevin Krammer wrote:

>> 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 was under the impression that the cache in maildir does not change the
> behavior but just makes things faster by avoiding unnecessary calls.
> Isn't the cache discarded when the modification time of the directory is
> newer than the modification time of the cache for that directory?
> 
> The removal of a file would change the directory's modification time, this
> should invalidate the cache. Any listing or file check would then rebuild
> the cache, right?

The cache itself is not invalidated automatically. The purpose of the cache 
was to limit the number of file stats (QFile::exists()) calls. 
Items can go into the cache if:
- findRealKey is called on them, and they are not yet in the cache
- the cache is completely refreshed (this runs two entryLists() calls and 
puts all files from cur and new into the cache)
- items are copied/moved inside the resource with the Maildir lib methods

There is no automatic comparision of the cache time with the directory time, 
as that would involve a stat call, defeating the purpose of the cache.

What the maildir *resource* (not the lib) does, is that it watches the 
maildir directories. If they change, it does a complete refresh of the 
cache. This mean copies/deletes outside of the resource won't be noticed 
unless the directory is watched. 
findRealKey() would still work for new items, the problem will be with 
deleted items.
The potential slowdown in mixedmaildir might be that listing the content of 
the whole dir will execute N QFile::exists() calls (N = number of mails) in 
best case (max. 2*N calls in worst case), instead of two QDir::entryList() 
calls + checks inside the cache. I meassured the latter to be faster.

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