git: a8267ecc3df0 - main - Speed up *-old-* make targets by using sed instead of xargs

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sat, 09 Apr 2022 00:41:18 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=a8267ecc3df0aa633daa56360d67a24f9b1d3961

commit a8267ecc3df0aa633daa56360d67a24f9b1d3961
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-04-01 22:58:00 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-04-09 00:41:10 +0000

    Speed up *-old-* make targets by using sed instead of xargs
    
    Targets like 'list-old-files' used "xargs -n1" to produce a list with
    one file per line.  Using xargs resulted in one fork+exec for each
    Argument, resulting in rather long runtime.  Instead, use sed to split
    the list.  On one machine `make list-old-files` took 30s wall clock time
    with xargs and less than 1s with sed.
    
    Reviewed by:    jhb
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34741
---
 Makefile.inc1 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index f4d5b4cc8050..1f29e89881c0 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -3208,7 +3208,8 @@ list-old-files: .PHONY
 	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
 	    -V OLD_FILES -V "OLD_FILES:Musr/share/*.gz:R" \
 	    -V "OLD_FILES:Mlib/*.so.*:S,^lib,usr/lib32," \
-	    -V "OLD_FILES:Musr/lib/*:S,^usr/lib,usr/lib32," | xargs -n1 | sort
+	    -V "OLD_FILES:Musr/lib/*:S,^usr/lib,usr/lib32," | \
+	    sed -E 's/[[:space:]]+/\n/g' | sort
 
 delete-old-files: .PHONY
 	@echo ">>> Removing old files (only deletes safe to delete libs)"
@@ -3275,7 +3276,7 @@ list-old-libs: .PHONY
 	    -V OLD_LIBS -V MOVED_LIBS -V "OLD_LIBS:Mlib/*:S,^lib,usr/lib32," \
 	    -V "OLD_LIBS:Musr/lib/*:S,^usr/lib,usr/lib32," \
 	    -V "OLD_LIBS:Mlib/casper/*:S,^lib/casper,usr/lib32," | \
-	    xargs -n1 | sort
+	    sed -E 's/[[:space:]]+/\n/g' | sort
 
 delete-old-libs: .PHONY
 	@echo ">>> Removing old libraries"
@@ -3316,7 +3317,7 @@ check-old-libs: .PHONY
 list-old-dirs: .PHONY
 	@cd ${.CURDIR}; \
 	${MAKE} -f ${.CURDIR}/Makefile.inc1 ${.MAKEFLAGS} ${.TARGET} \
-	    -V OLD_DIRS | xargs -n1 | sort -r
+	    -V OLD_DIRS | sed -E 's/[[:space:]]+/\n/g' | sort -r
 
 delete-old-dirs: .PHONY
 	@echo ">>> Removing old directories"