]> git.eshelyaron.com Git - emacs.git/commit
In rgrep, check matching files before excluding files
authorSpencer Baugh <sbaugh@janestreet.com>
Sun, 26 May 2024 13:26:09 +0000 (09:26 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sun, 2 Jun 2024 11:18:28 +0000 (13:18 +0200)
commit70d904d10e64d73e99c513ff78e0e462776f5a1e
tree573c8e8e685130496f4e5b6e66e2cb1d1a4a604e
parent279aa19014e64410059c07563735bc7a3882c378
In rgrep, check matching files before excluding files

There are a lot of excluding globs, and checking them all is expensive.
The files glob (i.e. the glob for files we actually want) is usually
just one or two entries, so it's quite fast to check.

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.

Further optimizations are possible now that the ignores and matched
files are in the same <F> argument which can be rearranged more easily
without compatibility issues; I'll do those optimizations in later
commits.

* lisp/progmodes/grep.el (rgrep-find-ignores-in-<f>): Add.
* lisp/progmodes/grep.el (rgrep-default-command): Check
rgrep-find-ignores-in-<f> and move the excluded files glob to part of
the "files" argument.  (Bug#71179)

(cherry picked from commit b71fa27987d89774c84b0c9362ddfb4a0f679856)
lisp/progmodes/grep.el