From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: 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 Message-ID: References: <90fef338-cac6-aa08-bd74-5ce9e2721f76@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66364@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 05 18:20:52 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qoR5n-00024r-QE for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Oct 2023 18:20:52 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoR5i-0001s5-EE; Thu, 05 Oct 2023 12:20:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoR5f-0001me-Vj for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 12:20:44 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qoR5f-0005bE-Ed for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 12:20:43 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qoR5x-00057z-NX for bug-gnu-emacs@gnu.org; Thu, 05 Oct 2023 12:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Oct 2023 16:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66364 X-GNU-PR-Package: emacs Original-Received: via spool by 66364-submit@debbugs.gnu.org id=B66364.169652280519632 (code B ref 66364); Thu, 05 Oct 2023 16:21:01 +0000 Original-Received: (at 66364) by debbugs.gnu.org; 5 Oct 2023 16:20:05 +0000 Original-Received: from localhost ([127.0.0.1]:48348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoR52-00056a-HS for submit@debbugs.gnu.org; Thu, 05 Oct 2023 12:20:04 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:48603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoR4z-00055t-LD for 66364@debbugs.gnu.org; Thu, 05 Oct 2023 12:20:02 -0400 In-Reply-To: <90fef338-cac6-aa08-bd74-5ce9e2721f76@gutov.dev> (Dmitry Gutov's message of "Thu, 5 Oct 2023 19:09:52 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:271888 Archived-At: Dmitry Gutov writes: > On 05/10/2023 18:36, Spencer Baugh wrote: >> From 5573b678f816f81623deb7ebde66dfd3ebe92355 Mon Sep 17 00:00:00 2001 >> From: Spencer Baugh >> 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) #)(Hg) mapc(#f(compiled-function (b) #) (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)