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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 10 May 2025 10:03:43 +0300

> From: Lin Sun <[email-masked]>
> Date: Sat, 10 May 2025 00:07:52 +0000
> 
> Currently Emacs with native comp will comp .eln file name by the full context of the .el or .el.gz file in function "comp-el-to-eln-rel-filename".
> For example, emacs startup will require the simple.elc, then have to read full of simple.el.gz to calculate the name simple-X-Y.eln. 
> 
> That's slow on Windows.
> 
> This patch introduced a new option "fts" (file time stamp) for "--with-native-compile", it will let the function "comp-el-to-eln-rel-filename" to get the .eln name by reading the .el/.el.gz file timestamp, make emacs faster on Windows. On my Windows testing env, the  Emacs startup up time was reduced from 8s to 6.5s with 386 packages, speedup ~20%.

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?

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.

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.

Thanks.