Subject: bug#34343: [PATCH] Make project--find-regexp-in-files work with remote files

From: Dmitry Gutov <[email-masked]>
Date: Thu, 2 Jan 2020 04:22:16 +0300

Hi Michael,

On 01.01.2020 14:29, Michael Albinus wrote:
> I've played a little bit with this. Even if there is no remote file name
> involved, file-local-name is slow due to the file-remote-p call and the
> file name handler mechanery. See:

This is unfortunate. But there's a bigger problem: file-local-name is 
even slower when the file name actually *is* remote.

> Refactoring the code, and applying `file-local-name' just to the cases
> where it is needed, shows an elapsed time similar to the initial one.

If you take a look at xref-matches-in-files, you will find that is 
exactly what I did.

But check this out:

ELISP> (benchmark-run-compiled
     nil
   (dotimes (i 10000) (file-local-name (format "/tmp/%d" i))))

(0.01541569 0 0.0)

ELISP> (benchmark-run-compiled
     nil
   (dotimes (_i 10000) (file-local-name (format "/ssh:[email-masked]:/"))))
(3.229403787 28 1.9053286330000034)

And that is for just 10'000 files, not for 1'000'000.

And with longer file names, the process takes even longer (twice as long 
in my real-world example).