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

Manuel Giraud <[email protected]> Fri, 31 Jul 2026 10:13:02 +0200
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Phil Sainty <[email protected]> writes:

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

Hi,

Thanks.  I have used your benchmark and FWIW, I don't see much
difference on a OpenBSD machine:

No patch:
  warm-up:    0m23.38s real     0m02.89s user     0m13.86s system
  next:       0m10.77s real     0m01.63s user     0m09.23s system

With your patch:
  warm-up:    0m31.48s real     0m03.24s user     0m16.90s system
  next:       0m10.77s real     0m01.67s user     0m09.08s system
-- 
Manuel Giraud