Subject: Re: bug#78416: [PATCH] * src/lread.c (get-load-suffixes): Avoid module suffix with compressed suffix

From: Eli Zaretskii <[email-masked]>
Date: Wed, 14 May 2025 15:11:40 +0300

> From: Lin Sun <[email-masked]>
> Date: Wed, 14 May 2025 06:21:09 +0000
> 
> The Emacs (with module) will try load module with compressed suffix ".gz", for example, (require 'X) will trigger emacs try load file X.dll, X.dll.gz... on windows, but the "X.dll.gz" does not loadable, it affects performance especially on windows.
> 
> This patch make the (get-load-suffixes) function return result contains the ".dll" but avoid the ".dll.gz". 

The issue is not specific to Windows, so I don't quite understand why
you are talking about Windows and *.dll files.

Paul and Po Lu, are there any systems we know about where Emacs can
load a compressed shared library whose file-name ends in ".gz" or any
other suffix jka-compr supports?  If there are no such systems, then
we should never consider compressed module files for loading.

However, the patch as it is isn't right, IMO: it's too general.

>      {
>        Lisp_Object exts = Vload_file_rep_suffixes;
>        Lisp_Object suffix = XCAR (suffixes);
> +#ifdef HAVE_MODULES
> +      if (suffix_p(suffix, MODULES_SUFFIX))
> +	continue;
> +#ifdef MODULES_SECONDARY_SUFFIX
> +      else if (suffix_p (suffix, MODULES_SECONDARY_SUFFIX))
> +	continue;
> +#endif
> +#endif
>        FOR_EACH_TAIL (exts)
>  	lst = Fcons (concat2 (suffix, XCAR (exts)), lst);

This assumes that load-file-rep-suffixes holds _only_
compression-related suffixes.  This is indeed what we use it for in
Emacs by default, but the variable's potential uses are more general,
and can support any other suffixes.  So we cannot bluntly ignore any
suffix in this variable.  Assuming that indeed no platform we care
about supports loading compressed shared libraries, the change should
ignore _only_ ".gz" (and maybe other compression-related suffixes),
but not others.

Thanks.

P.S. Did you measure the effect of the proposed change, and if so, can
you show the respective timings?  The amount of speedup is an
important consideration whenever we complicate our code, so it is
important to know what kind of bang we get for the buck.