From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63651: possible eglot xref-find-references optimization Date: Mon, 22 May 2023 13:45:57 -0400 Message-ID: References: Reply-To: Alan Donovan 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="28466"; mail-complaints-to="usenet@ciao.gmane.io" To: 63651@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 22 19:47:37 2023 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 1q19d8-0007Aw-AT for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 May 2023 19:47:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q19ci-0008Fx-FS; Mon, 22 May 2023 13:47:08 -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 1q19cg-0008Fe-Ut for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 13:47:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q19cc-0004uJ-VZ for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 13:47:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q19cc-00033a-Iv for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 13:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Donovan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 May 2023 17:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63651 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168477758011689 (code B ref -1); Mon, 22 May 2023 17:47:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 May 2023 17:46:20 +0000 Original-Received: from localhost ([127.0.0.1]:36274 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q19bv-00032S-Ll for submit@debbugs.gnu.org; Mon, 22 May 2023 13:46:19 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:48290) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q19bu-00032J-9Q for submit@debbugs.gnu.org; Mon, 22 May 2023 13:46:18 -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 1q19bq-000889-Ob for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 13:46:18 -0400 Original-Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q19bn-0004qM-EJ for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 13:46:14 -0400 Original-Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1a950b982d4so19355ad.0 for ; Mon, 22 May 2023 10:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684777569; x=1687369569; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5Dpb7M1LiaGky9QdgUbAwdz1knb6OtJISxxZ+etOS5g=; b=iNbB1YKeRW6aJ8xX4Tb++GQ0mKs90uvwohQIvWROxE4cILuEhy7Q7U8/kWO4b3NuMJ iRQra2dqvxrO4y3oIz6hlJLyokVjsum4wHSnABgLGkrwoOjGRTLXVoVRdlP0tek2ePBY ZCmrnYkLrevqAmrFEiF+VUZxwHgVXrm76kaDP+9W7VEvvHdepNKtj3+uGTLCeyapADox /BRRt8jrmGvVXHGX1yju4xBt6dnrYDVpKlpvvtWpeAQBQ7csP8ZCl1hxVB29YgQfOIwG Q3/YjALt/8hHo4L7l5uqQIn7LNSX7evnxDC4pMnxdWhT/QY+WYFoT2V/SuLOm9rEFC6j Zx6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684777569; x=1687369569; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Dpb7M1LiaGky9QdgUbAwdz1knb6OtJISxxZ+etOS5g=; b=cYcDruaRb3YDXIX3/31pJemSehtXNgL8Hw8LtLu0ZNhDeW1SxuZc+5Dsp41r/donZo QUsjx05PVbPLviyAiQt4HhLfyd+pstxIcZe8XGkbafWF9wYUvC4SHhUDpwHmp83V8DtF D7ZS0gBnjgjY2CQqpxnJcdF4p983T2PeuQUXPdM5LpK+Mk2fI+GEqE+IABE2OmfHol34 EVIFZfiSYbMIlBiltu0VpdWZ0QrXQ9TqJ9N+2F1XSI4zASLBkX7ek35cKQIAs/n5R/MG JBdj+D1Oud/YicrTtkCMuaqhiKzp3PUVVJS00RKKwrOiHKoY9TIiPBVd9FYGQqHIINfc K9qA== X-Gm-Message-State: AC+VfDzsL/IWFFAkI3H7EQ8zgCQMrus5Hnvg2IW8FDux1CV3MaC7ydHV JLa4QApnFDOohfkj1/qISvsBMgFPoxJh1xrmTQuJqyrOaIWe3eKv40siUA== X-Google-Smtp-Source: ACHHUZ4ycpBZm25pdglo7n2kJOl6l+lKqKxGfLMlVaYQKlBfbryhgnuIYbjVtL9kZOybs9u3hVW+U1oceW68pj1dnAo= X-Received: by 2002:a17:902:dac1:b0:19b:c61:2867 with SMTP id q1-20020a170902dac100b0019b0c612867mr434867plx.15.1684777568695; Mon, 22 May 2023 10:46:08 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=adonovan@google.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -175 X-Spam_score: -17.6 X-Spam_bar: ----------------- X-Spam_report: (-17.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action 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:262177 Archived-At: Hi Jo=C3=A3o & other eglot folks, I've been doing a small amount of digging into what makes VSCode so relatively fast. One item that I noticed is that eglot, in the loop that it does over the references obtained from the LSP server, calls find-buffer-visiting to avoid re-reading files that are already open in buffers. I'm not sure whether this is just an optimization, or whether it is necessary to ensure that modified buffer contents are rendered correctly, but it's noticeably slow: for one large query that results in an xref buffer of 1300 lines, the operation takes about 2s normally, but only about 0.8s when I replace the find-buffer-visiting call with false. (According to the elisp CPU profiler, find-buffer-visiting calls file-truename, recursively, a lot.) (defun eglot--xref-make-match (name uri range) "Like `xref-make-match' but with LSP's NAME, URI and RANGE. Try to visit the target file for a richer summary line." (pcase-let* ((file (eglot--uri-to-path uri)) (visiting (or (find-buffer-visiting file) ;; <--- replace this with = false (gethash uri eglot--temp-location-buffers))) (collect (lambda () ... Would that change be sound? Or is it necessary for the reason I guessed at (or some other reason)? cheers alan