Subject: Re: bug#71179: [PATCH] In rgrep, check matching files before excluding files

From: Spencer Baugh <[email-masked]>
Date: Fri, 24 May 2024 16:54:37 -0400

Dmitry Gutov <[email-masked]> writes:
> Hi Spencer,
>
> On 24/05/2024 23:14, Spencer Baugh wrote:
>> If find checks the files glob first and then the excluding glob, it has
>> to do much less checking (since the files glob will substantially narrow
>> down the set of files on its own), and find performance is much better.
>> In my benchmarking, this takes (rgrep "foo" "*.el"
>> "~/src/emacs/trunk/")
>> from ~410ms to ~130ms.
>
> I can confirm improvement here (though not exactly 3x).
>
> 1.9s to 1.3s in a Linux checkout, for example. Nice.
>
> Moving the files exclude instructions to the <F> placeholder is a
> slight incompatibility, but I wonder if there are any custom
> grep-find-template values which would be bothered by it (that's the
> only incompatibility I could think of). Perhaps those that currently
> don't include <X> at all?

A grep-find-template that doesn't include <X> will indeed start seeing
ignores based on grep-find-ignored-files in rgrep.  But, such a user can
just set grep-find-ignored-files to nil and then they'll stop seeing
ignores again.

Also, for what it's worth, note that the documentation for
grep-find-template says this:

  <X> - find options to restrict or expand the directory list
  <F> - find options to limit the files matched

So this change makes the documentation more accurate: <X> previously
also affected the files matched, but now it only affects the directory
list, as documented.  <F> continues to limit the files matched, as
before.