Subject: bug#71094: closed (Re: bug#71094: [PATCH] Prefer to run find and grep in parallel in rgrep)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 03 Jul 2024 13:46:02 +0000

Your bug report

#71094: [PATCH] Prefer to run find and grep in parallel in rgrep

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71094: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71094
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71094: [PATCH] Prefer to run find and grep in parallel in rgrep
From: Andrea Corallo <[email-masked]>
To: Spencer Baugh <[email-masked]>
Cc: [email-masked], Eli Zaretskii <[email-masked]>, [email-masked], Stefan Kangas <[email-masked]>, [email-masked]
Date: Wed, 03 Jul 2024 09:42:52 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Spencer Baugh <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>> Spencer Baugh <[email-masked]> writes:
>>
>>> Eli Zaretskii <[email-masked]> writes:
>>>>> From: Spencer Baugh <[email-masked]>
>>>>> Cc: [email-masked],  [email-masked],  [email-masked]
>>>>> Date: Thu, 30 May 2024 08:29:04 -0400
>>>>>
>>>>> Eli Zaretskii <[email-masked]> writes:
>>>>>
>>>>> > Thanks, LGTM.
>>>>>
>>>>> So is this OK to install now?
>>>>
>>>> As far as I'm concerned, yes.  I don't know if the other participants
>>>> of this discussion are okay with this or they still have some
>>>> comments.
>>>
>>> Since no-one else has made any comments, could this be installed now?
>>
>> Yes, please go ahead, and thanks.
>
> I don't actually have commit access (AFAIK?) so someone else will need
> to push it :)

Should be done, please double check.

Closing meanwhile.

  Andrea

Subject: [PATCH] Prefer to run find and grep in parallel in rgrep
From: Spencer Baugh <[email-masked]>
To: [email-masked]
Cc: Glenn Morris <[email-masked]>, [email-masked]
Date: Tue, 21 May 2024 10:35:07 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

grep.el prefers to run "find" and "xargs grep" in a pipeline,
which means that "find" can continue searching the filesystem
while "xargs grep" searches files.  If find and xargs don't
support the flags required for this behavior, grep.el will fall
back to using the -exec flags to "find", which meant "find" will
wait for each "grep" process to complete before continuing to
search the filesystem tree.  This behavior is controlled by
grep-find-use-xargs; `gnu' produces the pipeline and `exec' is
the slower fallback.

In f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9, the `exec-plus'
option was added for grep-find-use-xargs, which improves on
`exec' by running one "grep" process to search multiple files,
which `gnu' (by using xargs) already did.  However, the change
erroneously added the `exec-plus' case before the `gnu' case in
the autodetection code in grep-compute-defaults, so `exec-plus'
would be used even if `gnu' was supported.

This change just swaps the two cases, so the faster `gnu' option
is once again used in preference to `exec-plus'.  In my
benchmarking on a large repository, this provides a ~40%
speedup.

In GNU Emacs 29.2.50 (build 11, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2024-05-15 built on
 igm-qws-u22796a
Repository revision: 734740051bd377d24899d08d00ec8e1bb8e00e00
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.9 (Green Obsidian)

Configured using:
 'configure -C --with-x-toolkit=lucid --with-gif=ifavailable'

>From 06f0683b51088e4c1c080408624f310d6561a381 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <[email-masked]>
Date: Tue, 21 May 2024 10:32:45 -0400
Subject: [PATCH] Prefer to run find and grep in parallel in rgrep

grep.el prefers to run "find" and "xargs grep" in a pipeline,
which means that "find" can continue searching the filesystem
while "xargs grep" searches files.  If find and xargs don't
support the flags required for this behavior, grep.el will fall
back to using the -exec flags to "find", which meant "find" will
wait for each "grep" process to complete before continuing to
search the filesystem tree.  This behavior is controlled by
grep-find-use-xargs; `gnu' produces the pipeline and `exec' is
the slower fallback.

In f3ca7378c1336b3ff98ecb5a99a98c7b2eceece9, the `exec-plus'
option was added for grep-find-use-xargs, which improves on
`exec' by running one "grep" process to search multiple files,
which `gnu' (by using xargs) already did.  However, the change
erroneously added the `exec-plus' case before the `gnu' case in
the autodetection code in grep-compute-defaults, so `exec-plus'
would be used even if `gnu' was supported.

This change just swaps the two cases, so the faster `gnu' option
is once again used in preference to `exec-plus'.  In my
benchmarking on a large repository, this provides a ~40%
speedup.

* lisp/progmodes/grep.el (grep-compute-defaults): Prefer `gnu'.
for grep-find-use-xargs over `exec-plus'.
---
 lisp/progmodes/grep.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 657349cbdff..04056e13685 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -812,15 +812,15 @@ grep-compute-defaults
 	(unless grep-find-use-xargs
 	  (setq grep-find-use-xargs
 		(cond
-		 ((grep-probe find-program
-			      `(nil nil nil ,(null-device) "-exec" "echo"
-				    "{}" "+"))
-		  'exec-plus)
 		 ((and
 		   (grep-probe
                     find-program `(nil nil nil ,(null-device) "-print0"))
 		   (grep-probe xargs-program '(nil nil nil "-0" "echo")))
 		  'gnu)
+		 ((grep-probe find-program
+			      `(nil nil nil ,(null-device) "-exec" "echo"
+				    "{}" "+"))
+		  'exec-plus)
 		 (t
 		  'exec))))
 	(unless grep-find-command
-- 
2.39.3