From: Sean Allred <allred.sean@gmail.com>
To: 73320@debbugs.gnu.org
Subject: bug#73320: [PATCH] project--vc-list-files: use Git's sparse-index
Date: Tue, 17 Sep 2024 11:55:43 -0500 [thread overview]
Message-ID: <m0h6aenrsg.fsf@epic96565.epic.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]
Tags: patch
Hello!
I noticed that `C-x p f` (M-x project-find-file) took an incredibly long
time to run on our monorepo -- even when using a sparse index -- and I
tracked the problem down to this function. Adding `--sparse` to the
`git-ls-files` invocation resolves the issue handily, albeit with the
quirk of still showing top-level directories that are excised from the
sparse index (which we may want to remove from the return value of this
function since it does say it returns /files/).
I'm expecting at least one more version of this patch before it's even
considered for merge. Given that this change removes many, many results
from the return value of `project--vc-list-files', I suspect this would
be a breaking change for some use case that I'm not considering. I'm
hoping the list can provide some feedback on the best way to make this
configurable. I've not really hacked in project.el before and am not
super familiar with its internals.
If you prefer, you may pull this patch from my fork on github at
url: git@github.com:vermiculus/emacs.git
branch: sa/sparse-index
Keep in mind I may be updating this branch with feedback from this list
as it comes in.
-Sean
In GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2023-07-30 built on
armbob.lan
Windowing system distributor 'Apple', version 10.3.2487
System Description: macOS 14.6.1
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules 'CFLAGS=-DFD_SETSIZE=10000
-DDARWIN_UNLIMITED_SELECT' --with-x-toolkit=no'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-project-vc-list-files-use-Git-s-sparse-index.patch --]
[-- Type: text/patch, Size: 1737 bytes --]
From e72c013afbafad3faf19f98acb8d0387fdf045ba Mon Sep 17 00:00:00 2001
From: Sean Allred <allred.sean@gmail.com>
Date: Tue, 17 Sep 2024 10:07:41 -0500
Subject: [PATCH] project--vc-list-files: use Git's sparse-index
When dealing with exceptionally large Git repositories, the performance
of `project-find-file` can suffer dramatically as the list of files is
collected for completion. This adds insult to injury when you consider
cases where the developer has configured the repository to use a sparse
checkout where the vast majority of these files are not even present on
disk and are not valid candidates for completion.
Unconditionally pass along the `--sparse` option to `git-ls-files` to
coerce `project--vc-list-files` only consider files present in the
sparse index (and presumably on disk).
No consideration is made to make this configurable as it is currently
unclear as to the best way to do this -- whether to follow the example
of the `include-untracked` symbol in this function or to adopt some
other mechanism.
---
lisp/progmodes/project.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index b29d5ed5404..82cb79322dd 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -663,7 +663,7 @@ project--vc-list-files
(pcase backend
(`Git
(let* ((default-directory (expand-file-name (file-name-as-directory dir)))
- (args '("-z"))
+ (args '("-z", "--sparse"))
(vc-git-use-literal-pathspecs nil)
(include-untracked (project--value-in-dir
'project-vc-include-untracked
base-commit: 7d365a2d72d8e656262205827cc5fdf423c3a41f
--
2.46.0
[-- Attachment #3: Type: text/plain, Size: 17 bytes --]
--
Sean Allred
next reply other threads:[~2024-09-17 16:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 16:55 Sean Allred [this message]
2024-09-17 22:54 ` bug#73320: [PATCH] project--vc-list-files: use Git's sparse-index Dmitry Gutov
2024-09-18 0:36 ` Sean Allred
2024-09-18 22:27 ` Dmitry Gutov
2024-09-19 4:25 ` Sean Allred
2024-09-19 9:44 ` Dmitry Gutov
2024-09-29 1:19 ` Dmitry Gutov
2024-10-03 23:57 ` Dmitry Gutov
2024-10-04 7:48 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 21:25 ` Dmitry Gutov
2024-10-05 6:48 ` Eli Zaretskii
2024-10-05 12:33 ` Dmitry Gutov
2024-10-07 23:55 ` Dmitry Gutov
2024-10-07 0:41 ` Jim Porter
2024-10-07 23:38 ` Dmitry Gutov
2024-09-19 5:41 ` Eli Zaretskii
2024-09-19 9:34 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m0h6aenrsg.fsf@epic96565.epic.com \
--to=allred.sean@gmail.com \
--cc=73320@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.