emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Speed up project-kill-buffers


From: Dmitry Gutov
Subject: Re: [PATCH] Speed up project-kill-buffers
Date: Tue, 4 May 2021 00:43:03 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1

Hi Philip,

On 03.05.2021 12:43, Philip Kaludercic wrote:
I've noticed that sometimes project-kill-buffers is noticeably slow, and
it seems like it's has to do with project--buffer-list working on remote
files. The function goes through every buffer and calls
(project-current), even if the buffer is related to a remote file that
cannot be part of the current project.

The patch I attach below is a simple fix to avoid checking files that
cannot be part of the current project. Or are there any edge-cases that
this code approach breaks?

In theory, files on different hosts could be part of the same "project" (in Eli's sense, see https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00051.html and the other messages in that thread), but we'll get there when we get there. Probably by adding a method like project-contains-file-p.

In the meantime (until somebody complains), the patch like this should be fine. I haven't found any significant difference in performance, but I don't have Tramp buffers in the current session.

Pushed to master, thanks.

If we do believe that a project can only span one host, we could also change the check like this:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 33827136a1..6f911e4fbe 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1120,11 +1120,11 @@ project-kill-buffer-conditions

 (defun project--buffer-list (pr)
   "Return the list of all buffers in project PR."
-  (let ((remote-project-p (file-remote-p (project-root pr)))
+  (let ((conn (file-remote-p (project-root pr)))
         bufs)
     (dolist (buf (buffer-list))
- (when (and (let ((remote (file-remote-p (buffer-local-value 'default-directory buf))))
-                   (if remote-project-p remote (not remote)))
+      (when (and (equal conn
+ (file-remote-p (buffer-local-value 'default-directory buf)))
                  (equal pr
                         (with-current-buffer buf
                           (project-current))))

WDYT?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]