emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51699: closed (29.0.50; [PATCH] Improve performance of 'file-name-ca


From: GNU bug Tracking System
Subject: bug#51699: closed (29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files)
Date: Thu, 11 Nov 2021 18:52:02 +0000

Your message dated Thu, 11 Nov 2021 19:51:14 +0100
with message-id <874k8iil0d.fsf@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@gnu.org.)


-- 
51699: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=51699
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files Date: Mon, 8 Nov 2021 19:46:05 -0800 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.

Attachment: 0001-Improve-performance-when-checking-case-sensitivity-o.patch
Description: Text document

Attachment: 0002-Improve-performance-of-tramp-find-foreign-file-name-.patch
Description: Text document

Attachment: benchmark.el
Description: Text document

Attachment: benchmark-results.txt
Description: Text document


--- End Message ---
--- Begin Message --- Subject: Re: bug#51699: 29.0.50; [PATCH] Improve performance of 'file-name-case-insensitive-p' for Tramp files Date: Thu, 11 Nov 2021 19:51:14 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Version: 29.1

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> From 2aec8e21a3e37728a990c4f116f60c8b12bb2110 Mon Sep 17 00:00:00 2001
> From: Jim Porter <jporterbugs@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.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]