bug#81548: 31.0.91; eglot extremely slow with large source files

Eli Zaretskii <[email protected]> Tue, 04 Aug 2026 14:44:35 +0300
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> From: Peter Wu <[email protected]>
> Date: Mon, 3 Aug 2026 20:57:29 +0000
> 
> 
> 
> 0. make sure you have clangd installed. I'm on macOS 26.6 and use the
> system stock clangd: Apple clangd version 21.0.0 (clang-2100.1.1.101)
> 1. git clone https://github.com/wolfSSL/wolfssl
> 2. cd wolfssl
> 3. ./autogen.sh (assuming you have the autotools installed)
> 4. ./configure --enable-certgen \
>             --enable-certreq \
>             --enable-certext \
>             --enable-crl \
>             --enable-asn \
>             --enable-opensslextra
> 5. generate a compile_commands.json (I used: uvx compiledb make -j8)
> 6. make sure compile_commands.json has been generated (~475K in size)
> 7. create a $HOME/.emacs file with just these lines:
> 
> ;;; -*- lexical-binding: t; -*-
> 
> (use-package eglot
>   :hook
>   ((c-mode c++-mode) . eglot-ensure))
> 
> 8. emacs wolfcrypt/test/test.c (this file contains 82K lines of code)
> 9. ensure eglot is enabled
> 10. search for a function, e.g. wc_RsaPrivateKeyDecode on line 28693
> 
>     ret = wc_RsaPrivateKeyDecode(tmp, &idx, key, (word32)bytes);
> 
> 11. move the point to the function
> 12. M-x xref-find-definitions RET
> 13. eglot hangs for, in my case, ~45 seconds, before locating the
> definition
> 14. if you do it again on another function, it works quickly as expected
> 15. when eglot hangs for the first time, C-g is able to cancel the
> operation
> 16. this performance issue happens on 31.0.91 and the master branch as
> of this report but things work fine with 30.2 no hang.
> 17. I also tried c-ts-mode on 31.0.91 and the master branch, but the
> problem can also be reproduced on both occasions

Could you produce a profile (from "M-x profiler-start") during those
45 sec, so we could better see the potential culprits?

Adding João to the discussion.