From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ship Mints Newsgroups: gmane.emacs.bugs Subject: bug#73718: 31.0.50; Severe performance issue with Tramp and project-mode-line-format Date: Sun, 13 Oct 2024 09:31:12 -0400 Message-ID: References: <874j5lzhdn.fsf.ref@aol.com> <874j5lzhdn.fsf@aol.com> <29ebe27b-89d6-4861-8c5e-3db50a1660f3@yandex.ru> <86a5fdmg3h.fsf@mail.linkov.net> <71d57a53-f8d8-45f7-bff6-09f5acf292f8@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000007dc27006245bbce7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16456"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ergus , Michael Albinus , 73718@debbugs.gnu.org, Juri Linkov To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 13 15:33:08 2024 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 1szyiZ-00042p-R5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Oct 2024 15:33:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szyiH-0006vd-BK; Sun, 13 Oct 2024 09:32:49 -0400 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 1szyiF-0006vE-6c for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 09:32:47 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szyiE-0003gt-O8 for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 09:32:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=PHui1KUVWIeWLlA50it8TBWx/aaXVDz2uobWBQt6QmY=; b=P0inig7BJHAaklS4Ju5PTAKot8t/f/G2vKF3whH/tv62chLlnaFtJWApKeKt+XIakTfSHtc1fio/X04XU58z5V2OVnduydgBrLB7CBO1mc/P3V2kL9D0F5lb2eRlT1v2oWG3X/dXcgDNPDWTpRSW4K+cD2iXjvvWMGC6AbqTVaT2l+jJgHlI8SyEeMSGW4wUMMdf+qbc8l/gUPnMOU+3YFRNaFoqFU0TWan1dqZmyiGhV0RtPWZJg4NWlsCscMldNILp+GrC5OjpUR8BDIB4PjX1FXZQOa9/o8k9zrUiTG+UwJLSPjJrMRgZagptCgednzH1aZ/sHsj0xlsbA9u5QQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1szyiU-0002ds-47 for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 09:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ship Mints Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Oct 2024 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73718 X-GNU-PR-Package: emacs Original-Received: via spool by 73718-submit@debbugs.gnu.org id=B73718.172882636210125 (code B ref 73718); Sun, 13 Oct 2024 13:33:02 +0000 Original-Received: (at 73718) by debbugs.gnu.org; 13 Oct 2024 13:32:42 +0000 Original-Received: from localhost ([127.0.0.1]:50574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szyi9-0002dE-WA for submit@debbugs.gnu.org; Sun, 13 Oct 2024 09:32:42 -0400 Original-Received: from mail-vk1-f181.google.com ([209.85.221.181]:57720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szyi7-0002d6-RA for 73718@debbugs.gnu.org; Sun, 13 Oct 2024 09:32:40 -0400 Original-Received: by mail-vk1-f181.google.com with SMTP id 71dfb90a1353d-50d494ac189so226093e0c.3 for <73718@debbugs.gnu.org>; Sun, 13 Oct 2024 06:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728826283; x=1729431083; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PHui1KUVWIeWLlA50it8TBWx/aaXVDz2uobWBQt6QmY=; b=RUPT+CSnlSJ3CZ92E8DYhj6ZJ9ccIGbfR6uHe3tvchs+5vKDKlEc4WwywoeGdNLGJT 6yrt9XgB8ARpxuUQ6RHxHuU03ke8eD3pLGJlx3YN6wghDWSPHm37y5KOqlW3I7Ct99o7 ufF0zz8MS2lnVo0ZtCSVDiIKaFVXFkdvyEIJu7aIM8G8KqQ48VA8C8MzUlkFjFMjFH8q yZ6IA7Gx+tcbWrCr4KC4XuvDCaHC73/Gj3dl9/43e66bASxA+MjATfXsMNzu9KVd8oDy X16VLdXx9VykpruJWZvrBLHb8QukD0AT0UOA5uudluULclO7vrWKsj6h2ZGhGI8GHXO0 UYaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728826283; x=1729431083; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PHui1KUVWIeWLlA50it8TBWx/aaXVDz2uobWBQt6QmY=; b=bAsr/pyAvrrL6yxfQ76wIYnUis+MF9+srTDIvXP6Sm2XpxjzYwQRY3IJjDzrnZjR8V RDXpP617wrREUIkDQBMIIPGyrue/dZRHS0yqLi27kK0fhsXLLVTjt4V8+589LgRrA7rJ DbPu+ZM5htBopYq3Ir7B4xpIVB9SSNTTr5di28Y2OJJ/nJPqFXa+PkUKo5zZ36nTTc/G IbCUeQDmo/IbA3WzZ5nnEDGAZTvmAGYHNYH4UAXGF5JgtZtWtdtaZLXFyKZ/wzMUINpH gajhvdVM6EesitV1f9kAXEjTM0forj/srAYswq8rqq3AiIfBNHy46y958BUfJ6raRhI5 avdQ== X-Forwarded-Encrypted: i=1; AJvYcCULFvTt5Q6bpj1f3urr3Sf1kj51nAgLIhwnNBgLIxlUOvVR8pR98hnC5L6IGomACguNwfLc4A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxuU8eJx+m928pQkZ3ZFbhYc0VynZvmKXUlBXvOeKi5wM3433Xv JJKqyEoc0GnV0uxW/MYjSno7zzVfiB08UPAt94F5+cIxz8jlFPIxWZiNiMWEPZ4jzGNOONYf8nv gXbJZsUT0QmYciJ9OeoxtFNg0O3Y= X-Google-Smtp-Source: AGHT+IENIyEATBNwx4tnscMF6W5f5KxCFOLYgeNtgneSM89YLeAFJw0skhgHlO/C7U6JIaQDumPxEY/L5plJ6AtmAEY= X-Received: by 2002:a05:6122:209f:b0:50d:35d9:ad5a with SMTP id 71dfb90a1353d-50d35d9b726mr3043654e0c.5.1728826283243; Sun, 13 Oct 2024 06:31:23 -0700 (PDT) In-Reply-To: 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:293518 Archived-At: --0000000000007dc27006245bbce7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Forgot to add this counterpart for when you want to use a non-project semaphore but also want to project-current to tell the truth about being a non-project: (defun my/project-current-non-project-advice (orig-fun &rest args) (let ((p (apply orig-fun args))) (when (and p (string=3D (project-name p) my:project--non-project-dir)= ) (setq p nil)) p)) (advice-add #'project-current :around #'my/project-current-non-project-advice)) On Fri, Oct 11, 2024 at 10:35=E2=80=AFAM Ship Mints w= rote: > In addition to guarding project-try-vc, I also have a customized cache fo= r > non-projects specifically to get around the incessant retesting for what > are effectively invariant conditions. > > If of any utility to others: > > (use-package project > ... > (defconst my:project--non-project-dir ".") ; nil disables the cache; > NOTE: eglot relies on project-root so this has to be a real path > (defun my/project-try-non-project-cache (dir) > (unless (and my:project-vc-inhibit-remote (file-remote-p dir)) ; yet > another optional remote guard > (let ((proj (cons 'transient (or my:project--non-project-dir > (expand-file-name dir))))) > (vc-file-setprop dir 'project-vc proj) ; project caches via vc > internal properties > proj))) > (add-to-list 'project-find-functions #'my/project-try-non-project-cache > 'append)) > > ;; customized project current name function that respects > ;; non-project marker and returns nil if a non-project > (defun my/project-current-name (&optional buf) > "Return the current project name for BUF, or nil if a non-project. > If BUF is nil, the current buffer is used." > (with-current-buffer (or buf (current-buffer)) > (when-let* ((p (project-current)) > (pn (project-name p))) > (unless (string=3D pn my:project--non-project-dir) > pn)))) > ... > ) > > On Thu, Oct 10, 2024 at 8:38=E2=80=AFPM Dmitry Gutov w= rote: > >> On 09/10/2024 19:10, Juri Linkov wrote: >> > Or maybe better to cache the value of project-name on remove projects. >> >> Just the project->project-name mapping? Why not. I suppose there'd still >> be a pause when switching projects, but it's not as bad. >> >> For general caching, from past threads it seems the most problematic >> case is "no project". Because OT1H it's still costly it terms of remote >> I/O. But on the other, this is exactly when the cache might get invalid >> soon (because the user will initialize a Git repo, or create another >> root marker, etc). >> >> I guess we should come back to this after bug#72300. >> >> >> >> --0000000000007dc27006245bbce7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Forgot to add this counterpart for when you want to use a non-project se= maphore but also want to project-current to tell the truth about being a no= n-project:

= =C2=A0 (defun my/project-current-non-project-advice (orig-fun &rest arg= s)
=C2=A0 =C2=A0 (let ((p (apply orig-fun args)))
=C2=A0 =C2=A0 =C2= =A0 (when (and p (string=3D (project-name p) my:project--non-project-dir))<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq p nil))
=C2=A0 =C2=A0 =C2=A0 p))=C2=A0 (advice-add #'project-current :around #'my/project-current-= non-project-advice))

On Fri, Oct 11, 2024 at 10:35=E2=80=AFAM Ship Min= ts <shipmints@gmail.com> w= rote:
In ad= dition to guarding=C2=A0project-try-vc, I also have a customized cache for = non-projects specifically to get around the incessant retesting for what ar= e effectively invariant conditions.

If of any utility to others:

(use-package project
...
=C2=A0 (defconst my:project--= non-project-dir ".") ; nil disables the cache; NOTE: eglot relies= on project-root so this has to be a real path
=C2=A0 (defun my/project-= try-non-project-cache (dir)
=C2=A0 =C2=A0 (unless (and my:project-vc-inh= ibit-remote (file-remote-p dir)) ; yet another optional remote guard
=C2= =A0 =C2=A0 =C2=A0 (let ((proj (cons 'transient (or my:project--non-proj= ect-dir (expand-file-name dir)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (vc-file-= setprop dir 'project-vc proj) ; project caches via vc internal properti= es
=C2=A0 =C2=A0 =C2=A0 =C2=A0 proj)))
=C2=A0 (add-to-list 'proje= ct-find-functions #'my/project-try-non-project-cache 'append))
<= br>=C2=A0 ;; customized project current name function that respects
=C2=A0 ;; non-pr= oject marker and returns nil if a non-project
=C2=A0 (defun my/project-c= urrent-name (&optional buf)
=C2=A0 =C2=A0 "Return the current p= roject name for BUF, or nil if a non-project.
If BUF is nil, the current= buffer is used."
=C2=A0 =C2=A0 (with-current-buffer (or buf (curre= nt-buffer))
=C2=A0 =C2=A0 =C2=A0 (when-let* ((p (project-current))
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (pn (project= -name p)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (string=3D pn my:project-= -non-project-dir)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pn))))
...
)

On Thu, Oct 10,= 2024 at 8:38=E2=80=AFPM Dmitry Gutov <dgutov@yandex.ru> wrote:
On 09/10/2024 19:10, Juri Linkov wrote= :
> Or maybe better to cache the value of project-name on remove projects.=

Just the project->project-name mapping? Why not. I suppose there'd s= till
be a pause when switching projects, but it's not as bad.

For general caching, from past threads it seems the most problematic
case is "no project". Because OT1H it's still costly it terms= of remote
I/O. But on the other, this is exactly when the cache might get invalid soon (because the user will initialize a Git repo, or create another
root marker, etc).

I guess we should come back to this after bug#72300.



--0000000000007dc27006245bbce7--