From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59935: 29.0.60; project-list-buffers is slow Date: Sat, 10 Dec 2022 10:11:15 +0200 Message-ID: <83o7sby8yk.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31947"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59935@debbugs.gnu.org, juri@linkov.net To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 10 09:12:29 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 1p3uyD-00085r-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Dec 2022 09:12:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3uxu-0007ba-MM; Sat, 10 Dec 2022 03:12:10 -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 1p3uxo-0007bE-0N for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 03:12:05 -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 1p3uxm-00062Q-U2 for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 03:12:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3uxm-0005ak-9j for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 03:12:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Dec 2022 08:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59935 X-GNU-PR-Package: emacs Original-Received: via spool by 59935-submit@debbugs.gnu.org id=B59935.167065989221485 (code B ref 59935); Sat, 10 Dec 2022 08:12:02 +0000 Original-Received: (at 59935) by debbugs.gnu.org; 10 Dec 2022 08:11:32 +0000 Original-Received: from localhost ([127.0.0.1]:41337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3uxH-0005aT-Ss for submit@debbugs.gnu.org; Sat, 10 Dec 2022 03:11:32 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:45058) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3uxF-0005aK-Ok for 59935@debbugs.gnu.org; Sat, 10 Dec 2022 03:11:30 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3ux8-0005v7-Tr; Sat, 10 Dec 2022 03:11:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=W+RqFPCPtJ2p2iMSWJNwvx/DAFgwFnYqKxuvfFxju38=; b=DkQLu0l/fNCy 1FwjUT3vC+OdaNWQJtMPF2KQfRZ3U9ZgVULopdxee9EceemZG4bYskmjbNsXflMji+yIZwdaY8Fek HpX/VrkeoM9LrGofJb5AqgWOjCNZ+FhHwZXatKYgV1FG0s2Pw+zZ95smT3ofG8zXWWMP1Cw05bC/f FpDxAi7sAWdgns5stXnyVDam2mCu6/C6ZeFa7yImIMu72AQlVE1Cb32gfRKU5h5uVVzNq7v21aMOv oXns36eoXaVXrD7/9c0O4xxgJZFglfJMsYwIIok9uexx83Cy83UrNliMFDwaASI8Yqdu9S8/x2+IL WmfDyJ6ysS0qBghS2tyf2A==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3ux5-00070I-Nc; Sat, 10 Dec 2022 03:11:22 -0500 In-Reply-To: (message from Dmitry Gutov on Sat, 10 Dec 2022 03:49:47 +0200) 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:250494 Archived-At: > Cc: juri@linkov.net > Date: Sat, 10 Dec 2022 03:49:47 +0200 > From: Dmitry Gutov > > 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. I'm not following. Are you saying that the problem is that the FILTER-PREDICATE argument to list-buffers-noselect calls project-buffers for each buffer? If so, I don't understand why a trivial change to project-list-buffers could not call project-buffers just once, and then reuse the value in the call to list-buffers-noselect both as the BUFFER-LIST argument and (if needed) in the FILTER-PREDICATE argument, using memq. If this is not the problem, then what is? > And the patch is this: Consequently, I don't understand the rationale for this patch, nor for the combined one you posted later. Please elaborate. P.S. Btw, if you are not sure the multiple calls to project-buffers is the reason for the slow operation, how about profiling it to be sure? We may be barking up the wrong tree.