From: Spencer Baugh Date: Wed, 3 Jul 2024 13:39:23 +0000 (+0200) Subject: Prefer to run find and grep in parallel in rgrep (bug#71094) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f5d0058b4828a8103d0b37d4209a7e3fde9311c4;p=emacs.git Prefer to run find and grep in parallel in rgrep (bug#71094) * lisp/progmodes/grep.el (grep-compute-defaults): Prefer `gnu' for grep-find-use-xargs over `exec-plus', but not on Windows. (bug#71094) (cherry picked from commit f7725d85f3132fb684032438f81defcb481892b7) --- diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 7ac19501741..826a66d6dbd 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -827,15 +827,23 @@ The value depends on `grep-command', `grep-template', (unless grep-find-use-xargs (setq grep-find-use-xargs (cond - ((grep-probe find-program - `(nil nil nil ,(null-device) "-exec" "echo" - "{}" "+")) - 'exec-plus) + ;; For performance, we want: + ;; A. Run grep on batches of files (instead of one grep per file) + ;; B. If the directory is large and we need multiple batches, + ;; run find in parallel with a running grep. + ;; "find | xargs grep" gives both A and B ((and + (not (eq system-type 'windows-nt)) (grep-probe find-program `(nil nil nil ,(null-device) "-print0")) (grep-probe xargs-program '(nil nil nil "-0" "echo"))) 'gnu) + ;; "find -exec {} +" gives A but not B + ((grep-probe find-program + `(nil nil nil ,(null-device) "-exec" "echo" + "{}" "+")) + 'exec-plus) + ;; "find -exec {} ;" gives neither A nor B. (t 'exec)))) (unless grep-find-command