unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: 36712@debbugs.gnu.org
Subject: bug#36712: 27.0.50; nnimap unconditionally setting marks in a loop
Date: Wed, 17 Jul 2019 18:09:45 -0700	[thread overview]
Message-ID: <87k1cg4086.fsf@ericabrahamsen.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]


I started doing some very basic profiling of Gnus, and noticed that
getting new mail was resulting in a couple thousand calls to
`gnus-info-set-entry', as well as some of the range manipulation
functions.

It looks like updating IMAP group marks using qresync would loop over
all possible flag/mark pairs and unconditionally set everything, even
when there was nothing to set. With fewer than 100 IMAP groups in total,
that was a couple thousand extra function calls. Most of them with nil
arguments, but still.

I'm not super familiar with the code in question, but the attached diff
looks like it will pull the qresync behavior in line with the
non-qresync behavior, so I'm hoping it's correct. It cuts way down on
function calls, anyway!




In GNU Emacs 27.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.24.10)
 of 2019-07-15 built on slip
Repository revision: c687f25ee24bd29d623a23819eef930937252b25
Windowing system distributor 'The X.Org Foundation', version 11.0.12005000
System Description:	Arch Linux

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnimap-dont-add-marks.diff --]
[-- Type: text/x-patch, Size: 1367 bytes --]

diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 67c5db1e04..5f8e9d5ec0 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -1702,18 +1702,19 @@ nnimap-update-qresync-info
 	     (cdr (or (assoc (caddr type) flags) ; %Flagged
 		      (assoc (intern (cadr type) obarray) flags)
 		      (assoc (cadr type) flags))))) ; "\Flagged"
-	(setq marks (delq ticks marks))
-	(pop ticks)
-	;; Add the new marks we got.
-	(setq ticks (gnus-add-to-range ticks new-marks))
-	;; Remove the marks from messages that don't have them.
-	(setq ticks (gnus-remove-from-range
-		     ticks
-		     (gnus-compress-sequence
-		      (gnus-sorted-complement existing new-marks))))
-	(when ticks
-	  (push (cons (car type) ticks) marks)))
-      (gnus-info-set-marks info marks t))
+	(when new-marks
+	  (setq marks (delq ticks marks))
+	  (pop ticks)
+	  ;; Add the new marks we got.
+	  (setq ticks (gnus-add-to-range ticks new-marks))
+	  ;; Remove the marks from messages that don't have them.
+	  (setq ticks (gnus-remove-from-range
+		       ticks
+		       (gnus-compress-sequence
+			(gnus-sorted-complement existing new-marks))))
+	  (when ticks
+	    (push (cons (car type) ticks) marks))
+	  (gnus-info-set-marks info marks t))))
     ;; Add vanished to the list of unexisting articles.
     (when vanished
       (let* ((old-unexists (assq 'unexist marks))

             reply	other threads:[~2019-07-18  1:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  1:09 Eric Abrahamsen [this message]
     [not found] ` <handler.36712.B.156341220728747.ack@debbugs.gnu.org>
2019-07-25 15:32   ` bug#36712: Acknowledgement (27.0.50; nnimap unconditionally setting marks in a loop) Eric Abrahamsen
2019-07-25 17:03     ` Lars Ingebrigtsen
2019-07-25 19:26       ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1cg4086.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=36712@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).