unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 63651@debbugs.gnu.org
Subject: bug#63651: possible eglot xref-find-references optimization
Date: Mon, 22 May 2023 13:45:57 -0400	[thread overview]
Message-ID: <CAPVWWDVVA+pp6Yo4e=hDysii_0HL8pJQ+HzLXUPWNePxcdnQfQ@mail.gmail.com> (raw)
In-Reply-To: <CAPVWWDXj+au=50v00jK7DNGFX33p7uyz_x+iQMGxk6Gu2p5saA@mail.gmail.com>

Hi João & 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





       reply	other threads:[~2023-05-22 17:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPVWWDXj+au=50v00jK7DNGFX33p7uyz_x+iQMGxk6Gu2p5saA@mail.gmail.com>
2023-05-22 17:45 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-05-24 16:28   ` bug#63651: possible eglot xref-find-references optimization João Távora
2023-05-24 21:22     ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-04 13:55       ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors

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='CAPVWWDVVA+pp6Yo4e=hDysii_0HL8pJQ+HzLXUPWNePxcdnQfQ@mail.gmail.com' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=63651@debbugs.gnu.org \
    --cc=adonovan@google.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).