git: f098b537c932 - stable/13 - Speed up *-old-* make targets by using sed instead of xargs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Oct 2023 13:36:30 UTC
The branch stable/13 has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=f098b537c9323a6677dc549c9857a6e805405022
commit f098b537c9323a6677dc549c9857a6e805405022
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-04-01 22:58:00 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-10-10 13:36: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
(cherry picked from commit a8267ecc3df0aa633daa56360d67a24f9b1d3961)
---
Makefile.inc1 | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Makefile.inc1 b/Makefile.inc1
index ab9a9451299c..e0f5d9cae72d 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -3225,7 +3225,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)"
@@ -3292,7 +3293,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"
@@ -3333,7 +3334,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"