~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
6 5

[PATCH aerc] notmuch: reload all changed messages on DB change

Details
Message ID
<20240807205528.240439-2-me@jasoncarloscox.com>
DKIM signature
pass
Download raw message
Patch: +41 -23
This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7.

As discussed in the aerc-devel thread for the reverted patch, the
performance improvement comes with an issue: changes to message tags are
no longer immediately reflected in the UI. This issue occurs whether the
tags are modified from within aerc or externally with the notmuch CLI.
The message list also flickers any time tag changes are made.

Further, commit c36ed72e4a59 ("notmuch: speed up lastmod query")
dramatically reduces the number of messages which are re-indexed when
the database changes, likely eliminating the need for the reverted
performance improvement anyway.

Fixes: c56649fe5291 ("notmuch: don't reload all message on change")
Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/53729
Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/54028
Reported-by: Robin Dapp <rdapp@modk.org>
Reported-by: Ryan Winograd <ryan@thewinograds.com>
Cc: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
Signed-off-by: Jason Cox <me@jasoncarloscox.com>
---
 worker/notmuch/eventhandlers.go | 15 ++++++++--
 worker/notmuch/worker.go        | 49 +++++++++++++++++++--------------
 2 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/worker/notmuch/eventhandlers.go b/worker/notmuch/eventhandlers.go
index e4c2536e..fb454e08 100644
--- a/worker/notmuch/eventhandlers.go
+++ b/worker/notmuch/eventhandlers.go
@@ -9,6 +9,7 @@ import (
	"path/filepath"
	"strconv"

	"git.sr.ht/~rjarry/aerc/lib/log"
	"git.sr.ht/~rjarry/aerc/worker/types"
)

@@ -75,9 +76,17 @@ func (w *worker) updateChangedMessages() error {
	if err != nil {
		return fmt.Errorf("Couldn't get updates messages: %w", err)
	}
	w.w.PostMessage(&types.DirectoryContents{
		Uids: uids,
	}, nil)
	for _, uid := range uids {
		m, err := w.msgFromUid(uid)
		if err != nil {
			log.Errorf("%s", err)
			continue
		}
		err = w.emitMessageInfo(m, nil)
		if err != nil {
			log.Errorf("%s", err)
		}
	}
	w.state = newState
	return nil
}
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index 249347ce..c6a81050 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -433,30 +433,12 @@ func (w *worker) handleFetchMessageHeaders(
			w.emitMessageInfoError(msg, uid, err)
			continue
		}
		info, err := m.MessageInfo()
		err = w.emitMessageInfo(m, msg)
		if err != nil {
			w.w.Errorf("could not emit message info: %v", err)
			w.emitMessageInfoError(msg, uid, err)
			continue
		}
		switch {
		case len(w.headersExclude) > 0:
			info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true)
		case len(w.headers) > 0:
			info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false)
		}

		switch msg {
		case nil:
			w.w.PostMessage(&types.MessageInfo{
				Info: info,
			}, nil)
		default:
			w.w.PostMessage(&types.MessageInfo{
				Message: types.RespondTo(msg),
				Info:    info,
			}, nil)
		}

	}
	w.done(msg)
	return nil
@@ -698,6 +680,33 @@ func (w *worker) emitMessageInfoError(msg types.WorkerMessage, uid uint32, err e
	}, nil)
}

func (w *worker) emitMessageInfo(m *Message,
	parent types.WorkerMessage,
) error {
	info, err := m.MessageInfo()
	if err != nil {
		return fmt.Errorf("could not get MessageInfo: %w", err)
	}
	switch {
	case len(w.headersExclude) > 0:
		info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true)
	case len(w.headers) > 0:
		info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false)
	}
	switch parent {
	case nil:
		w.w.PostMessage(&types.MessageInfo{
			Info: info,
		}, nil)
	default:
		w.w.PostMessage(&types.MessageInfo{
			Message: types.RespondTo(parent),
			Info:    info,
		}, nil)
	}
	return nil
}

func (w *worker) emitLabelList() {
	tags := w.db.ListTags()
	w.w.PostMessage(&types.LabelList{Labels: tags}, nil)
-- 
2.46.0

[aerc/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D39ZBAUWAZS4.2ISV1S1Z2JT4H@fra02>
In-Reply-To
<20240807205528.240439-2-me@jasoncarloscox.com> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: SUCCESS in 1m58s

[notmuch: reload all changed messages on DB change][0] from [Jason Cox][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/54345
[1]: me@jasoncarloscox.com

✓ #1297051 SUCCESS aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1297051
✓ #1297052 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1297052
Details
Message ID
<a52b5dd1-4f42-40c6-8552-de2599390f49@ferdinandy.com>
In-Reply-To
<20240807205528.240439-2-me@jasoncarloscox.com> (view parent)
DKIM signature
missing
Download raw message
2024. aug. 7. 22:57:04 Jason Cox <me@jasoncarloscox.com>:

> This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7.

Shouldn't reverting be a revert commit by Robin?
Details
Message ID
<D39ZTW0W9NC6.2LR2F9T6RD8RC@jasoncarloscox.com>
In-Reply-To
<a52b5dd1-4f42-40c6-8552-de2599390f49@ferdinandy.com> (view parent)
DKIM signature
pass
Download raw message
On Wed Aug 7, 2024 at 5:07 PM EDT, Bence Ferdinandy wrote:
> 2024. aug. 7. 22:57:04 Jason Cox <me@jasoncarloscox.com>:
>
> > This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7.
>
> Shouldn't reverting be a revert commit by Robin?

I don't know; I didn't see the revert process documented anywhere, and I
thought the patch should be reverted, so I sent my own revert commit.
Totally fine by me if Robin wants to handle it, though!
Details
Message ID
<f2766168-4ef7-4d35-af5a-abefa7cf0414@app.fastmail.com>
In-Reply-To
<20240807205528.240439-2-me@jasoncarloscox.com> (view parent)
DKIM signature
pass
Download raw message
On Wed, 7 Aug 2024, at 22:55, Jason Cox wrote:
> This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7.
>
> [...snip...]

Somebody else reported similar issues on IRC. I have no objection to
reverting this until we can properly debug what's going on (I don't have
the time to do so right now right now).

For context, without my patch each time I mark a message as seen or
deleted a message, I'd get CPU spike at 150% for ~60 seconds. With this
patch, the operation took just 2s. Others couldn't properly reproduce my
issue, so I'll open a ticket to track it properly before proposing
another patch.

-- 
Hugo
Details
Message ID
<D3AKX06EBBOC.3G9ET8T3SO5TP@jasoncarloscox.com>
In-Reply-To
<f2766168-4ef7-4d35-af5a-abefa7cf0414@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
On Thu Aug 8, 2024 at 4:49 AM EDT, Hugo Osvaldo Barrera wrote:
> For context, without my patch each time I mark a message as seen or
> deleted a message, I'd get CPU spike at 150% for ~60 seconds. With this
> patch, the operation took just 2s. Others couldn't properly reproduce my
> issue, so I'll open a ticket to track it properly before proposing
> another patch.

Have you tested without this patch but with commit c36ed72e4a59
("notmuch: speed up lastmod query")? It seems like that commit might
solve most of your performance problems by reducing the number of
messages that are re-indexed when the database changes.

Applied: [PATCH aerc] notmuch: reload all changed messages on DB change

Details
Message ID
<172413887181.312031.3924547263769973221@ringo.local>
In-Reply-To
<20240807205528.240439-2-me@jasoncarloscox.com> (view parent)
DKIM signature
pass
Download raw message
Jason Cox <me@jasoncarloscox.com> wrote:
> This reverts commit c56649fe5291b725f14b45550a68cc7d0dc16ff7.
>
> As discussed in the aerc-devel thread for the reverted patch, the
> performance improvement comes with an issue: changes to message tags are
> no longer immediately reflected in the UI. This issue occurs whether the
> tags are modified from within aerc or externally with the notmuch CLI.
> The message list also flickers any time tag changes are made.
>
> Further, commit c36ed72e4a59 ("notmuch: speed up lastmod query")
> dramatically reduces the number of messages which are re-indexed when
> the database changes, likely eliminating the need for the reverted
> performance improvement anyway.
>
> Fixes: c56649fe5291 ("notmuch: don't reload all message on change")
> Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/53729
> Link: https://lists.sr.ht/~rjarry/aerc-devel/patches/54028
> Reported-by: Robin Dapp <rdapp@modk.org>
> Reported-by: Ryan Winograd <ryan@thewinograds.com>
> Cc: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
> Signed-off-by: Jason Cox <me@jasoncarloscox.com>
> ---

Acked-by: Robin Jarry <robin@jarry.cc>

Applied, thanks.

To git@git.sr.ht:~rjarry/aerc
   fff69046b02f..b03750473db6  master -> master
Reply to thread Export thread (mbox)