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

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

bug#51699: 29.0.50; [PATCH] Improve performance of 'file-name-case-insen


From: Jim Porter
Subject: bug#51699: 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


reply via email to

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