Skip to contentSkip to conversation

Inefficient find of pkg data

PATCH New Elizabeth Flanagan 1 participant 2 messages May 30, 2012

lore
Share & tools
lore
#0 lore raw

cover Inefficient find of pkg data

[YOCTO #2419]

find -name is a horrible way to find files (.025s per exec). Changing this to shell expansion (.002 per exec). Also, no point in having a big for loop when I pipe this into head anyway.

I tried this a few ways and this seems the most efficient reducing rootfs generation down to around 30s from around 50s.

The following changes since commit 348da93e283b2b8454fd9cde80d4b17378e2a168:

webkit-gtk: Use glib as unicode backend to avoid browser crash (2012-05-30 17:38:02 +0100)

are available in the git repository at:
git://git.yoctoproject.org/poky-contrib eflanagan/license_1.3
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=eflanagan/license_1.3

Elizabeth Flanagan (1):
license.bbclass: optimize pkg runtime data

 meta/classes/license.bbclass |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 license.bbclass: optimize pkg runtime data

This fixes an ugly way I was trying to find pkg runtime data for package and license manifest creation.

rootfs generation times for core-image-minimal:

Prior to patch
real 0m41.570s
user 1m40.466s
sys 0m6.768s

With patch
real 0m27.527s
user 0m9.833s
sys 0m3.496s

---
 meta/classes/license.bbclass |   40 +++++++++++++++++++---------------------
 1 files changed, 19 insertions(+), 21 deletions(-)
meta/classes/license.bbclass +19 -21
index 6c4a673..d93ddf9 100644
@@ -86,28 +86,26 @@ license_create_manifest() {
 	# list of installed packages is broken for deb
 	for pkg in ${INSTALLED_PKGS}; do
 		# not the best way to do this but licenses are not arch dependant iirc
-		files=`find ${TMPDIR}/pkgdata/*/runtime -name ${pkg}| head -1`
-		for filename in $files; do
-			pkged_pn="$(sed -n 's/^PN: //p' ${filename})"
-			pkged_lic="$(sed -n '/^LICENSE: /{ s/^LICENSE: //; s/[+|&()*]/ /g; s/  */ /g; p }' ${filename})"
-			# check to see if the package name exists in the manifest. if so, bail.
-			if ! grep -q "PACKAGE NAME: ${pkg}" ${filename}; then
-				# exclude local recipes
-				if [ ! "${pkged_pn}" = "*locale*" ]; then
-					echo "PACKAGE NAME:" ${pkg} >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-					echo "RECIPE NAME:" ${pkged_pn} >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-					echo "LICENSE: " >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-					for lic in ${pkged_lic}; do
-						if [ -e "${LICENSE_DIRECTORY}/${pkged_pn}/generic_${lic}" ]; then
-							echo ${lic}|sed s'/generic_//'g >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-						else
-							echo "WARNING: The license listed, " ${lic} " was not in the licenses collected for " ${pkged_pn}>> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-						fi
-					done
-					echo "" >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
-				fi
+		filename=`ls ${TMPDIR}/pkgdata/*/runtime/${pkg}| head -1`
+		pkged_pn="$(sed -n 's/^PN: //p' ${filename})"
+		pkged_lic="$(sed -n '/^LICENSE: /{ s/^LICENSE: //; s/[+|&()*]/ /g; s/  */ /g; p }' ${filename})"
+		# check to see if the package name exists in the manifest. if so, bail.
+		if ! grep -q "PACKAGE NAME: ${pkg}" ${filename}; then
+			# exclude local recipes
+			if [ ! "${pkged_pn}" = "*locale*" ]; then
+				echo "PACKAGE NAME:" ${pkg} >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+				echo "RECIPE NAME:" ${pkged_pn} >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+				echo "LICENSE: " >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+				for lic in ${pkged_lic}; do
+					if [ -e "${LICENSE_DIRECTORY}/${pkged_pn}/generic_${lic}" ]; then
+						echo ${lic}|sed s'/generic_//'g >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+					else
+						echo "WARNING: The license listed, " ${lic} " was not in the licenses collected for " ${pkged_pn}>> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
+					fi
+				done
+				echo "" >> ${LICENSE_DIRECTORY}/${IMAGE_NAME}/license.manifest
 			fi
-		done
+		fi
 	done
 
 	# Two options here:
Signature · 1 line
1.7.5.4