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
This commit is contained in:
Ed Maste 2022-04-01 18:58:00 -04:00
parent 27f889cf41
commit a8267ecc3d

View File

@ -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"