From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#59935: 29.0.60; project-list-buffers is slow Date: Sat, 10 Dec 2022 03:49:47 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17192"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: juri@linkov.net To: 59935@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 10 02:50:24 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p3p0S-0004GR-QV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Dec 2022 02:50:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3p0D-0001hW-R0; Fri, 09 Dec 2022 20:50:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3p0A-0001hL-G8 for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 20:50:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3p06-0005BU-IQ for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 20:50:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3p06-0001gE-6K; Fri, 09 Dec 2022 20:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: juri@linkov.net, bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Dec 2022 01:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59935 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: juri@linkov.net Original-Received: via spool by submit@debbugs.gnu.org id=B.16706369996444 (code B ref -1); Sat, 10 Dec 2022 01:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Dec 2022 01:49:59 +0000 Original-Received: from localhost ([127.0.0.1]:39770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3p02-0001fs-Ty for submit@debbugs.gnu.org; Fri, 09 Dec 2022 20:49:59 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37218) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3p01-0001fm-AR for submit@debbugs.gnu.org; Fri, 09 Dec 2022 20:49:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3ozx-0001gh-G0 for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 20:49:57 -0500 Original-Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3ozu-00059H-NI for bug-gnu-emacs@gnu.org; Fri, 09 Dec 2022 20:49:52 -0500 Original-Received: by mail-wm1-x32a.google.com with SMTP id n9-20020a05600c3b8900b003d0944dba41so1078120wms.4 for ; Fri, 09 Dec 2022 17:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:from:content-language:subject:to :user-agent:mime-version:date:message-id:sender:from:to:cc:subject :date:message-id:reply-to; bh=J/2hInnGfLS+pagH1DXH722BP/b3RAOGIoVHiN1t7nc=; b=ZAIT2vDaSvviepz5ARfVU2/7CHI7VjqK2PXKsR+GcysQCFJENJFWdNbz5mdvhFglCC KL4360p+4WZSmh/liiR7U31B7GcyfPN6ddielRntHStjODSxp6MfCulhUDQACQf0zC3i u4rCc6W7EsnYB9ti8mBqcMLOrHWIvW7rzrRGGHnTyU13Tul2wONlSnPx33nj5TvXebxq 5y/80cTCBJyX7YwZsn3B9yMZG45UplE8MZpxOW5EdkmiLtA79IkYFm31IfZ0/XwXbKqD xndaqm1l3hBwrkWxG9p/W9PtZFaEsH4imN83Ox/JC52pDUx0EiJqYIxYVaFq3iCq+qIn /5KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:from:content-language:subject:to :user-agent:mime-version:date:message-id:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=J/2hInnGfLS+pagH1DXH722BP/b3RAOGIoVHiN1t7nc=; b=k+R6cEVaN/s6FevkN7mnoRRP7KpvrlxOqwKmQPAyOuT+XlrECzA0dNxshkI+tyHjSV Gbyhj9+Irj+wAvZDzS0p32eVY+q+ogG+4JiOlAUy+3DRazruDH5NqcA5yGyHVQfGa7Tr EJXAv5pPxgsLEef/J0jSGN/GHx8nW4HCxji7D9W9iQ+HYM6TGBNM6+pdgMrrk5xBpfX1 dCEi6T74en8nTOXJNbPkGuaoIllWVR60UfsFR72Ua18RGVIawlFI2hq8F9saPjJqXaji QF/HX0k+M0qupRXadJUdbLrnL0YQqoI4uN9b+Br1UH2KxWbD7DzovWlw113gAgZ25xre VSSA== X-Gm-Message-State: ANoB5plb6tUXhfdjO6Y+N03Z1eUb9U0KRUmDzYQVWW+YdTrW3ta1kJnH 1tK78chlH0wl3rujUKALTU1Pixmq8w0= X-Google-Smtp-Source: AA0mqf4KkPpSKmLg4aMILlD6mfvQobRFO2dcM+/L/uppGR/MqqFlYz1rko70Z0W6x1Sx6YV5eglCWQ== X-Received: by 2002:a05:600c:500b:b0:3cf:6d5b:8768 with SMTP id n11-20020a05600c500b00b003cf6d5b8768mr6521828wmr.8.1670636989154; Fri, 09 Dec 2022 17:49:49 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id t2-20020a1c7702000000b003cffd3c3d6csm1278996wmi.12.2022.12.09.17.49.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 17:49:48 -0800 (PST) Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250481 Archived-At: X-Debbugs-Cc: juri@linkov.net When you invoke 'C-x p C-b', there's a noticeable pause before the buffer list is displayed. It's ~400ms over here when there are 46 non-hidden buffers in the running session. What I think is happening, the predicate is called 46, which in turn calls (project-buffers pr) 46 times, and that ends up being 46 times slower than one might have anticipated. Not sure what's the best fix here (especially in time for the release), but if the FILTER-PREDICATE arg to list-buffers-noselect turned into a factory function (e.g. FILTER-PREDICATE-MAKER), that would be one solution. Another would be to only leave the legacy codepath: it's not affected, project-buffers is only called once there. Curiously, though, it shows a different list of buffers. It also includes "hidden" buffers - diff-syntax, Echo Area, etc. We should look into that either way. And the patch is this: diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 016dfdd5b4..ad49df0423 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1342,16 +1342,13 @@ project-list-buffers (interactive "P") (let ((pr (project-current t))) (display-buffer - (if (version< emacs-version "29.0.50") - (let ((buf (list-buffers-noselect arg (project-buffers pr)))) - (with-current-buffer buf - (setq-local revert-buffer-function - (lambda (&rest _ignored) - (list-buffers--refresh (project-buffers pr)) - (tabulated-list-print t)))) - buf) - (list-buffers-noselect - arg nil (lambda (buf) (memq buf (project-buffers pr)))))))) + (let ((buf (list-buffers-noselect arg (project-buffers pr)))) + (with-current-buffer buf + (setq-local revert-buffer-function + (lambda (&rest _ignored) + (list-buffers--refresh (project-buffers pr)) + (tabulated-list-print t)))) + buf)))) (defcustom project-kill-buffer-conditions '(buffer-file-name ; All file-visiting buffers are included.