Bug 279149 - Slow mark as read and folder loading
Summary: Slow mark as read and folder loading
Status: RESOLVED UNMAINTAINED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: Maildir Resource (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 10:30 UTC by András Manţia
Modified: 2017-01-07 22:03 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description András Manţia 2011-08-02 10:30:34 UTC
I added a new maildir resource and set it to my Mail folder. This resulted in all mails appearing as unread. Now if I click on a folder with many mails (3000 to 30000), it takes even minutes to load. This is somewhat expected as KMail's message list is slow as well. The problem appears when I try to mark them as read (right click on a folder, Mark all Mails as Read). This is also slow, and after the messages are marked as read, the resources starts to fetch again all the mails.
I get lots of
akonadi_maildir_resource_0 (0x884c90) 70850 UID FETCH 226252 FULLPAYLOAD CACHEONLY ANCESTORS INF EXTERNALPAYLOAD (UID REMOTEID REMOTEREVISION COLLECTIONID FLAGS SIZE)  

fetches (with the UID increasing).

If I attach the debugger to the resource, it shows it is busy inside MaildirResource::itemChanged. The changed part is the FLAGS part, that should be because of the Mark as Read. The code goes through this part then:
if ( mSettings->readOnly() || !payloadChanged ) {
      changeProcessed(); <---- here
      return;
    }

Now if you do the right click on a folder->Mark all Mails as Read for a few folders one after the other, you will see the busy indicator near the folders. The messages will be eventually marked as read, but the busy indicator remains due to the above fetches.
Curiously I let the machine running over night and it was still busy in the morning, with heavy disk activity from the maildir resource. The agent_config_akonadi_maildir_resource_0_changes.dat grew also big, it was 13MB. 

Furthermore even after I restarted the akonadi server and cleaned up the changes.dat file, the first access to a folder is very slow and the business is in the resource, not kmail. Further accesses are somewhat faster, even if I restart kmail.
Comment 1 András Manţia 2011-09-16 17:31:34 UTC
Unread issue fixed. The other one has two causes:
- disk IO bottleneck, as the maildir resource reads the headers from all the files
- maildir also creates one create job per mail, but only sends this to the server after all headers were read. 
- maildir resource keeps the read headers in memory

The above results is first high IO load in the resource, then high CPU load in the server and the database process, then high IO and CPU load in the database. This also causes high memory usage by the maildir resource if the read folder contains a lot of files.
Comment 2 András Manţia 2011-09-17 11:04:18 UTC
Mark as read should be faster now.
Comment 3 Kevin Kofler 2012-06-26 20:33:03 UTC
KMail from kdepim 4.8.4 takes about 2 minutes to process my main maildir folder (currently at 109900 messages). kdepim 4.4.x was able to do it in a few seconds.
Comment 4 Kevin Kofler 2012-06-26 20:34:10 UTC
(To clarify: "process" as in "load so that it can actually display message contents". First it takes a few seconds to show the message list, and then some more time to actually be able to display contents, totaling to ~2 minutes.)
Comment 5 András Manţia 2012-10-13 08:19:42 UTC
If you see the messages in the list in a few seconds, then it is not the resource that is slow. It might be the messagelist reorganizing the items (it can be REALLY slow for large folders with lots of unread mails or large threads and it depends on how it is configured: sort order, threading, view, etc.).
Comment 6 Dennis Schridde 2013-01-14 18:21:21 UTC
I also experience the slow-mark-as-read issue when just viewing an email on KDE 4.8.5 / Ubuntu Precise 12.04. My client is configured to mark emails as read right when it displays them. This, however, has a significant delay (most noticable on my netbook) - probably because the changes need to be synced from Kontact to Akonadi.

Sometimes it happens that I already switched to other folders to read the next batch of unread mails, but the folders are still displayed in Kontact as containing unread items. It will take a while (several seconds to a minute, maybe) for Kontact to show the correct status.

Also the folder status does not always resemble the status of the emails in the email list - sometimes I read all emails, but the folder list still displays the folder as containing X unread items.

Sometimes the delay (for syncing Kontact with Akonadi) is so long, that Akonadi started the next sync-with-IMAP-server operation in the background, which will cause the read status to be reset to that on the server (i.e. unread). Then I have to go again through the folders and mark emails as read manually. This usually does not affect all folders (probably because Akonadi also already synced some of my mails back up to the IMAP-server), but it is still annoying and confusing.
Comment 7 Dennis Schridde 2013-01-14 18:24:45 UTC
Regarding the slow folder display: For me that stems from Kontact having to fetch the mails from Akonadi and then collate them into threads. Some time ago I created a suggestion / wishlist-bug on that matter:
Fetching mails faster: bug #311781
Faster thread collation: bug #311780
Comment 8 Dennis Schridde 2013-01-14 20:58:38 UTC
(In reply to comment #6)
> Also the folder status does not always resemble the status of the emails in
> the email list - sometimes I read all emails, but the folder list still
> displays the folder as containing X unread items.
What I meant with that: The status displayed in the email list sometimes differs from the number of unread messages that the folder list displays for this folder. I.e. I am irritated by the folder list displaying 1 (e.g.) unread email, but I cannot find any unread email in the folder and the "+" shortcut does not jump to an unread email either. Only after a delay of a few seconds the folder list shows the correct number.
Comment 9 Fabian Henze 2014-06-01 11:57:02 UTC
This bites me as well when marking a folder with 17k messages on my own IMAP server as read. Any update on this?
Comment 10 Denis Kurz 2016-09-24 20:42:35 UTC
This bug has only been reported for versions older than KDEPIM 4.14 (at most akonadi-1.3). Can anyone tell if this bug still present?

If noone confirms this bug for a recent version of akonadi (part of KDE Applications 15.08 or later), it gets closed in about three months.
Comment 11 Denis Kurz 2017-01-07 22:03:16 UTC
Just as announced in my last comment, I close this bug. If you encounter it again in a recent version (at least 5.0 aka 15.08), please open a new one unless it already exists. Thank you for all your input.