All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] sstate/staging: Batch log messages for performance
@ 2017-02-01 12:05 Richard Purdie
  2017-02-01 12:05 ` [PATCH 2/3] staging: Reduce the number of mkdirs calls Richard Purdie
  2017-02-01 12:05 ` [PATCH 3/3] meta-environment: Clean up the task structure to reduce manifest warnings Richard Purdie
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Purdie @ 2017-02-01 12:05 UTC (permalink / raw)
  To: openembedded-core

According to profile data, repeated calls to bb.debug and bb.note in
the extend_recipe_sysroot() codepath were accounting for 75% of the time
(1.5s) in calls from tasks like do_image_complete.

This batches up the log messages into one call into the logging system
which gives similar behaviour to disabling the logging but retains the
debug information.

Since setscene_depvalid is also called from bitbake's setscene code,
we have to be a little creative with the function parameters and leave
the other debug output mechanism in place. This should hopefully
speed up recipe specific sysroots.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/sstate.bbclass  | 14 ++++++++++----
 meta/classes/staging.bbclass | 11 +++++++----
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index aeb7466..ada6fe5 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -909,13 +909,19 @@ def sstate_checkhashes(sq_fn, sq_task, sq_hash, sq_hashfn, d, siginfo=False):
 
 BB_SETSCENE_DEPVALID = "setscene_depvalid"
 
-def setscene_depvalid(task, taskdependees, notneeded, d):
+def setscene_depvalid(task, taskdependees, notneeded, d, log=None):
     # taskdependees is a dict of tasks which depend on task, each being a 3 item list of [PN, TASKNAME, FILENAME]
     # task is included in taskdependees too
     # Return - False - We need this dependency
     #        - True - We can skip this dependency
 
-    bb.debug(2, "Considering setscene task: %s" % (str(taskdependees[task])))
+    def logit(msg, log):
+        if log is not None:
+            log.append(msg)
+        else:
+            bb.debug(2, msg)
+
+    logit("Considering setscene task: %s" % (str(taskdependees[task])), log)
 
     def isNativeCross(x):
         return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
@@ -933,7 +939,7 @@ def setscene_depvalid(task, taskdependees, notneeded, d):
         return True
 
     for dep in taskdependees:
-        bb.debug(2, "  considering dependency: %s" % (str(taskdependees[dep])))
+        logit("  considering dependency: %s" % (str(taskdependees[dep])), log)
         if task == dep:
             continue
         if dep in notneeded:
@@ -987,7 +993,7 @@ def setscene_depvalid(task, taskdependees, notneeded, d):
 
 
         # Safe fallthrough default
-        bb.debug(2, " Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])))
+        logit(" Default setscene dependency fall through due to dependency: %s" % (str(taskdependees[dep])), log)
         return False
     return True
 
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index b9c84a4..35e53fe 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -441,6 +441,7 @@ python extend_recipe_sysroot() {
     bb.note("Direct dependencies are %s" % str(configuredeps))
     #bb.note(" or %s" % str(start))
 
+    msgbuf = []
     # Call into setscene_depvalid for each sub-dependency and only copy sysroot files
     # for ones that would be restored from sstate.
     done = list(start)
@@ -455,19 +456,21 @@ python extend_recipe_sysroot() {
                 taskdeps = {}
                 taskdeps[dep] = setscenedeps[dep][:2]
                 taskdeps[datadep] = setscenedeps[datadep][:2]
-                retval = setscene_depvalid(datadep, taskdeps, [], d)
+                retval = setscene_depvalid(datadep, taskdeps, [], d, msgbuf)
                 if retval:
-                    bb.note("Skipping setscene dependency %s for installation into the sysroot" % datadep)
+                    msgbuf.append("Skipping setscene dependency %s for installation into the sysroot")
                     continue
                 done.append(datadep)
                 new.append(datadep)
                 if datadep not in configuredeps and setscenedeps[datadep][1] == "do_populate_sysroot":
                     configuredeps.append(datadep)
-                    bb.note("Adding dependency on %s" % setscenedeps[datadep][0])
+                    msgbuf.append("Adding dependency on %s" % setscenedeps[datadep][0])
                 else:
-                    bb.note("Following dependency on %s" % setscenedeps[datadep][0])
+                    msgbuf.append("Following dependency on %s" % setscenedeps[datadep][0])
         next = new
 
+    bb.note("\n".join(msgbuf))
+
     stagingdir = d.getVar("STAGING_DIR")
     recipesysroot = d.getVar("RECIPE_SYSROOT")
     recipesysrootnative = d.getVar("RECIPE_SYSROOT_NATIVE")
-- 
2.7.4



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

* [PATCH 2/3] staging: Reduce the number of mkdirs calls
  2017-02-01 12:05 [PATCH 1/3] sstate/staging: Batch log messages for performance Richard Purdie
@ 2017-02-01 12:05 ` Richard Purdie
  2017-02-01 12:05 ` [PATCH 3/3] meta-environment: Clean up the task structure to reduce manifest warnings Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2017-02-01 12:05 UTC (permalink / raw)
  To: openembedded-core

The number of mkdir calls was showing up high on the profile charts since
it was getting called once per file which is excessive. Each call results
in one or more syscalls which is bad for performance. Cache which
directories we've seen to reduce the calls to a more reasonable number
and speed up recipe specific sysroots.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/staging.bbclass | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index 35e53fe..93d31eb 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -244,7 +244,7 @@ python do_populate_sysroot_setscene () {
 }
 addtask do_populate_sysroot_setscene
 
-def staging_copyfile(c, target, fixme, postinsts, stagingdir):
+def staging_copyfile(c, target, fixme, postinsts, stagingdir, seendirs):
     import errno
 
     if c.endswith("/fixmepath"):
@@ -255,7 +255,10 @@ def staging_copyfile(c, target, fixme, postinsts, stagingdir):
     #bb.warn(c)
     dest = c.replace(stagingdir, "")
     dest = target + "/" + "/".join(dest.split("/")[3:])
-    bb.utils.mkdirhier(os.path.dirname(dest))
+    destdir = os.path.dirname(dest)
+    if destdir not in seendirs:
+        bb.utils.mkdirhier(destdir)
+        seendirs.add(destdir)
     if "/usr/bin/postinst-" in c:
         postinsts.append(dest)
     if os.path.islink(c):
@@ -278,10 +281,12 @@ def staging_copyfile(c, target, fixme, postinsts, stagingdir):
                 raise
     return dest
 
-def staging_copydir(c, target, stagingdir):
+def staging_copydir(c, target, stagingdir, seendirs):
     dest = c.replace(stagingdir, "")
     dest = target + "/" + "/".join(dest.split("/")[3:])
-    bb.utils.mkdirhier(dest)
+    if dest not in seendirs:
+        bb.utils.mkdirhier(dest)
+        seendirs.add(dest)
 
 def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d):
     import subprocess
@@ -302,6 +307,7 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
 
     fixme = []
     postinsts = []
+    seendirs = set()
     stagingdir = d.getVar("STAGING_DIR")
     if native:
         pkgarchs = ['${BUILD_ARCH}', '${BUILD_ARCH}_*']
@@ -332,10 +338,10 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
                 for l in f:
                     l = l.strip()
                     if l.endswith("/"):
-                        staging_copydir(l, targetdir, stagingdir)
+                        staging_copydir(l, targetdir, stagingdir, seendirs)
                         continue
                     try:
-                        staging_copyfile(l, targetdir, fixme, postinsts, stagingdir)
+                        staging_copyfile(l, targetdir, fixme, postinsts, stagingdir, seendirs)
                     except FileExistsError:
                         continue
 
@@ -492,6 +498,7 @@ python extend_recipe_sysroot() {
     fixme = {}
     fixme[''] = []
     fixme['native'] = []
+    seendirs = set()
     postinsts = []
     multilibs = {}
     manifests = {}
@@ -570,14 +577,14 @@ python extend_recipe_sysroot() {
                     l = l.strip()
                     if l.endswith("/"):
                         if native:
-                            dest = staging_copydir(l, recipesysrootnative, stagingdir)
+                            dest = staging_copydir(l, recipesysrootnative, stagingdir, seendirs)
                         else:
-                            dest = staging_copydir(l, destsysroot, stagingdir)
+                            dest = staging_copydir(l, destsysroot, stagingdir, seendirs)
                         continue
                     if native:
-                        dest = staging_copyfile(l, recipesysrootnative, fixme['native'], postinsts, stagingdir)
+                        dest = staging_copyfile(l, recipesysrootnative, fixme['native'], postinsts, stagingdir, seendirs)
                     else:
-                        dest = staging_copyfile(l, destsysroot, fixme[''], postinsts, stagingdir)
+                        dest = staging_copyfile(l, destsysroot, fixme[''], postinsts, stagingdir, seendirs)
                     if dest:
                         m.write(dest.replace(workdir + "/", "") + "\n")
 
-- 
2.7.4



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

* [PATCH 3/3] meta-environment: Clean up the task structure to reduce manifest warnings
  2017-02-01 12:05 [PATCH 1/3] sstate/staging: Batch log messages for performance Richard Purdie
  2017-02-01 12:05 ` [PATCH 2/3] staging: Reduce the number of mkdirs calls Richard Purdie
@ 2017-02-01 12:05 ` Richard Purdie
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2017-02-01 12:05 UTC (permalink / raw)
  To: openembedded-core

This puts the dependencies on the correct task and removes pointless
noexec tasks allowing for a slightly cleaner task structure.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-core/meta/meta-environment.bb | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-core/meta/meta-environment.bb b/meta/recipes-core/meta/meta-environment.bb
index 1128a56..c7ac05d 100644
--- a/meta/recipes-core/meta/meta-environment.bb
+++ b/meta/recipes-core/meta/meta-environment.bb
@@ -19,12 +19,10 @@ SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}"
 
 inherit cross-canadian
 
-# Need to ensure we have the virtual mappings and site files for all multtilib 
-# variants
-DEPENDS += "${@all_multilib_tune_values(d, 'TOOLCHAIN_NEED_CONFIGSITE_CACHE')}"
-
 do_generate_content[cleandirs] = "${SDK_OUTPUT}"
 do_generate_content[dirs] = "${SDK_OUTPUT}/${SDKPATH}"
+# Need to ensure we have the virtual mappings and site files for all multtilib variants
+do_generate_content[depends] = "${@oe.utils.build_depends_string(all_multilib_tune_values(d, 'TOOLCHAIN_NEED_CONFIGSITE_CACHE'), 'do_populate_sysroot')}"
 python do_generate_content() {
     # Handle multilibs in the SDK environment, siteconfig, etc files...
     localdata = bb.data.createCopy(d)
@@ -74,6 +72,6 @@ FILES_${PN}= " \
 deltask do_fetch
 deltask do_unpack
 deltask do_patch
-do_configure[noexec] = "1"
-do_compile[noexec] = "1"
-do_populate_sysroot[noexec] = "1"
+deltask do_configure
+deltask do_compile
+deltask do_populate_sysroot
-- 
2.7.4



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

end of thread, other threads:[~2017-02-01 12:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-01 12:05 [PATCH 1/3] sstate/staging: Batch log messages for performance Richard Purdie
2017-02-01 12:05 ` [PATCH 2/3] staging: Reduce the number of mkdirs calls Richard Purdie
2017-02-01 12:05 ` [PATCH 3/3] meta-environment: Clean up the task structure to reduce manifest warnings Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.