GNU bug report logs -
#51699
29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files
Previous Next
Reported by: Jim Porter <jporterbugs <at> gmail.com>
Date: Tue, 9 Nov 2021 03:53:02 UTC
Severity: normal
Tags: patch
Found in version 29.0.50
Fixed in version 29.1
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 11 Nov 2021 19:51:14 +0100
with message-id <874k8iil0d.fsf <at> gmx.de>
and subject line Re: bug#51699: 29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files
has caused the debbugs.gnu.org bug report #51699,
regarding 29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
51699: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=51699
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
This is a spinoff of bug#51622. While looking at the performance of
'abbreviate-file-name' for Tramp files, I noticed that
'file-name-case-insensitive-p' was taking up a significant percentage of
the execution time. I dug into this and found two main hot spots:
1) 'tramp-handle-file-name-case-insensitive-p' calling 'file-remote-p'
and 'expand-file-name'
Since 'file-remote-p' only needed to check whether a connection was
already established, it could be replaced with this (thanks to Michael
Albinus for the pointer):
(let ((non-essential t)) (tramp-connectable-p v))
'expand-file-name' also had room for a small optimization, since it
previously called 'tramp-connectable-p' (which dissects the file if it's
not already) and then 'with-parsed-tramp-file-name' (which dissects it
again). I reversed the order so now there's one fewer dissection, and
it's a bit faster.
2) Potential handlers in 'tramp-find-foreign-file-name-handler' each
dissect the file name
Most Tramp methods have a 'tramp-FOO-file-name-p', and most of *those*
take a file name string and dissect it. This is a lot of duplicated
effort, so I modified 'tramp-find-foreign-file-name-handler' to pass the
dissected file name to any of the functions that support it (this is
indicated by an 'accepts-vec' property on the function). This probably
warrants some documentation (at least a NEWS entry), but I wanted to be
sure the strategy made sense before I wrote any docs.
With these changes combined, I see the following results (testing with
the sshx method connecting to localhost on a GNU/Linux system):
* 'file-name-case-insensitive-p':
3.5x faster, now 583μs per call
* 'tramp-handle-file-name-case-insensitive-p':
4.5x faster, now 281μs per call
* 'tramp-find-foreign-file-name-handler':
5.2x faster, now 45μs per call
In addition to the patches, I've attached the benchmark script that
generated these results as well as the raw data.
[0001-Improve-performance-when-checking-case-sensitivity-o.patch (text/plain, attachment)]
[0002-Improve-performance-of-tramp-find-foreign-file-name-.patch (text/plain, attachment)]
[benchmark.el (text/plain, attachment)]
[benchmark-results.txt (text/plain, attachment)]
[Message part 8 (message/rfc822, inline)]
Version: 29.1
Jim Porter <jporterbugs <at> gmail.com> writes:
Hi Jim,
> From 2aec8e21a3e37728a990c4f116f60c8b12bb2110 Mon Sep 17 00:00:00 2001
> From: Jim Porter <jporterbugs <at> gmail.com>
> Date: Wed, 10 Nov 2021 16:41:00 -0800
> Subject: [PATCH] Improve performance of 'tramp-find-foreign-file-name-handler'
Thanks for this final patch. I've applied it to master. It makes
tramp-tests.el faster for most of the test cases, not only for
file-name-case-insensitive-p tests. :-)
Closing this bug.
Best regards, Michael.
This bug report was last modified 3 years and 248 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.