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.devel Subject: Re: [PATCH] Speed up project-kill-buffers Date: Tue, 4 May 2021 00:43:03 +0300 Message-ID: <477b600f-a69c-179a-20e7-db60c2539599@yandex.ru> References: <87mttcgnke.fsf@posteo.net> 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="6343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 To: Philip Kaludercic , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 03 23:43:52 2021 Return-path: Envelope-to: ged-emacs-devel@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 1ldgM2-0001YK-T7 for ged-emacs-devel@m.gmane-mx.org; Mon, 03 May 2021 23:43:50 +0200 Original-Received: from localhost ([::1]:55412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldgM1-0003UU-Vs for ged-emacs-devel@m.gmane-mx.org; Mon, 03 May 2021 17:43:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldgLO-0002xB-Ui for emacs-devel@gnu.org; Mon, 03 May 2021 17:43:10 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:43942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldgLM-00009T-PA for emacs-devel@gnu.org; Mon, 03 May 2021 17:43:10 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id b19-20020a05600c06d3b029014258a636e8so168275wmn.2 for ; Mon, 03 May 2021 14:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4aCmk/+l3MRRndU7kw0YIy8uBn5EmkfC3z9gTugJ/go=; b=CyBzQyVlruCLQqU+3B2sBaSEKhwsSrj0VZiSU7IzPBHCar//G/t7nQ9XdQsr1mnRTJ k+i+IsETG+U1Wyx6HJv9Lg4Pdk8JirsTvYFrXCKojA8U659EaNpW53rbJjnMVhuFTzSa XfmJPCBUd7u3h9nQh32GkVA6z/CaD7AiDcxoZ2//IFcI66a57Wskf2hdt5UQD6GqCr1H HMPMc3rMI9KtUrDVSFpxrbVD3oUiamsS8WCmVfwOK8TqLbVtgJv8WVGNbebYYiFLZZp4 JmAqVo3X31iAz/ctOIr1wjue/x/w+pI+hsSxPKWKKjeHK3Um1ASn8rBIg1bNwjfRWnSj 5qCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4aCmk/+l3MRRndU7kw0YIy8uBn5EmkfC3z9gTugJ/go=; b=JrwJBIngunl3SY8MuKLDUdnU0SzoZigxjHER7OG3A4LGed1/ijTqR7EAPBM5oQnhc4 RLWflZcXXmyh4YXFEAMreNkbxdAnOBqIca6vs00jGrgcw5yZDRoWpbronkKWhTHB8fl5 ClHkCLNpEbBMSlPHzddrQbUop4nBK3DXRLwvyeJOWXpcLe6G6BRC/jJZaA/NjPp6yLDw y/HANz0Rewl6BU1PQZeUNv7wfLw9RQq96RBp4yekqX6HQMGdMJ1DEB2C9R0Zs34QlE8I FeWbk/38VA8QcT5UAZkcJbfQB+U2dqQuQxTvbYnFyAwDPyayikd/cc5Ux5Y72sUKBMPK x6TQ== X-Gm-Message-State: AOAM530n1zbs9MuYzC2nnFqIYu6dsvIPMWNK1ifHQ4fBkGzEd21TAqdk rKSlLir2gShnbQ6ms8T1THaJ86r5OEg= X-Google-Smtp-Source: ABdhPJwZ7D+TlTt8rNxdSewJs/MlF6qHuJIhRUHkp59UOF0ttdPzXxakfCkRCEaR6+XKl+gbGdlE+w== X-Received: by 2002:a1c:988f:: with SMTP id a137mr17316849wme.81.1620078186845; Mon, 03 May 2021 14:43:06 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id o17sm14604077wrs.48.2021.05.03.14.43.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 May 2021 14:43:05 -0700 (PDT) In-Reply-To: <87mttcgnke.fsf@posteo.net> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32b.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.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:268852 Archived-At: 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?