public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation
@ 2023-06-02 16:06 Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace Ulrich Müller
  0 siblings, 2 replies; 3+ messages in thread
From: Ulrich Müller @ 2023-06-02 16:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: tex, Ulrich Müller, Tim Harder

For texlive-latexextra-2021, SRC_URI calculation ran for 37 seconds
here. Reduced it to 0.025 seconds (i.e. more than a factor 1000) by
using bash arrays and parameter expansion instead of nested loops.

Reported-by: Tim Harder <radhermit@gentoo.org>
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/texlive-module.eclass | 39 +++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index fea4003c37a8..99a90d91654f 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -99,32 +99,39 @@ TEXLIVE_DEVS=${TEXLIVE_DEVS:- zlogene dilfridge sam }
 BDEPEND="${COMMON_DEPEND}
 	app-arch/xz-utils"
 
-for i in ${TEXLIVE_MODULE_CONTENTS}; do
-	for tldev in ${TEXLIVE_DEVS}; do
-		SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}"
-	done
+tl_uri_prefix="https://dev.gentoo.org/~@dev@/distfiles/texlive/tl-"
+tl_uri_suffix="-${PV}.${PKGEXT}"
+
+tl_uri=( ${TEXLIVE_MODULE_CONTENTS} )
+tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" )
+for tldev in ${TEXLIVE_DEVS}; do
+	SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}"
 done
 
 # Forge doc SRC_URI
-[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} doc? ("
-for i in ${TEXLIVE_MODULE_DOC_CONTENTS}; do
+if [[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]]; then
+	SRC_URI+=" doc? ("
+	tl_uri=( ${TEXLIVE_MODULE_DOC_CONTENTS} )
+	tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" )
 	for tldev in ${TEXLIVE_DEVS}; do
-		SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}"
+		SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}"
 	done
-done
-[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} )"
+	SRC_URI+=" )"
+fi
 
 # Forge source SRC_URI
-if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]] ; then
-	SRC_URI="${SRC_URI} source? ("
-	for i in ${TEXLIVE_MODULE_SRC_CONTENTS}; do
-		for tldev in ${TEXLIVE_DEVS}; do
-			SRC_URI="${SRC_URI} https://dev.gentoo.org/~${tldev}/distfiles/texlive/tl-${i}-${PV}.${PKGEXT}"
-		done
+if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]]; then
+	SRC_URI+=" source? ("
+	tl_uri=( ${TEXLIVE_MODULE_SRC_CONTENTS} )
+	tl_uri=( "${tl_uri[@]/%/${tl_uri_suffix}}" )
+	for tldev in ${TEXLIVE_DEVS}; do
+		SRC_URI+=" ${tl_uri[@]/#/${tl_uri_prefix/@dev@/${tldev}}}"
 	done
-	SRC_URI="${SRC_URI} )"
+	SRC_URI+=" )"
 fi
 
+unset tldev tl_uri tl_uri_prefix tl_uri_suffix
+
 RDEPEND="${COMMON_DEPEND}"
 
 IUSE="${IUSE} doc"
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands
  2023-06-02 16:06 [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation Ulrich Müller
@ 2023-06-02 16:06 ` Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace Ulrich Müller
  1 sibling, 0 replies; 3+ messages in thread
From: Ulrich Müller @ 2023-06-02 16:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: tex, Ulrich Müller

For texlive-latexextra-2021[doc], the number of "mv" commands is
reduced from 12718 to 3130. Speedup is also by a factor of about 4,
which saves another 4 seconds.

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/texlive-module.eclass | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index 99a90d91654f..a5c86b65cef0 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -164,10 +164,18 @@ texlive-module_src_unpack() {
 	sed -e 's/\/[^/]*$//' -e "s:^:${RELOC_TARGET}/:" "${T}/reloclist" |
 		sort -u |
 		xargs mkdir -p || die
-	local i
+	local i dir="" files=()
 	while read i; do
-		mv "${i}" "${RELOC_TARGET}/${i%/*}" || die
+		if [[ ${RELOC_TARGET}/${i%/*} != "${dir}" ]]; then
+			# new dir, do the previous move
+			[[ -z ${dir} ]] || mv "${files[@]}" "${dir}" || die
+			dir="${RELOC_TARGET}/${i%/*}"
+			files=()
+		fi
+		# collect files with same destination dir
+		files+=( "${i}" )
 	done < "${T}/reloclist"
+	mv "${files[@]}" "${dir}" || die
 }
 
 # @FUNCTION: texlive-module_add_format
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace
  2023-06-02 16:06 [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation Ulrich Müller
  2023-06-02 16:06 ` [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands Ulrich Müller
@ 2023-06-02 16:06 ` Ulrich Müller
  1 sibling, 0 replies; 3+ messages in thread
From: Ulrich Müller @ 2023-06-02 16:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: tex, Ulrich Müller

Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
 eclass/texlive-module.eclass | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index a5c86b65cef0..f9907ab7b617 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -341,8 +341,8 @@ texlive-module_src_compile() {
 	done
 
 	# Determine texlive-core version for fmtutil call
-        fmt_call="$(has_version '>=app-text/texlive-core-2019' \
-         && echo "fmtutil-user" || echo "fmtutil")"
+	fmt_call="$(has_version '>=app-text/texlive-core-2019' \
+		&& echo "fmtutil-user" || echo "fmtutil")"
 
 	# Build format files
 	for i in texmf-dist/fmtutil/format*.cnf; do
@@ -402,7 +402,6 @@ texlive-module_src_install() {
 		cp -pR tlpkg "${ED}/usr/share/" || die
 	fi
 
-
 	if [[ -d texmf-var ]]; then
 		insinto /var/lib/texmf
 		doins -r texmf-var/.
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-02 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 16:06 [gentoo-dev] [PATCH 1/3] texlive-module.eclass: Speed up SRC_URI calculation Ulrich Müller
2023-06-02 16:06 ` [gentoo-dev] [PATCH 2/3] texlive-module.eclass: Reduce number of executed external commands Ulrich Müller
2023-06-02 16:06 ` [gentoo-dev] [PATCH 3/3] texlive-module.eclass: Whitespace Ulrich Müller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox