From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#36712: 27.0.50; nnimap unconditionally setting marks in a loop Date: Wed, 17 Jul 2019 18:09:45 -0700 Message-ID: <87k1cg4086.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="56965"; mail-complaints-to="usenet@blaine.gmane.org" To: 36712@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 18 03:11:09 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hnuwu-000EhR-FE for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Jul 2019 03:11:08 +0200 Original-Received: from localhost ([::1]:33552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnuws-0001oX-DJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Jul 2019 21:11:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53281) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnuwp-0001oE-Ec for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:11:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnuwo-0007bw-FF for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:11:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hnuwo-0007bo-BJ for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hnuwo-0007V4-4u for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Jul 2019 01:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36712 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156341220728747 (code B ref -1); Thu, 18 Jul 2019 01:11:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jul 2019 01:10:07 +0000 Original-Received: from localhost ([127.0.0.1]:53207 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hnuvv-0007Tb-B0 for submit@debbugs.gnu.org; Wed, 17 Jul 2019 21:10:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hnuvt-0007TT-Ow for submit@debbugs.gnu.org; Wed, 17 Jul 2019 21:10:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53006) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnuvs-0001DR-OT for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:10:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnuvr-0006on-BL for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:10:04 -0400 Original-Received: from ericabrahamsen.net ([52.70.2.18]:44588 helo=mail.ericabrahamsen.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hnuvp-0006fk-PY for bug-gnu-emacs@gnu.org; Wed, 17 Jul 2019 21:10:02 -0400 Original-Received: from localhost (c-73-254-86-141.hsd1.wa.comcast.net [73.254.86.141]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id F3DA4FA42A for ; Thu, 18 Jul 2019 01:09:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163276 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=nnimap-dont-add-marks.diff 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)) --=-=-=--