bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ihor Radchenko
Subject: bug#70036: 30.0.50; Move file-truename to the C level
Date: Thu, 28 Mar 2024 09:22:26 +0000

Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife
of text editors" <bug-gnu-emacs@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.

Attachment: profile-emacs-master.eld
Description: Binary data

-- 
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>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]