From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 51622@debbugs.gnu.org
Subject: bug#51622: 29.0.50; [PATCH v2] Abbreviate remote home directories in `abbreviate-file-name'
Date: Mon, 08 Nov 2021 20:18:45 +0100 [thread overview]
Message-ID: <87r1bqo3qi.fsf@gmx.de> (raw)
In-Reply-To: <493647c2-74af-52fc-d55e-42280e893694@gmail.com> (Jim Porter's message of "Mon, 8 Nov 2021 10:32:53 -0800")
Jim Porter <jporterbugs@gmail.com> writes:
Hi Jim,
> 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 check (file-remote-p filename nil 'connected) is applied to prevent
unintended work. It returns non-nil when there is already a connection
to the remote host. The intention is to avoid, that
`tramp-handle-file-name-case-insensitive-p' opens a new connection just
in order to see, whether the remote file system is case
insensitive. This is not needed when there's no connection yet.
Hmm, we could replace this check by something cheaper: is there already
a connection process?
--8<---------------cut here---------------start------------->8---
(and (let ((non-essential t)) (tramp-connectable-p filename))
...
--8<---------------cut here---------------end--------------->8---
The `non-essential' variable must be bound to non-nil; otherwise
`tramp-connectable-p' would always return non-nil.
Does this help? In case of, you might offer a patch, with a comment why
we don't use (file-remote-p filename nil 'connected) .
For the `expand-file-name' case I have no offer yet. But let's see how
the timing changes with that change above.
Btw, when you run benchmark checks, you shall set (or let-bind)
`tramp-verbose' to 0. Writing debug data has a cost.
> (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.
Good idea, I was also thinking about. For backward compatibility we will
keep a mirror of that function in tramp-compat.el, until we support only
Emacs 29+. Isn't this a glory future? :-)
Best regards, Michael.
next prev parent reply other threads:[~2021-11-08 19:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-06 3:44 bug#51622: 29.0.50; [PATCH] Abbreviate remote home directories in `abbreviate-file-name' Jim Porter
2021-11-06 8:06 ` Eli Zaretskii
2021-11-06 15:34 ` Michael Albinus
2021-11-06 16:38 ` Jim Porter
2021-11-06 17:41 ` Michael Albinus
2021-11-07 3:30 ` bug#51622: 29.0.50; [PATCH v2] " Jim Porter
2021-11-07 18:37 ` Michael Albinus
2021-11-08 4:54 ` Jim Porter
2021-11-08 15:58 ` Michael Albinus
2021-11-08 18:32 ` Jim Porter
2021-11-08 19:18 ` Michael Albinus [this message]
2021-11-14 2:10 ` Jim Porter
2021-11-14 14:43 ` Michael Albinus
2021-11-15 6:58 ` bug#51622: 29.0.50; [PATCH v3] " Jim Porter
2021-11-15 16:59 ` Michael Albinus
2021-11-16 1:14 ` Jim Porter
2021-11-16 11:43 ` Michael Albinus
2021-11-16 12:57 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1bqo3qi.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=51622@debbugs.gnu.org \
--cc=jporterbugs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).