GNU bug report logs - #70036
30.0.50; Move file-truename to the C level

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Wed, 27 Mar 2024 19:10:02 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Theodor Thornhill <theo <at> thornhill.no>
Cc: 70036 <at> debbugs.gnu.org
Subject: bug#70036: 30.0.50; Move file-truename to the C level
Date: Thu, 28 Mar 2024 09:22:26 +0000
[Message part 1 (text/plain, inline)]
Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife
of text editors" <bug-gnu-emacs <at> gnu.org> 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

          73  15%           - file-truename

73 is ~0.073 seconds, which cannot be right if you profiled the above
`benchmark-run'.

I tried to record the profiles on my side, using the above
`benchmark-run' call, and what I am seeing is that most of the CPU time
is already spend in C subrs:

        1285  17% + file-name-nondirectory
        1250  16%   Automatic GC
        1182  15% + file-symlink-p
        1060  14% + file-name-case-insensitive-p
         495   6% + find-file-name-handler
         451   6% + file-name-as-directory
         425   5% + file-name-directory
         401   5% - directory-file-name
         398   5%  + setq

I am attaching my profile, as saved via M-x
profiler-report-write-profile. You can view it via M-x
profile-report-find-profile

At least, the number of calls to `file-name-nondirectory' can be
trivially reduced in the `file-truename' code - it is called up to three
times in a row.

[profile-emacs-master.eld (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]
-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

This bug report was last modified 1 year and 105 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.