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

Phil Sainty <[email protected]> Sat, 01 Aug 2026 16:51:55 +1200
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
On 2026-08-01 03:06, Manuel Giraud wrote:
> Your interrogations drive me into more tests ;-) So yes, OpenBSD has 
> its
> own implementation of find but there is also a package with GNU find
> (renamed gfind).  The version of GNU find, I have is:
> 
> find (GNU findutils) 4.10.0
> Copyright (C) 2024 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later 
> <https://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by Eric B. Decker, James Youngman, and Kevin Dalley.
> Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION
> FTS(FTS_CWDFD) CBO(level=1)

As my version was the older 4.8.0, I downloaded and compiled 4.10.0
(from which I see the same version/features output as you).

I find that 4.10.0 is *dramatically* faster than 4.8.0, regardless of
the -path vs -name syntax.

I then compiled all the releases from 4.8 to 4.11, and found that the
performance boost came about in 4.10.0 specifically, with any other
version performing just like the preceding one.

The only relevant NEWS change for GNU findutils 4.10.0 points to
https://savannah.gnu.org/bugs/?58427 which prevented the
short-circuiting of some operations; so my impression is that older
versions were needlessly testing too many of the (numerous) conditions
generated by the rgrep find command, causing the comparative slowness.

It's not only that, though -- while I can make 4.10 as slow as 4.8 by
adding "-O2" to the find options, I cannot make 4.8 (or 4.9) as fast
as 4.10 by adding "-O1" to the find options.  This makes me wonder
whether the short-circuiting functionality itself was also new to 4.10
(but there's no comment on this in the NEWS).


> What I conclude from these results:
> 
>          - GNU find is faster than native find.
> 
>          - I still don't see any significant speed up with your patch
>            (sorry).

Using 4.10.0 I too no longer see a large difference between the two,
although I continue to see a small difference.

Testing today:

| GNU find | Without my patch | With my patch |
|----------+------------------+---------------|
|    4.8.0 |           21.373 |        13.788 |
|   4.10.0 |            8.845 |         7.811 |

I ran each test repeatedly, and picked a representative result.


1a) Without my patch, using GNU find 4.8.0:

real	0m21.373s
user	0m14.965s
sys	0m6.405s

1b) With my patch, using GNU find 4.8.0

real	0m13.788s
user	0m8.130s
sys	0m5.650s

2a) Without my patch, using GNU find 4.10.0:

real	0m8.845s
user	0m3.287s
sys	0m5.553s

2b) With my patch, using GNU find 4.10.0:

real	0m7.811s
user	0m2.356s
sys	0m5.454s


As such, I'm still inclined to think there's a benefit to preferring
-name over -path, even if *by far* the bigger improvement for people
using GNU find 4.9 or earlier is to upgrade to 4.10 or later.


-Phil