bug#81525: 32.0.50; [PATCH] Performance improvement for rgrep's find command

Sean Whitton <[email protected]> Fri, 31 Jul 2026 11:36:15 +0100
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Phil Sainty [31/Jul  6:39pm +12] wrote:
> `rgrep' generates a find command which prunes the directories
> listed in `grep-find-ignored-directories', and the way it
> does that turns out to be relatively slow.
>
> For the entry "SCSS" (for example), it uses the find syntax
> "-path \*/SCCS".  We can also write that as "-name SCSS",
> and (on my system) this change to the find command syntax
> knocks about 30% off the run time.  That seems significant
> enough that I think we should generate the -name syntax
> whenever appropriate (which is true for all default entries
> of the list).
>
> I'm using the following to benchmark just the "find" command
> without actually grepping, finding all files under my home
> directory:
>
>   (require 'grep)
>   (grep-compute-defaults)
>
>   (let ((grep-find-template
>          "time find -H <D> <X> -type f <F> -print 2>/dev/null"))
>     (shell-command (rgrep-default-command
>                     "ignore" "no-such-file" "$HOME")))
>
> On my system, repeated test runs take ~23 seconds for the
> original command using the -path syntax, and ~16 seconds
> for the patched version.
>
> I've attached a patch to change how the find command is
> built, retaining the original -path syntax whenever there
> is a slash in the name, but using -name otherwise.

Thanks.  Can you write down a proof/argument that this will match
exactly the same things, in the commit message and/or this bug?

-- 
Sean Whitton