I'm not sure, due the current Dir type of go-maildir (just string) it
will be needed to use at least one open(3)/close(3) per call of
Dir.Flag, I dropped this patch there, that reduced the loop run time
from 4.5s to 3.4s, still not as good as leaving the file descriptor
opened as I did for aerc.
Yes, I tested this patched by calling both functions (Message.Flags
and Message.Readdir) and panicking if reflect.DeepEqual returned
false, also master aerc and with this patched reports the
same unseen messages count.
On Sat Mar 5, 2022 at 11:28 PM CET, inwit wrote:
Fix a data race due dirInfo pointer being read in the main goroutine
by NewMessageStore and written in the annonymous goroutine launched in
Worker.getDirectoryInfo.
To address the issue https://todo.sr.ht/~rjarry/aerc/16 replace
go-maildir library Dir.Flags with our own based on readdir(3)
Signed-off-by: wagner riffel <w@104d.net>
---
On Mon Feb 28, 2022 at 12:29 AM CET, Robin Jarry wrote:
> This is almost a revert of a commit I made recently to fix a performance
> problem when opening maildir folders containing large number of
> messages:
>
> https://git.sr.ht/~rjarry/aerc/commit/622802d3a5ea980b2d08ff
Sorry, I shoud have checked git-blame first.
> I agree that there is likely a data race but could we find a fix that
> preserves the original fix? Maybe allow incremental dirinfo using
> a channel to keep the app responsive.
It's rare to see issues raised due this race because sleeps are
"synchronizing" the goroutine for the most messages.
While concurrency might be applied here, going through the issue I
found weird that modern hardware would have problems listing 40, 100,
400 thousands of emails, so I started profiling, no surprises on 86%
of the time aerc was hanging on syscalls, that happened to be
go-maildir library (made from here:
https://github.com/emersion/go-maildir/blob/v0.2.0/maildir.go#L178),
I've quickly drafted this patch which in my machine (i7 3770, over 10
years old) took down the loop run time for 400,000 random-generated
emails (~8.5 GB total of data) from ~4.5sec to ~610ms, honestly I
can't feel any difference in UI display time between current master
and this patch (I tried to replicate your benchmark described in
https://todo.sr.ht/~rjarry/aerc/16, "time ./aerc and quitting when the
message view was completely loaded" but I failed find where exactly to
place _exit 🤦), do you think it's still worth adding incremental
dirinfo progress concurrently?
I'm having trouble with this patch. After applying it, I'm getting a ton of
error messages of the form: "could not get flags: maildir: invalid mailfile
format". I've counted and I'm getting one message per each file found in my
Maildir folder structure. The messages appear at startup, even before I try to
load other folders.
The overall speed of the Maildir interface is more or less the same. I'm seeing
a ~20K message folder load in around 20s (with and without the patch), which is
no good.
The same set of messages is processed by notmuch or mutt without complaints.
It could be unrelated, but the fact that before this patch I was getting other
errors like those I reported to maildir.go [0], makes me think that there could
be something related to how maildir.go deals with messages in the first place.
It could also have to do with the fact that (unfortunately) my account is a M$
Office365 account.
Thanks for the patch, in any case.
[0] https://github.com/emersion/go-maildir/issues/12