GNU bug report logs - #66364
29.1.50; vc-hg-registered/state are slow on directories of large repos

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Thu, 5 Oct 2023 15:35:02 UTC

Severity: minor

Tags: patch

Found in version 29.1.50

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 66364 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 66364 <at> debbugs.gnu.org
Subject: Re: bug#66364: 29.1.50; vc-hg-registered/state are slow on
 directories of large repos
Date: Thu, 05 Oct 2023 12:19:37 -0400
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 05/10/2023 18:36, Spencer Baugh wrote:
>>  From 5573b678f816f81623deb7ebde66dfd3ebe92355 Mon Sep 17 00:00:00 2001
>> From: Spencer Baugh<sbaugh <at> janestreet.com>
>> Date: Thu, 5 Oct 2023 11:35:25 -0400
>> Subject: [PATCH] Optimize vc-hg-state for directories
>> Directories are never tracked in hg, so it's pointless to run
>> vc-hg-state on them.  And, in fact, our implementation previously
>> would list all the files contained in the directory and then parse
>> that in Emacs, which is very slow in large repos.
>> Let's just use the knowledge that directories aren't tracked in hg,
>> and skip running hg entirely.
>> * lisp/vc/vc-hg.el (vc-hg-state): Return unregistered for
>> directories.
>> ---
>>   lisp/vc/vc-hg.el | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>> diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
>> index c3e563a1f10..9a30706f519 100644
>> --- a/lisp/vc/vc-hg.el
>> +++ b/lisp/vc/vc-hg.el
>> @@ -216,8 +216,10 @@ vc-hg-registered
>>     (defun vc-hg-state (file)
>>     "Hg-specific version of `vc-state'."
>> -  (let ((state (vc-hg-state-fast file)))
>> -    (if (eq state 'unsupported) (vc-hg-state-slow file) state)))
>> +  (if (file-directory-p file)
>> +      'unregistered
>> +    (let ((state (vc-hg-state-fast file)))
>> +      (if (eq state 'unsupported) (vc-hg-state-slow file) state))))
>>     (defun vc-hg-state-slow (file)
>>     "Determine status of FILE by running hg."
>
> Perhaps we should just follow the example of vc-git-registered and
> return nil.

Also fine by me.

> Could you mention which code calls 'registered' on a directory,
> though? If it's in-tree, that's probably a bug too.

vc-root-diff.  Here's the trace:

* vc-hg-registered("~/test-hg-repos/empty/")
  apply(vc-hg-registered "~/test-hg-repos/empty/")
  vc-call-backend(Hg registered "~/test-hg-repos/empty/")
  #f(compiled-function (b) #<bytecode -0x10c889a4506dd5b1>)(Hg)
  mapc(#f(compiled-function (b) #<bytecode -0x10c889a4506dd5b1>) (FE RCS CVS SVN SCCS SRC Bzr Git Hg))
  vc-registered("~/test-hg-repos/empty/")
  vc-backend("~/test-hg-repos/empty/")
  vc-working-revision("~/test-hg-repos/empty/")
  vc-root-diff(nil t)
  funcall-interactively(vc-root-diff nil t)
  call-interactively(vc-root-diff nil nil)
  command-execute(vc-root-diff)




This bug report was last modified 1 year and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.