Subject: bug#42966: 28.0.50; vc-dir: wrong backend

From: Dmitry Gutov <[email-masked]>
Date: Sat, 24 Oct 2020 22:42:57 +0300

On 24.10.2020 16:41, Michael Albinus wrote:
> Dmitry Gutov <[email-masked]> writes:
> 
>> Hi Michael,
> 
> Hi Dmitry,
> 
>> Not in Tramp, but I see an old change in VC that was most likely
>> informed by a performance problem in Tramp.
>>
>> See the commit a40c87a0093. It adds caching of the result of
>> vc-git-root to a VC property 'git-root' on the file name.
> 
> This seems to be bug#11757.

Huh. Looks familiar ;-)

But that report was about process calls (and git.cmd being expensive), 
whereas vc-git-root doesn't call any external programs, it just 
traverses the filesystem.

>> Does the change below still make some scenario perceptibly slower?
>>
>> diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
>> index b1880c0f7b..91554bb6d8 100644
>> --- a/lisp/vc/vc-git.el
>> +++ b/lisp/vc/vc-git.el
>> @@ -1573,8 +1573,7 @@ vc-git-extra-menu
>>   (defun vc-git-extra-status-menu () vc-git-extra-menu-map)
>>
>>   (defun vc-git-root (file)
>> -  (or (vc-file-getprop file 'git-root)
>> -      (vc-file-setprop file 'git-root (vc-find-root file ".git"))))
>> +  (vc-find-root file ".git"))
>>
>>   ;; grep-compute-defaults autoloads grep.
>>   (declare-function grep-read-regexp "grep" ())
> 
> I haven't tested. But this means to call process-file several times,
> it would be a performance degradation, for sure.

Could you test it, please?

AFAICT locate-dominating-file doesn't call process-file.