Subject: Re: bug#70036: 30.0.50; Move file-truename to the C level

From: Theodor Thornhill <[email-masked]>
Date: Wed, 27 Mar 2024 22:43:25 +0100

Felician Nemeth <[email-masked]> writes:

>> I've been studying Eglots performance and have been noticing a couple
>> of things that I find very interesting. It seems like `file-truename`
>> is in the hot path
>
> I think Eglot repeatedly calls file-truename with the same argument (or
> with an argument from a small set of filenames.)

This is true, to some extent. For the requests, eglot calls it
directly. For some handlers it is called through the function
`find-buffer-visiting`, so I'd say it's advisable to keep the function
itself fast.

>
> I wonder whether it would make sense for Eglot to cache the result of
> file-truename.  Do you think caching would make Eglot faster than it
> currently is?  (Would it still be worth moving file-truename to the C
> level?)

I think it would be faster, yes. This was my first thought as well, but
I quickly threw the first attempts on that away due to the fact that the
processing almost solely lies in that function, and I'd suppose it would
make other parts of emacs faster too. Adding complications to eglot
would likely make the source more complicated rather than better on the
whole. But that's only my opinion. I'd like to try to replicate the
function 1 to 1 in C.

What do you think?

Theo