Subject: bug#78340: [PATCH] New option for comp *.eln file name by the file timestamp of *.el

From: Lin Sun <[email-masked]>
Date: Sat, 10 May 2025 15:28:15 +0000

From: Eli Zaretskii <[email-masked]>
Sent: Saturday, May 10, 2025 07:03 AM
> Is this with a cold disk cache or a warm disk cache?  IOW, if you
> start Emacs, then kill the Emacs session, and then start it again, do
> you still measure 8 sec or do you measure a significantly shorter time?

It's an average time, I run it on same environment ~5 times then cal the value. 

> Also, is your anti-virus software configured to ignore *.eln files in
> the directories where you install them?  The *.eln files are DLLs as
> far as Windows is concerned, so it's executable code, and anti-virus
> software will therefore generally scan them when accessed or loaded,
> which could significantly slow down loading.

I tested on same environment, with this patch it will speedup Emacs loading files.

> Anyway, unless Andrea (CC'ed) enthusiastically embraces this, I don't
> think it's correct to install this feature.  Time stamps are too
> unreliable for this job:
> 
>  . it is easy to "fake" file's time using 'touch' 'cp -p' and similar
>    techniques; in fact, the Emacs "make install" uses that
>  . on a modern system, it is quite possible to have a newer file have
>    the same time stamp as an older file, due to relatively low
>    resolution of file time stamps
>  . Emacs on MS-Windows has a 1-sec granularity of file time stamps,
>    which makes the above even worse
>
> All of the above means that using the file time stamps risks loading
> incorrect *.eln files, which could crash Emacs.  So up front, I don't
> think we should have this feature, on Windows or elsewhere.

The .eln file is named in filename-X-Y.eln format, timestamp change maybe lead that Emacs can not find the .eln file, then Emacs will use the .elc/.el file, still works.

All these won't compare to a malicious user compiling a .so/.dll file and replacing an exists .eln, reading full content to calculate the file name won't stop that risk.

This option gives Emacs user a chance to build a faster Emacs on their local, especially for Emacs on Windows. And it's not a default option, won't bother the user who don't build the Emacs themself.