From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: master 08c80c45dde: Don't use file-truepath in Eglot (bug#70036) Date: Thu, 18 Apr 2024 08:02:42 +0200 Message-ID: <87edb3rywt.fsf@thornhill.no> References: <171215083924.12380.5369373861551158668@vcs2.savannah.gnu.org> <20240403132719.A18EFC12C28@vcs2.savannah.gnu.org> <87il0fsufu.fsf@thornhill.no> 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="8983"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Apr 18 08:03:23 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rxKri-00028q-Qy for ged-emacs-devel@m.gmane-mx.org; Thu, 18 Apr 2024 08:03:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxKrI-000693-D2; Thu, 18 Apr 2024 02:02:56 -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 1rxKrF-00068X-Me for emacs-devel@gnu.org; Thu, 18 Apr 2024 02:02:53 -0400 Original-Received: from out-185.mta0.migadu.com ([2001:41d0:1004:224b::b9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxKrA-0006FE-UK for emacs-devel@gnu.org; Thu, 18 Apr 2024 02:02:53 -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=1713420165; 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=W5PCZWWyfSvivvT+68InUwUkk4GF9uCompoRQOfB9F0=; b=XfjocgSEOLUlBIkJ2YpLSuvjmyudNsjLZOtztifBizeI9wcW6ZxDxFX94pfnR8WyiV8H/Z lQvRqr1Dc86lJpQnIxTsbnE8bpiW5zq8oHLOdoeY2B0Tx+Q0XZwpEx1rt3NZviOvbCcHBe Hh1KWCi7ohflRpGHR3bV/vIyHFnpiv3+E3RJX4hQcZhxkLw8MtCZflXffoOtAYCXmE/tVd SNY3xVlMSHAXjF4rxWgnRtwysluB33psHPAs3SYwc0vtLBO7VJQqP1XEvnZFd0udST6qH6 SGZKPc4W1QeGONTyum6GE7UGuuIg+JEB8T1NpND1NeMamxRzCwNyWY0dwGNCPQ== In-Reply-To: X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::b9; envelope-from=theo@thornhill.no; helo=out-185.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317797 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > On Wed, Apr 17, 2024 at 7:41=E2=80=AFPM Theodor Thornhill wrote: > have been looking for an Eglot maintainer but everyone I contacted > >> If you want I can do this - so that you don't have to. I've been >> considering it for some time after I responded to your call for >> maintainers. > > OK, I've added you to the GitHub repo as a collaborator. Let me know > off-list what your intentions are (to phase it out, keep it and take > it over, or whatever) and let's see how it goes. > Thanks, will do. >> > The change seems well structured, well coded, and well described in the >> > commit message, so I could understand it easily. Do keep that up. >> > >> > But of course going from file-buffer-visiting to something else >> > whose underlying implementation is faster but doesn't chase >> > symlinks is probably going to have some kind of functional implication >> > right? I wonder if (or rather "I hope that") you guys considered it. >> >> I did - and afaict it has no such implications. It > > I've identified at least one implication. A rather obvious one, given > that you've effectively removed symlink-awareness from Eglot. > > When working in a project with symlinks and visiting such symlinks, > the LSP server is now informed (via LSP 'didOpen') of the symlinked > file as if it was its own file, whereas before your changes Eglot > sent over the true name of the file. You can see this easily > from M-x eglot-events-buffer. > > What does this mean in practice? Many things potentially, but > at least this one: I've run this experiment: In a new dir, create > a lib.h file with this silly content: > > int foo(); > > Then create a main.cpp like this: > > #include "lib.h" > int main() { return foo(); } > > Then create a mainlink.cpp symbolic link to main.cpp > > Then M-x eglot (launches clangd server to manage the new directory > as a project). > > Let's say that during the Eglot session I visit both main.cpp > and mainlink.cpp in different buffers (either because I don't visit > them at the same time or because find-file-existing-other-name is > nil). Then I press M-? on lib.h's foo() to tell me who references it. > > Before you change, Eglot will -- correctly -- tell me there is a single > user of lib.h's foo() function in my project. > > After your change, it tells me there are two users. This is wrong, > there is only one. > > It could be that some servers with direct access to the file system > can deduplicate the information and add back the symlink smarts. > > But clangd doesn't do this, and in general servers _can't_ do > this because LSP models a virtual file system. >From what I can see in other servers this is recognized as a server problem, and not a client problem [1], [2], [3].=20 > > And for symlinks to large enough files, I'd be surprised if this > doesn't slow down the performance of the server because it has to > analyse what it is told is a completely new file. > > So this seems like a pretty big flaw to me after just minimal > surface scratching. Please reinstate the previous code. > I can absolutely do this, but I'd rather we consider it a bit more before I do. On my system there is a real, tangible performance increase with this change, and the symlink one seems more like a server edge case issue. Maybe we could check for file-symlink-p rather than runthe whole file-truepath? > We can resume discussion of your performance problems in the > bug report. I've seen the profile reports and file-truename is > not thaat big of a problem. But nevertheless I think I can > help you think of other places to cache things. Caching > eglot--TextDocumentIdentifier per-buffer seems like a much > easier way to solve your problems. I disagree - it really makes a huge difference in felt latency. Theo [1]: https://github.com/clangd/clangd/issues/124 [2]: https://github.com/microsoft/python-language-server/issues/181 [3]: https://github.com/microsoft/vscode-python/issues/2613