From: Sean Whitton <spwhitton@spwhitton.name>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: 74243@debbugs.gnu.org
Subject: bug#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered
Date: Tue, 26 Nov 2024 15:52:29 +0800 [thread overview]
Message-ID: <87r06ytosi.fsf@melete.silentflame.com> (raw)
In-Reply-To: <ierttc3z71g.fsf@janestreet.com> (Spencer Baugh's message of "Tue, 19 Nov 2024 08:28:59 -0500")
Hello,
On Tue 19 Nov 2024 at 08:28am -05, Spencer Baugh wrote:
> The original motivation of optimizing 'state is to speed up
> vc-refresh-state and vc-after-save, since they call vc-hg-state in
> find-file-hook and after-save-buffer, which adds very noticeable
> latency. (I care less about the speed of vc-dir, which uses
> 'dir-status-files not 'state)
>
> So those functions would need to pass this argument. But they (through
> vc-state-refresh) then store the returned state in 'vc-state in the VC
> per-file properties, so anyone accessing that will also see the effect
> of this argument.
I see what you mean.
Quoting vc-state,
| A return of nil from this function means we have no information on the
| status of this file.
| [...]
| `ignored' The file showed up in a dir-status listing with a flag
| indicating the version-control system is ignoring it,
| Note: This property is not set reliably (some VCSes
| don't have useful directory-status commands) so assume
| that any file with vc-state nil might be ignorable
| without VC knowing it.
|
| `unregistered' The file is not under version control."
|
| ;; Note: we usually return nil here for unregistered files anyway
| ;; when called with only one argument. This doesn't seem to cause
| ;; any problems. But if we wanted to change that, we should
| ;; probably opt for redefining the `registered' command to return
| ;; non-nil even for unregistered files (maybe also rename it), and
| ;; then make sure that all `state' implementations handle
| ;; unregistered file appropriately.
(I think there's a mistake here: an ignored file is not a file "under
version control", so `unregistered' should say "not under version
control and not ignored". Would you agree?)
Thanks for pointing out the involvement of find-file-hook and
after-save-hook. The problem you describe is not at all Hg-specific:
vc-state gets called in a context where speed matters, but it's also the
primary entry point for any code that wants to know the state of a file,
some of which might care more about accuracy than speed.
To put it another way, the code assumes throughout that finding out the
file state will always be fast. But it also assumes the information is
accurate if present. This makes me queasy about your original patch.
It does not seem wise to return something we don't know to be true only
on the basis that it all works out fine for now.
The 'nil' return value might provide us with a way out, however.
Could we add an optional argument to vc-state that means "just return
nil if finding out the state properly might be slow"?
Could we make vc-after-save and the relevant find-file-hook entry pass
that option through, and do something sensible with a nil return value?
If they get nil, they would clear out the saved property, and possibly
update the mode line display to "????" or something. Maybe we'd want a
user option (that could go in your large repo's .dir-locals.el, so it's
set-and-forget) to opt-in to not knowing the file state as often.
--
Sean Whitton
next prev parent reply other threads:[~2024-11-26 7:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 17:41 bug#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-17 1:03 ` Sean Whitton
[not found] ` <ierttc3z71g.fsf@janestreet.com>
2024-11-26 7:52 ` Sean Whitton [this message]
2024-11-26 23:26 ` Dmitry Gutov
2024-11-26 23:32 ` Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-27 0:18 ` Dmitry Gutov
2024-11-29 8:17 ` Sean Whitton
2024-11-29 12:43 ` Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-29 23:45 ` Sean Whitton
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r06ytosi.fsf@melete.silentflame.com \
--to=spwhitton@spwhitton.name \
--cc=74243@debbugs.gnu.org \
--cc=sbaugh@janestreet.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).