From kmail-devel Mon Dec 01 13:26:04 2003 From: Stephan Kulow Date: Mon, 01 Dec 2003 13:26:04 +0000 To: kmail-devel Subject: Patch: better performance for maildir X-MARC-Message: https://marc.info/?l=kmail-devel&m=107028526222072 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_sF0y/7OtsNdB2kv" --Boundary-00=_sF0y/7OtsNdB2kv Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! As SUSE moves offices, it was decided that moving the NFS server first was a good idea - so now I have to live with a NFS connection through the city for a week. Anyway, after watching kmail compacting folders for two hours, I decided to look at it ;) The biggest problem is that it calls ::access on non-existant files for most of the time. So here is my proposed solution: get the dir listing once and then check string lists instead of asking the file system file per file. This speeds up exiting kmail on a (slow) NFS $HOME from hours to minutes. Greetings, Stephan -- There may be no I in TEAM, but a M and an E. --Boundary-00=_sF0y/7OtsNdB2kv Content-Type: text/x-diff; charset="us-ascii"; name="kmail_nfs" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kmail_nfs" Index: kmfoldermaildir.cpp =================================================================== RCS file: /home/kde/kdepim/kmail/kmfoldermaildir.cpp,v retrieving revision 1.74 diff -u -3 -p -u -b -r1.74 kmfoldermaildir.cpp --- kmfoldermaildir.cpp 29 Nov 2003 18:17:19 -0000 1.74 +++ kmfoldermaildir.cpp 1 Dec 2003 13:01:21 -0000 @@ -238,7 +238,7 @@ int KMFolderMaildir::expungeContents() { // nuke all messages in this folder now QDir d(location() + "/new"); - d.setFilter(QDir::Files); + // d.setFilter(QDir::Files); coolo: QFile::remove returns false for non-files QStringList files(d.entryList()); QStringList::ConstIterator it(files.begin()); for ( ; it != files.end(); ++it) @@ -263,6 +263,9 @@ int KMFolderMaildir::compact() QString subdirNew(location() + "/new/"); QString subdirCur(location() + "/cur/"); + QDir d(subdirNew); + QStringList newFiles(d.entryList()); + for (int i = 0; i < count(); i++) { KMMsgInfo *mi = (KMMsgInfo*)mMsgList[i]; @@ -274,8 +277,7 @@ int KMFolderMaildir::compact() continue; // first, make sure this isn't in the 'new' subdir - QString newFile(subdirNew + filename); - if (QFile::exists(newFile)) + if ( newFiles.contains( filename ) ) moveInternal(subdirNew + filename, subdirCur + filename, mi); // construct a valid filename. if it's already valid, then --Boundary-00=_sF0y/7OtsNdB2kv Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KMail Developers mailing list kmail@kde.org https://mail.kde.org/mailman/listinfo/kmail --Boundary-00=_sF0y/7OtsNdB2kv--