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

From: Theodor Thornhill <[email-masked]>
Date: Thu, 28 Mar 2024 11:59:46 +0100

Ihor Radchenko <[email-masked]> writes:

> Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife
> of text editors" <[email-masked]> writes:
>
>> Firstly, I'll show some benchmarks
>>
>> ```
>> ;; Emacs 29 branch
>>
>> (benchmark-run 10000
>>   (file-truename "~/Work/some/long/path/to/parse/that/is/very/deep/deep/deep/super/duper/deep/deep.el"))
>> ;; (1.810892642 1 0.051070616)
>> ...
>> Below are the profiles and the patch. On my system I needed to `ln -s
>> lisp/loadup.el .` to make it compile. Not sure if that is due to
>> differences between old and new `file-truename`, or something else.
>
> The profiles look fishy. For example, in emacs-30-before
>

Not sure I understand what you mean. I tried it again, but this time the
call is 100000 times and in an existing file on my system which is
deeply nested. I run emacs with `emacs -Q` from a build on
`30b1b0d7cd8e4d46a601e9737350cda970f6bab0`.

the relevant part from the profile this time:
```
       15478  72% - command-execute
       15440  72%  - funcall-interactively
       15439  72%   - eval-last-sexp
       15439  72%    - #<compiled-function 0C4>
       15439  72%     - elisp--eval-last-sexp
       15436  71%      - eval
       15436  71%       - benchmark-call
       15434  71%        - #<lambda E8B>
       15434  71%         - file-truename
       13536  63%          - file-truename
       12224  57%           - file-truename
       10970  51%            - file-truename
        9673  45%             - file-truename
        8468  39%              - file-truename
        7420  34%               - file-truename
        6374  29%                - file-truename
        5286  24%                 - file-truename
        4275  19%                  - file-truename
        3313  15%                   - file-truename
        2454  11%                    - file-truename
        1652   7%                     - file-truename
         984   4%                      - file-truename
         376   1%                         file-truename
           1   0%          time-since
           1   0%     execute-extended-command
```

To me this looks like it spends a lot of time in recursive calls

Theo