From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#51622: 29.0.50; [PATCH v2] Abbreviate remote home directories in `abbreviate-file-name' Date: Mon, 8 Nov 2021 10:32:53 -0800 Message-ID: <493647c2-74af-52fc-d55e-42280e893694@gmail.com> References: <5ac0b5f3-302c-2f96-771c-8d38088aa573@gmail.com> <87mtmhmh60.fsf@gmx.de> <87a6ihchbo.fsf@gmx.de> <87sfw7u7zw.fsf@gmx.de> <87v912od0s.fsf@gmx.de> 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="15293"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51622@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 08 19:34:13 2021 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 1mk9TA-0003kb-Kx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Nov 2021 19:34:12 +0100 Original-Received: from localhost ([::1]:34398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mk9T8-00020g-Vv for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 08 Nov 2021 13:34:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mk9T0-0001zX-8q for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2021 13:34:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mk9T0-0006ek-0x for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2021 13:34:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mk9Sz-00021b-UT for bug-gnu-emacs@gnu.org; Mon, 08 Nov 2021 13:34:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Nov 2021 18:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51622 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51622-submit@debbugs.gnu.org id=B51622.16363963827694 (code B ref 51622); Mon, 08 Nov 2021 18:34:01 +0000 Original-Received: (at 51622) by debbugs.gnu.org; 8 Nov 2021 18:33:02 +0000 Original-Received: from localhost ([127.0.0.1]:59454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mk9S2-000202-CV for submit@debbugs.gnu.org; Mon, 08 Nov 2021 13:33:02 -0500 Original-Received: from mail-pg1-f173.google.com ([209.85.215.173]:38783) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mk9S0-0001zX-M2 for 51622@debbugs.gnu.org; Mon, 08 Nov 2021 13:33:01 -0500 Original-Received: by mail-pg1-f173.google.com with SMTP id e65so15919834pgc.5 for <51622@debbugs.gnu.org>; Mon, 08 Nov 2021 10:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=gUVDU2G6yM9JabGroVlc9eix1bJviJVn6fbXF4jHrPE=; b=oL62e9Gnifds76x6Sg+3rGhdJCrhWlXkVlTF3VDJn3eCzIL7UHyQyB4ye7wWFYxNF0 bFnuzS5zx59HmdEYuhNwffh63TeSND5y52NztZeghgz1psIoUFb9zCgfd5WbhHLzd8vm uii0bakBnuqoX5lvE3cbXjFPULMQtJzEK1zrLMzsLS6KhBmjE4vpY8nbeIMhO/GSLTK2 Pkar2bCNqdkIeQGqW92Ql2a1BUcEp/LMk8Q4z1l9mVXfllnq27UxX+qpP4uiOrYhDyfN FgyPoKuhcnAej/4ZmwPHaAAJe/w2kpsrlNtIgvG1lMt4HvEvCOWobcnpKqm11rc9NVtv WK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gUVDU2G6yM9JabGroVlc9eix1bJviJVn6fbXF4jHrPE=; b=4uDBVMNEkZIlS+BIcX+K7xnniHLoDNMPMz2j96yNVdBnBaF97TQF5gx1t83P+xbjBD J3FkwauFpRtOggUkjMIyYM1bYXtjonRGq14WTjR7w0xa/6xpOT59WfpC+oHjcgp+Wadz b4/n/aiP6w1VC3/VFLHeUYHExWP6+L6gYg6KhednSIGGjDQpuEMI1zJw90DMPeaY+QIZ yqw7ZD4ICDYBZU6za9ncL9dabt3jdCKoQuliRC7eWfstCC42EoknwvXLjkBRl/G07VCQ Py3Gtm9I477Zbhvr24E/KugONBYDXmHxrcEIDOkVOyhoZ16FEAIc4Tcq6EO8P9kWGzi3 nfeA== X-Gm-Message-State: AOAM533dlnYTgzTzVtnGJC5j3ZbCrxLFnPbGD1lAWcTwTiLR8/m+4SfJ dRTtYPRQpcQhYaySko7lSiapYPqW1NQ= X-Google-Smtp-Source: ABdhPJxg5BBR8rt4b2Tz6IwIEneEOYBjPyY9jgvwd4+km89NPoO5spEUC9Ig3ijQPs298LhXmGPwHQ== X-Received: by 2002:a05:6a00:23c4:b0:49f:e054:84cb with SMTP id g4-20020a056a0023c400b0049fe05484cbmr1348615pfc.63.1636396374691; Mon, 08 Nov 2021 10:32:54 -0800 (PST) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id 32sm7793697pgn.31.2021.11.08.10.32.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 10:32:54 -0800 (PST) In-Reply-To: <87v912od0s.fsf@gmx.de> Content-Language: en-US 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" Xref: news.gmane.io gmane.emacs.bugs:219374 Archived-At: On 11/8/2021 7:58 AM, Michael Albinus wrote: > Jim Porter writes: > >> I've attached the beginnings of a patch to do this. What do you think? >> If the general idea makes sense, I'll finish it up and file a separate >> bug to track it. If Tramp needs to perform the checks every time for >> some remote hosts, maybe the user could set `tramp-case-insensitive' >> to `never-cache' for those connections? > > Before we start such changes, we should understand your case. Why is it > computed every time? Why isn't the cached value used? Thanks for the explanation above. It turns out I was just mistaken about what's happening. The check on the remote host *is* performed only once. Sorry for the confusion. If I profile `tramp-handle-file-name-case-insensitive-p' on Emacs 29 master, I see that 52% of the time is spent in `file-remote-p' (and a further 30% in `expand-file-name'). This is where the difference in performance comes from; I don't think my patch helps with that, but when testing, I eliminated the `file-remote-p' call (and the remote check) and saw performance improve. I just got mixed up about what the issue was. If the calls to `file-remote-p' and `expand-file-name' could be optimized or replaced, that would make this function a lot faster. I'll take a look at this and see what I can do to improve things. If you have any suggestions though, I'm happy to hear about them. (The main reason I'm digging into this right now is that you mentioned it would be nice if we didn't have to copy-and-paste so much code from `abbreviate-file-name'. I'm looking into making a new function called something like `directory-abbrev-apply', which *only* does the `directory-abbrev-alist' replacements so that Tramp can call this. However, to make it easier to use correctly, I wanted to make sure `case-fold-search' was set based on `file-name-case-insensitive-p'. I only want to do that though if I can make that function fast enough that it doesn't show up near the top of a performance profile. Otherwise, I'll just try to keep the number of calls to `file-name-case-insensitive-p' to the bare minimum.)