git: ffd4db6b9406 - main - Speed up USES=cargo ports ops
Tobias Kortkamp
tobik at FreeBSD.org
Wed Apr 14 12:22:48 UTC 2021
The branch main has been updated by tobik:
URL: https://cgit.FreeBSD.org/ports/commit/?id=ffd4db6b940600e78ab01f8ef06bb3e7629f48e6
commit ffd4db6b940600e78ab01f8ef06bb3e7629f48e6
Author: Tobias Kortkamp <tobik at FreeBSD.org>
AuthorDate: 2021-04-14 11:53:37 +0000
Commit: Tobias Kortkamp <tobik at FreeBSD.org>
CommitDate: 2021-04-14 12:22:42 +0000
Speed up USES=cargo ports ops
MASTER_SITES aliases processing in the framework is very inefficient
and the CRATESIO indirection is not worth it. Normally ports only
have a handful of sites at most, but USES=cargo currently adds one
site for each crate by necessity. The inefficiency suddenly matters
a lot.
By consuming MASTER_SITE_CRATESIO directly we can sidestep this
issue without losing anything.
Before:
$ time make -C www/zola -V MASTER_SITES >/dev/null
4.21 real 4.14 user 0.03 sys
After:
$ time make -C www/zola -V MASTER_SITES >/dev/null
0.60 real 0.58 user 0.02 sys
---
Mk/Uses/cargo.mk | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Mk/Uses/cargo.mk b/Mk/Uses/cargo.mk
index 69a1ee45c8a4..816b720a2eef 100644
--- a/Mk/Uses/cargo.mk
+++ b/Mk/Uses/cargo.mk
@@ -15,7 +15,7 @@ IGNORE+= USES=cargo takes no arguments
.endif
# List of static dependencies. The format is cratename-version.
-# CARGO_CRATES will be downloaded from MASTER_SITES_CRATESIO.
+# CARGO_CRATES will be downloaded from MASTER_SITE_CRATESIO.
CARGO_CRATES?=
# List of features to build (space separated list).
@@ -35,7 +35,8 @@ CARGO_DIST_SUBDIR?= rust/crates
# Generate list of DISTFILES.
.for _crate in ${CARGO_CRATES}
-MASTER_SITES+= CRATESIO/${_crate:C/^([-_a-zA-Z0-9]+)-[0-9].*/\1/}/${_crate:C/^[-_a-zA-Z0-9]+-([0-9].*)/\1/}:cargo_${_crate:C/[^a-zA-Z0-9_]//g}
+# Resolving CRATESIO alias is very inefficient with many MASTER_SITES, consume MASTER_SITE_CRATESIO directly
+MASTER_SITES+= ${MASTER_SITE_CRATESIO:S,%SUBDIR%,${_crate:C/^([-_a-zA-Z0-9]+)-[0-9].*/\1/}/${_crate:C/^[-_a-zA-Z0-9]+-([0-9].*)/\1/},:S,$,:cargo_${_crate:C/[^a-zA-Z0-9_]//g},}
DISTFILES+= ${CARGO_DIST_SUBDIR}/${_crate}.tar.gz:cargo_${_crate:C/[^a-zA-Z0-9_]//g}
.endfor
More information about the dev-commits-ports-all
mailing list