Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 14/20] python-pgo-image: profiling for python3
Date: Mon, 20 Feb 2017 12:35:45 +0200	[thread overview]
Message-ID: <20170220103551.20022-14-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <20170220103551.20022-1-markus.lehtonen@linux.intel.com>

Add a new 'do_profile3' task for python-pgo-image that runs profiling
task for python3 and retrieves the profile data, similarly to
'do_profile' for python2. Profile data will be copied into a directory
pointed by PYTHON3_PROFILE_DIR on the host system. The profile task may
be specified with PYTHON3_PROFILE_TASK.

[YOCTO #9338]

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 meta/recipes-devtools/images/python-pgo-image.bb | 55 +++++++++++++++++++-----
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/meta/recipes-devtools/images/python-pgo-image.bb b/meta/recipes-devtools/images/python-pgo-image.bb
index bab95f8..ca690d5 100644
--- a/meta/recipes-devtools/images/python-pgo-image.bb
+++ b/meta/recipes-devtools/images/python-pgo-image.bb
@@ -3,6 +3,7 @@ SUMMARY = "Minimal image for doing Python profiling (for PGO)"
 IMAGE_FEATURES += "ssh-server-dropbear"
 IMAGE_INSTALL = "packagegroup-core-boot"
 IMAGE_INSTALL += "python-profile-opt python-profile-opt-tests python-profile-opt-tools"
+IMAGE_INSTALL += "python-profile-opt3 python-profile-opt3-tests"
 
 LICENSE = "MIT"
 
@@ -20,12 +21,17 @@ PYTHON_PROFILE_TASK_DEFAULT = "-m test.regrtest --pgo -w -x test_asyncore test_g
 PYTHON_PROFILE_TASK_DEFAULT = "/opt/share/doc/python-profile-opt/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck"
 PYTHON_PROFILE_TASK ?= "${PYTHON_PROFILE_TASK_DEFAULT}"
 
+PYTHON3_PROFILE_DIR ?= "${TMPDIR}/work-shared/${MACHINE}/python3/pgo-data"
+PYTHON3_PROFILE_TASK_DEFAULT = "-m test.regrtest --pgo -w -x test_asyncore test_gdb test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_main_handling test_multiprocessing_spawn test_subprocess"
+
+PYTHON3_PROFILE_TASK ?= "${PYTHON3_PROFILE_TASK_DEFAULT}"
+
 # 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"
 
-python do_profile() {
+def run_profile(d, profile_bin, profile_task, tgt_in_dir, host_out_dir):
     from oeqa.targetcontrol import get_target_controller
     from oe.utils import getstatusoutput
 
@@ -39,37 +45,64 @@ python do_profile() {
         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)
+        ret, output = target.run(profile_bin + ' ' + profile_task, 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/ .')
+        ret, output = target.run('tar czf pgo-data.tgz -C %s .' % tgt_in_dir)
         if ret:
             bb.fatal("Failed to archive profile data on target: %s" % output)
 
         # Retrieve and unpack profile data
-        profile_dir = d.getVar("PROFILE_DATA_WORKDIR", True)
-        target.copy_from('/home/root/pgo-data.tgz', profile_dir)
+        target.copy_from('/home/root/pgo-data.tgz', host_out_dir)
 
-        profile_tarball = os.path.join(profile_dir, 'pgo-data.tgz')
-        ret, output = getstatusoutput('tar xf %s -C %s' % (profile_tarball, profile_dir))
+        profile_tarball = os.path.join(host_out_dir, 'pgo-data.tgz')
+        ret, output = getstatusoutput('tar xf %s -C %s' % (profile_tarball, host_out_dir))
         os.unlink(profile_tarball)
         if ret:
             bb.fatal("Failed to unpack python profile data: %s" % output)
     finally:
         target.stop()
+
+
+# Profile task for Python2
+python do_profile() {
+    run_profile(d, 'LD_LIBRARY_PATH=/opt/lib /opt/bin/python',
+                d.getVar('PYTHON_PROFILE_TASK', True),
+                '/home/root/python-pgo-profiles/',
+                os.path.join(d.getVar("PROFILE_DATA_WORKDIR", True), 'python'))
 }
 
 addtask profile after do_build
 do_profile[depends] += "qemu-native:do_populate_sysroot qemu-helper-native:do_populate_sysroot"
-do_profile[cleandirs] = "${PROFILE_DATA_WORKDIR}"
-
+do_profile[cleandirs] = "${PROFILE_DATA_WORKDIR}/python"
 
 python do_profile_setscene () {
     sstate_setscene(d)
 }
 
 SSTATETASKS += "do_profile"
-do_profile[sstate-inputdirs] = "${PROFILE_DATA_WORKDIR}"
+do_profile[sstate-inputdirs] = "${PROFILE_DATA_WORKDIR}/python"
 do_profile[sstate-outputdirs] = "${PYTHON_PROFILE_DIR}"
 addtask do_profile_setscene
+
+
+# Profile task for Python3
+python do_profile3() {
+    run_profile(d, 'LD_LIBRARY_PATH=/opt/lib /opt/bin/python3',
+                d.getVar('PYTHON3_PROFILE_TASK', True),
+                '/home/root/python3-pgo-profiles/',
+                os.path.join(d.getVar("PROFILE_DATA_WORKDIR", True), 'python3'))
+}
+
+addtask profile3 after do_build
+do_profile3[depends] += "qemu-native:do_populate_sysroot qemu-helper-native:do_populate_sysroot"
+do_profile3[cleandirs] = "${PROFILE_DATA_WORKDIR}/python3"
+
+python do_profile3_setscene () {
+    sstate_setscene(d)
+}
+
+SSTATETASKS += "do_profile3"
+do_profile3[sstate-inputdirs] = "${PROFILE_DATA_WORKDIR}/python3"
+do_profile3[sstate-outputdirs] = "${PYTHON3_PROFILE_DIR}"
+addtask do_profile3_setscene
-- 
2.10.2



  parent reply	other threads:[~2017-02-20 10:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 10:35 [PATCH 01/20] python-native: support profile optimized build Markus Lehtonen
2017-02-20 10:35 ` [PATCH 02/20] python: add python-profile-opt recipe Markus Lehtonen
2017-02-20 10:35 ` [PATCH 03/20] python: remove path hack from setup.py Markus Lehtonen
2017-02-20 10:35 ` [PATCH 04/20] python-profile-opt: rename libpython Markus Lehtonen
2017-02-20 10:35 ` [PATCH 05/20] devtools/images: add python-pgo-image Markus Lehtonen
2017-02-20 10:35 ` [PATCH 06/20] python: make profile-optimized build possible Markus Lehtonen
2017-02-20 10:35 ` [PATCH 07/20] python-pgo-image: exclude tests from the default profile target Markus Lehtonen
2017-02-20 10:35 ` [PATCH 08/20] python: add python-tools subpackage Markus Lehtonen
2017-02-20 10:35 ` [PATCH 09/20] python-pgo-image: switch python default profile task to pybench Markus Lehtonen
2017-02-20 10:35 ` [PATCH 10/20] python-pgo-image: enable sstate for do_profile Markus Lehtonen
2017-02-20 10:35 ` [PATCH 11/20] python3-native: support profile optimized build Markus Lehtonen
2017-02-20 10:35 ` [PATCH 12/20] python3: fix depends of python-tests Markus Lehtonen
2017-02-20 10:35 ` [PATCH 13/20] python3: add python-profile-opt3 recipe Markus Lehtonen
2017-02-20 10:35 ` Markus Lehtonen [this message]
2017-02-20 10:35 ` [PATCH 15/20] python3: remove two setup.py cross-compile hacks Markus Lehtonen
2017-02-20 10:35 ` [PATCH 16/20] python3: support profile optimized build Markus Lehtonen
2017-02-20 10:35 ` [PATCH 17/20] python3: fix profile-optimized build of modules Markus Lehtonen
2017-02-20 10:35 ` [PATCH 18/20] python-pgo-image: exclude tests from the python3 profile target Markus Lehtonen
2017-02-20 10:35 ` [PATCH 19/20] python3: add python3-tools subpackage Markus Lehtonen
2017-02-20 10:35 ` [PATCH 20/20] python-pgo-image: change python3 profile target to pybench Markus Lehtonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170220103551.20022-14-markus.lehtonen@linux.intel.com \
    --to=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox