From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74243: [PATCH] Speed up vc-hg-state by treating ignored files as unregistered Date: Tue, 26 Nov 2024 18:32:38 -0500 Message-ID: References: <87mshy7jtp.fsf@melete.silentflame.com> <87r06ytosi.fsf@melete.silentflame.com> <802729a0-6937-48a7-9ce5-bd81e8548877@gutov.dev> Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13566"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74243@debbugs.gnu.org, Sean Whitton To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 27 00:33:18 2024 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 1tG53W-0003NP-2S for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 27 Nov 2024 00:33:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tG53I-0003GL-Cy; Tue, 26 Nov 2024 18:33:04 -0500 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 1tG53G-0003Ft-Ft for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 18:33:02 -0500 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 1tG53G-0002Yn-4v for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 18:33:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=6FKEvTmZXdpSwF4vnisf4TQku+at3iFCg+0HknzTIL4=; b=UfHUduKJZhGoLSXNV5yfYRCQLoZIFkZh7WaNWtiwgeYSg+e8qU+vmQZdU8AmLiPE4f5nGst6d+fTlaXv6E2RD8eHFrXp0TGFs8hzHrubnEmBzQyqmUPrKwdvv8YhgSnm50DKfJyfz2MqMtzW+GKi0X51fhwyDk/632HzudF44gorccCHeyIss6UqArG8hWvM/Hh9Eh162ZUYV72RKyiAza/3roBd0sY/cnw12avJ93dVHYvvJlscxCcoUwMQW/QivW7NVKeBiOvHEvFXVQCAew1Kln9vmqiRCzchL/MlIF75NQCO0IZyg6rVJnOERDxZE8EhIoznt3oos5h9P/ic+A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tG53F-0007xU-V5 for bug-gnu-emacs@gnu.org; Tue, 26 Nov 2024 18:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Nov 2024 23:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74243 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74243-submit@debbugs.gnu.org id=B74243.173266396630564 (code B ref 74243); Tue, 26 Nov 2024 23:33:01 +0000 Original-Received: (at 74243) by debbugs.gnu.org; 26 Nov 2024 23:32:46 +0000 Original-Received: from localhost ([127.0.0.1]:55435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tG52z-0007wu-SG for submit@debbugs.gnu.org; Tue, 26 Nov 2024 18:32:46 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:52835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tG52x-0007wb-Ue for 74243@debbugs.gnu.org; Tue, 26 Nov 2024 18:32:44 -0500 In-Reply-To: <802729a0-6937-48a7-9ce5-bd81e8548877@gutov.dev> (Dmitry Gutov's message of "Wed, 27 Nov 2024 01:26:26 +0200") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1732663958; bh=6FKEvTmZXdpSwF4vnisf4TQku+at3iFCg+0HknzTIL4=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=cL8Sm1Svn3v1aDUx6h9gAhT+fvogAYt762g7Y4FXBN7GzHnl/fAB//kQ0OyQtyLFM 1iczqgyosJlWvvZFISD4z7U90RK2OKjs6a0j1aSeDxYYCQ20Wuj6Hqjhy3OycjqGxm 9ih/X86l5nM/j1qzZPw/UUrTeUWFYJyxAomM9DYYgRGBBGgGQ04MbrDZq8iLzUO6gN BOriSkEMyBkTqdELq9CExrqD/QvG/0LTWK4Kzj0Qc0MDN/0jOC22MK5YAdkjJlj2L/ Cg6Nb217Xlce9dUuBbwAeq2tBW5g1beBomAtLwfM1UfltFfld6ZFwG02rYP0ZaohPy m0n7fk9wxJdbw== 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:296007 Archived-At: Dmitry Gutov writes: > Hi, just to interject a little. > > On 26/11/2024 09:52, Sean Whitton wrote: >> (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. > > This FR reminds me of a similar change in vc-git-state that we ended > up installing in bug#11757 (in 2012). Then stayed with it until 2017 > when bug#19343 was filed and fixed (provided a recent enough Git is > used) - see also the problem scenario described there. > > So it seems both a reasonable change and ultimately not > ideal. Depending on how many users we think might be affected by > performance here. > >> 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. > > A user option seems like an easier choice. > > Solutions that clear cache under some conditions or other tend to be > more complex, and slow down at least some combined scenarios (e.g. one > of my use cases is saving the buffer and having diff-hl-mode use its > vc state from after-save-hook). These are all reasonable concerns. Since posting my original patch, though, I've heard from Hg developers that they plan to eventually implement per-directory ignore files, like in Git. That would remove the original performance problem, so maybe this is not so important. That being said, it's still sad that the vc hooks in find-file-hook and after-save-hook can hurt performance so much. It seems to me that the ideal outcome would be to support asynchronicity in those hooks. That would benefit all vc backends... though this is perhaps quite difficult. Maybe asynchronously populating the saved vc-state property would work? With some clever usage of nil return values as Sean describes...