summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-10-12 11:24:09 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-14 09:20:56 +0100
commit2844a495c673d0c06cccb6406266cd909e69344c (patch)
treedd2f1163f1dbfdbaa3ed5523abba7c58d51dc488 /meta/recipes-core
parent0986c77eb0d4b7ecb695bd13449a258e1a9a0977 (diff)
downloadpoky-2844a495c673d0c06cccb6406266cd909e69344c.tar.gz
initscripts: populate-volatiles: Speed up processing
Checking the requirements for each volatiles file in the populate-volatiles script can be very slow when there are a large number of volatiles files, easily consuming over 80% of the processing time. These checks don't usually uncover any problems so concatenate all the volatiles files together and process them as one large file for a "fast path" option. This ensures that the penalty for checking the requirements is only incurred once. In the event that checking the requirements for the unified file fails, fall back to the slow process of checking each one individually so that the offending one can be skipped. The core file is handled separately because it is responsible for creating the temp directory used by check_requirements and thus must always run first and without having its requirements checked. [YOCTO #12949] (From OE-Core rev: f380fac8a43a75861f3157777b12a317b985a5e1) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh37
1 files changed, 33 insertions, 4 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index 35316ec2ba..824f8f3a6b 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -112,7 +112,6 @@ check_requirements() {
112 } 112 }
113 113
114 CFGFILE="$1" 114 CFGFILE="$1"
115 [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
116 115
117 TMP_INTERMED="${TMPROOT}/tmp.$$" 116 TMP_INTERMED="${TMPROOT}/tmp.$$"
118 TMP_DEFINED="${TMPROOT}/tmpdefined.$$" 117 TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
@@ -154,8 +153,11 @@ check_requirements() {
154 153
155apply_cfgfile() { 154apply_cfgfile() {
156 CFGFILE="$1" 155 CFGFILE="$1"
156 SKIP_REQUIREMENTS="$2"
157 157
158 check_requirements "${CFGFILE}" || { 158 [ "${VERBOSE}" != "no" ] && echo "Applying ${CFGFILE}"
159
160 [ "${SKIP_REQUIREMENTS}" == "yes" ] || check_requirements "${CFGFILE}" || {
159 echo "Skipping ${CFGFILE}" 161 echo "Skipping ${CFGFILE}"
160 return 1 162 return 1
161 } 163 }
@@ -231,10 +233,37 @@ then
231 sh ${ROOT_DIR}/etc/volatile.cache 233 sh ${ROOT_DIR}/etc/volatile.cache
232else 234else
233 rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build 235 rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build
234 for file in `ls -1 "${CFGDIR}" | sort`; do 236
235 apply_cfgfile "${CFGDIR}/${file}" 237 # Apply the core file with out checking requirements. ${TMPROOT} is
238 # needed by check_requirements but is setup by this file, so it must be
239 # processed first and without being checked.
240 [ -e "${CFGDIR}/${COREDEF}" ] && apply_cfgfile "${CFGDIR}/${COREDEF}" "yes"
241
242 # Fast path: check_requirements is slow and most of the time doesn't
243 # find any problems. If there are a lot of config files, it is much
244 # faster to to concatenate them all together and process them once to
245 # avoid the overhead of calling check_requirements repeatedly
246 TMP_FILE="${TMPROOT}/tmp_volatile.$$"
247 rm -f "$TMP_FILE"
248
249 CFGFILES="`ls -1 "${CFGDIR}" | grep -v "^${COREDEF}\$" | sort`"
250 for file in ${CFGFILES}; do
251 cat "${CFGDIR}/${file}" >> "$TMP_FILE"
236 done 252 done
237 253
254 if check_requirements "$TMP_FILE"
255 then
256 apply_cfgfile "$TMP_FILE" "yes"
257 else
258 # Slow path: One or more config files failed requirements.
259 # Process each one individually so the offending one can be
260 # skipped
261 for file in ${CFGFILES}; do
262 apply_cfgfile "${CFGDIR}/${file}"
263 done
264 fi
265 rm "$TMP_FILE"
266
238 [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache 267 [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache
239fi 268fi
240 269