aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2016-09-01 17:18:54 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-05-17 10:10:46 +0300
commitd2c05be20b68fd0a9674f0e3656a4b0804ba2f39 (patch)
tree6f96b0025b7b01a6e0cb504c8ce7d31a4fcb25c0
parent73a05b3eeca0e7562f7c688a79d3e41a810d8350 (diff)
downloadopenembedded-core-contrib-d2c05be20b68fd0a9674f0e3656a4b0804ba2f39.tar.gz
devtools/images: add python-pgo-image
This is a special image for profiling Python in order to utilize profile-guided-optimization. Profile data can be obtained by by running bitbake python-pgo-image -c profile. It will be located in the directory pointed by ${PYTHON_PROFILE_DIR}. The profile task that is run can be altered by specifying ${PYTHON_PROFILE_TASK}. [YOCTO #9338] Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--meta/recipes-devtools/images/python-pgo-image.bb62
1 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-devtools/images/python-pgo-image.bb b/meta/recipes-devtools/images/python-pgo-image.bb
new file mode 100644
index 0000000000..af9da20338
--- /dev/null
+++ b/meta/recipes-devtools/images/python-pgo-image.bb
@@ -0,0 +1,62 @@
+SUMMARY = "Minimal image for doing Python profiling (for PGO)"
+
+IMAGE_FEATURES += "ssh-server-dropbear"
+IMAGE_INSTALL = "packagegroup-core-boot python-profile-opt python-profile-opt-tests"
+
+LICENSE = "MIT"
+
+inherit core-image
+
+PYTHON_PROFILE_DIR ?= "${TMPDIR}/work-shared/${MACHINE}/python/pgo-data"
+PYTHON_PROFILE_TASK ?= "-m test.regrtest --pgo -w -x test_asyncore test_gdb test_multiprocessing test_subprocess"
+
+# We need these because we're utilizing the runtime test helpers from oeqa
+TEST_TARGET ?= "qemu"
+TEST_QEMUBOOT_TIMEOUT ?= "1000"
+TEST_LOG_DIR ?= "${WORKDIR}/qemulogs"
+FIND_ROOTFS = "1"
+
+python do_profile() {
+ from oeqa.targetcontrol import get_target_controller
+ from oe.utils import getstatusoutput
+
+ target = get_target_controller(d)
+ target.deploy()
+ try:
+ # Boot target
+ bootparams = None
+ if d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd':
+ bootparams = 'systemd.log_level=debug systemd.log_target=console'
+ target.start(extra_bootparams=bootparams)
+
+ # Run profile task
+ profile_cmd = 'LD_LIBRARY_PATH=/opt/lib /opt/bin/python %s' % d.getVar("PYTHON_PROFILE_TASK", True)
+ ret, output = target.run(profile_cmd, timeout=7200)
+ if ret:
+ bb.fatal("Failed to run profile task on target: %s" % output)
+ ret, output = target.run('tar czf pgo-data.tgz -C /home/root/python-pgo-profiles/ .')
+ if ret:
+ bb.fatal("Failed to archive profile data on target: %s" % output)
+
+ # Retrieve and unpack profile data
+ profile_dir = d.getVar("PYTHON_PROFILE_DIR", True)
+ target.copy_from('/home/root/pgo-data.tgz', profile_dir)
+
+ profile_tarball = os.path.join(profile_dir, 'pgo-data.tgz')
+ ret, output = getstatusoutput('tar xf %s -C %s' % (profile_tarball, profile_dir))
+ os.unlink(profile_tarball)
+ if ret:
+ bb.fatal("Failed to unpack python profile data: %s" % output)
+ finally:
+ target.stop()
+
+ # Exclude files causing problems in cross-profiling
+ excludes = [os.path.join(profile_dir, 'Modules', 'posixmodule.gcda')]
+ for path in excludes:
+ if os.path.exists(path):
+ os.unlink(path)
+}
+
+addtask profile after do_build
+do_profile[depends] += "qemu-native:do_populate_sysroot qemu-helper-native:do_populate_sysroot"
+do_profile[cleandirs] = "${PYTHON_PROFILE_DIR}"