diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-10-27 15:35:43 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-06 23:18:01 +0100 |
commit | 59510c41c839004f037a20464f368c445a7a91d1 (patch) | |
tree | e5048ea3c367881f01d9928c4936b1d95088e111 /worker/maildir/worker.go | |
parent | 29205fdd07c09c21c2d5244c6c7e4fae7b6c824f (diff) | |
download | aerc-59510c41c839004f037a20464f368c445a7a91d1.tar.gz |
maildir: keep less data in memory for sorting
Sorting opens and reads portions of every file within a directory in
order to gather the data needed. Specifically, RFC822Headers and
BodyStructure are not needed. The RFC822Headers field stores a lot of
information, and the BodyStructure field requires parsing the body of
the email.
Don't set these two values when parsing.
Note: in my testing, this dropped sorting a 52k archive from 2.2gb of
ram usage, to < 500mb
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/maildir/worker.go')
-rw-r--r-- | worker/maildir/worker.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index 30faddac..de7e8e89 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -448,7 +448,7 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32, wg.Add(1) go func(uid uint32) { defer wg.Done() - info, err := w.msgInfoFromUid(uid) + info, err := w.msgHeadersFromUid(uid) if err != nil { logging.Errorf("could not get message info: %v", err) return @@ -729,6 +729,18 @@ func (w *Worker) msgInfoFromUid(uid uint32) (*models.MessageInfo, error) { return info, nil } +func (w *Worker) msgHeadersFromUid(uid uint32) (*models.MessageInfo, error) { + m, err := w.c.Message(*w.selected, uid) + if err != nil { + return nil, err + } + info, err := m.MessageHeaders() + if err != nil { + return nil, err + } + return info, nil +} + func (w *Worker) handleCheckMail(msg *types.CheckMail) { if msg.Command == "" { w.err(msg, fmt.Errorf("checkmail: no command specified")) |