From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70036: a fix that Date: Fri, 19 Apr 2024 13:32:42 +0200 Message-ID: <87r0f1mvtx.fsf@thornhill.no> References: <4e670617-6483-4159-a5cf-27a921764c38@email.android.com> <864jbxden1.fsf@gnu.org> <86r0f1bopx.fsf@gnu.org> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7095"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70036@debbugs.gnu.org, felician.nemeth@gmail.com To: Eli Zaretskii , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 19 13:34:22 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 1rxmVZ-0001ZW-6l for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Apr 2024 13:34:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxmV6-0001Wo-79; Fri, 19 Apr 2024 07:33:52 -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 1rxmV4-0001Wc-Or for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 07:33:50 -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 1rxmV4-0006eb-98 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 07:33:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxmVH-0003ub-O7 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 07:34:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Apr 2024 11:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70036 X-GNU-PR-Package: emacs Original-Received: via spool by 70036-submit@debbugs.gnu.org id=B70036.171352639114665 (code B ref 70036); Fri, 19 Apr 2024 11:34:03 +0000 Original-Received: (at 70036) by debbugs.gnu.org; 19 Apr 2024 11:33:11 +0000 Original-Received: from localhost ([127.0.0.1]:58104 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxmUQ-0003oT-H4 for submit@debbugs.gnu.org; Fri, 19 Apr 2024 07:33:10 -0400 Original-Received: from out-176.mta0.migadu.com ([2001:41d0:1004:224b::b0]:13155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxmUM-0003mk-GN for 70036@debbugs.gnu.org; Fri, 19 Apr 2024 07:33:08 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1713526365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yACaqzWwkw35NNrQowyQy51TiM4MgCV9+YilJ3km1Hg=; b=UAPq2kmTeVEQA4ELrtyDl4Vjvm0Rq1d04YmoZeoNvqX6+mtPwn6zhmQz1qZ5mfHGWhvIy0 YOsux+XpP0Gx5WXZ/I5APiPpRe0veZuyzoR0KbnVuAV2ryr6JZvQHxX1rghkmkAddgffc8 2f869WuQ0xUE4Q9j0HcdKZD2nOl+cbF6VPcu+A0MyjxV1XbfIfH/CWaq/It79skEjKbZW2 MW/g3W/t531AebsGPxlDjxhITBaOzT/rHQS5v1YJbznffRbfV01PwIUPnPnTpxRzsHjYDM eycHaAbsI4pM2CS7ZHFycUwQnFU89NDzm82Nn7c3MqX7k6uO7kmtYY3kz2lqNg== In-Reply-To: <86r0f1bopx.fsf@gnu.org> X-Migadu-Flow: FLOW_OUT 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:283667 Archived-At: Eli Zaretskii writes: >> From: Jo=C3=A3o T=C3=A1vora >> Date: Fri, 19 Apr 2024 09:27:31 +0100 >> Cc: theo@thornhill.no, felician.nemeth@gmail.com, 70036@debbugs.gnu.org >>=20 >> > > I still think the cleanest solution is to write file-truename >> > > in C. >> > >> > I explained in that past discussion why this is not simple. So if >> > simpler solutions exist, we should prefer them. >>=20 >> Fair enough. Shifting complexity around is what we do. But >> having a performant file-truename is a strategically investment, it's >> a very common filesystem primitive that users expect to be as fast >> as it can be made. Common Lisp has TRUENAME, Python has 'realpath()', >> etc. We could compare (here benchmarks are definitely the best >> method) > > file-truename does much more than just the equivalent of realpath. If > all we needed was a single call to realpath, we'd done that in C long > ago. > > The problem with rewriting file-truename in C is that we must be 110% > compatible to what the Lisp implementation does, since it's such a > low-level API that is used so widely. > >> > find-buffer-visiting was made much faster lately, but that speedup >> > AFAIR shows up only if the session has a lot of buffers, so trying >> > these benchmarks in "emacs -Q" will not typically show the effect, and >> > could even obscure the file-truename effect as well, because the >> > number of calls to file-truename will be much smaller. >>=20 >> I'm not sure what test you are suggesting. If f-b-v performs _better_ >> in "lots of buffers" situation, then we should measure Eglot's performan= ce >> in the plausible _worse_ case of few buffers, no? > > No, IMO we should try it in both "emacs -Q" and in a session with a > lot of buffers, to have the performance in its true relevant context. > Most real-life Emacs sessions have many more buffers than we have in > "emacs -Q". Worst-case testing is not always TRT, because it can skew > the perspective and lead to wrong decisions. > >> > But if calling >> > find-buffer-visiting from Eglot can be avoided, that is of course even >> > better. >>=20 >> Yes, that's what my latest patch does. But ideally it would be cleaner >> (IMHO) to have a fast usable find-buffer-visiting by speeding >> up its underlying file-truename. > I wonder - why can't we use just buffer-file-truename? In the below function, wouldn't buffer-file-truename let us avoid the file-truename in eglot-path-to-uri? (defun eglot--TextDocumentIdentifier () "Compute TextDocumentIdentifier object for current buffer." `(:uri ,(or eglot--cached-tdi (setq eglot--cached-tdi (eglot-path-to-uri (or buffer-file-name (ignore-errors (buffer-file-name (buffer-base-buffer))))))))) > We did that at least to some extent in the improvements submitted by > Ihor and now available on master. From where I stand, we now have a > reasonably performant implementation of find-buffer-visiting; I would > need benchmarks showing otherwise to change my mind. Theo