matcha icon indicating copy to clipboard operation
matcha copied to clipboard

PERF: JMAP batch operations use individual requests in a loop

Open andrinoff opened this issue 7 months ago • 2 comments

Is your feature request related to a problem?

MoveEmails, DeleteEmails, and ArchiveEmails in backend/jmap/jmap.go loop over UIDs and call individual methods, resulting in N network round-trips for N emails. For example:

func (p *Provider) MoveEmails(ctx context.Context, uids []uint32, srcFolder, dstFolder string) error {
    for _, uid := range uids {
        if err := p.MoveEmail(ctx, uid, srcFolder, dstFolder); err != nil {
            return err
        }
    }
    return nil
}

JMAP natively supports batch operations — multiple Email/set updates can be combined in a single request.

Describe the solution you'd like

Batch all UIDs into a single JMAP Email/set request with multiple updates. This reduces N round-trips to 1, significantly improving performance for bulk operations (e.g. selecting 50 emails and archiving them).

Describe alternatives you've considered

Parallelizing the individual requests with goroutines, but this adds complexity and still uses more bandwidth than a single batch request.

Additional context

The same pattern applies to DeleteEmails and ArchiveEmails in the same file.

andrinoff avatar Apr 15 '26 19:04 andrinoff

This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.

floatpanebot avatar May 16 '26 05:05 floatpanebot

Closing due to inactivity. Reopen if still relevant.

floatpanebot avatar May 30 '26 05:05 floatpanebot