From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 06/20] python: make profile-optimized build possible
Date: Mon, 20 Feb 2017 12:35:37 +0200 [thread overview]
Message-ID: <20170220103551.20022-6-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <20170220103551.20022-1-markus.lehtonen@linux.intel.com>
This patch makes it possible to build python with profile directed
optimization. That is, feed python build process with profile data to
guide optimization. This is the third (and the last) step in profile
directed optimization for Python.
In order to do a profile-optimized build you need to set
PYTHON_PROFILE_OPT = "1" in your local.conf. Be sure to get the profile
data for python, preferably by running
"bitbake python-pgo-image -c profile".
[YOCTO #9338]
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
meta/recipes-devtools/python/python_2.7.12.bb | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-devtools/python/python_2.7.12.bb b/meta/recipes-devtools/python/python_2.7.12.bb
index 31df7bb..dbd44bf 100644
--- a/meta/recipes-devtools/python/python_2.7.12.bb
+++ b/meta/recipes-devtools/python/python_2.7.12.bb
@@ -43,6 +43,17 @@ EXTRA_OECONF += "ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no"
STAGING_INCDIR_DEFAULT ?= "${STAGING_INCDIR}"
STAGING_LIBDIR_DEFAULT ?= "${STAGING_LIBDIR}"
+# Automatic profile guided optimization
+PYTHON_MAKE_TARGET ?= "${@'build_all_use_profile' if d.getVar('PYTHON_PROFILE_OPT', True) == '1' else ''}"
+PYTHON_PROFILE_DIR ?= "${@'${TMPDIR}/work-shared/${MACHINE}/python/pgo-data' if d.getVar('PYTHON_PROFILE_OPT', True) == '1' else ''}"
+python () {
+ if (d.getVar('PYTHON_PROFILE_OPT', True) == '1' and
+ d.getVar('PYTHON_MAKE_TARGET', True) == 'build_all_use_profile'):
+ profile_dir = d.getVar('PYTHON_PROFILE_DIR', True)
+ bb.utils.mkdirhier(profile_dir)
+ d.setVarFlag('do_compile', 'file-checksums', '%s:True' % profile_dir)
+}
+
do_configure_append() {
rm -f ${S}/Makefile.orig
autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
@@ -80,9 +91,15 @@ do_compile() {
export CROSS_COMPILE="${TARGET_PREFIX}"
export PYTHONBUILDDIR="${B}"
- # This is only used in PGO profiling by python-profile-opt package
if [ "${PYTHON_MAKE_TARGET}" = "build_all_generate_profile" ]; then
+ # This is only used in PGO profiling by python-profile-opt package
export EXTRA_CFLAGS="-fprofile-dir=./python-pgo-profiles/"
+ else
+ if [ -n "${PYTHON_PROFILE_DIR}" ]; then
+ export EXTRA_CFLAGS="-fprofile-dir=${PYTHON_PROFILE_DIR}"
+ # Remove non-optimized build artefacts
+ oe_runmake clean
+ fi
fi
oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
@@ -100,6 +117,11 @@ do_install() {
export CROSS_COMPILE="${TARGET_PREFIX}"
export PYTHONBUILDDIR="${B}"
+ # This only has effect if we build with -fprofile-use, e.g. when make
+ # target is build_all_use_profile
+ if [ -n "${PYTHON_PROFILE_DIR}" ]; then
+ export EXTRA_CFLAGS="-fprofile-dir=${PYTHON_PROFILE_DIR}"
+ fi
# After swizzling the makefile, we need to run the build again.
# install can race with the build so we have to run this first, then install
@@ -147,6 +169,7 @@ py_package_preprocess () {
python -m py_compile ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
}
+
require python-${PYTHON_MAJMIN}-manifest.inc
# manual dependency additions
--
2.10.2
next prev parent reply other threads:[~2017-02-20 10:35 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 ` Markus Lehtonen [this message]
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 ` [PATCH 14/20] python-pgo-image: profiling for python3 Markus Lehtonen
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-6-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