aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2019-10-17 10:34:59 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2019-10-17 13:06:39 +0200
commitaacf421dbd46bdd3dc916efc6fa5ab83bbdf8895 (patch)
treede3308053333f3fec34a78cbc55f7c8f165e209f
parentabdf2ab6d79a67fd9049354e301836e75be57fce (diff)
downloadalpine_aports-aacf421dbd46bdd3dc916efc6fa5ab83bbdf8895.tar.bz2
alpine_aports-aacf421dbd46bdd3dc916efc6fa5ab83bbdf8895.tar.xz
alpine_aports-aacf421dbd46bdd3dc916efc6fa5ab83bbdf8895.zip
main/python3: reduce number of unit tests for PGO
Backport upstream patch that reduced number tests that are run for the profile guided optimization. This reduced build time significantly and fixes builders that hangs during build. Problem was introduced with commit df3979dba3df (main/python3: enable optimizations). Upstream issue: https://bugs.python.org/issue36044
-rw-r--r--main/python3/APKBUILD6
-rw-r--r--main/python3/bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch233
2 files changed, 237 insertions, 2 deletions
diff --git a/main/python3/APKBUILD b/main/python3/APKBUILD
index 8e4dcf5755..1aadfa8a9b 100644
--- a/main/python3/APKBUILD
+++ b/main/python3/APKBUILD
@@ -5,7 +5,7 @@ pkgname=python3
5# the python2-tkinter's pkgver needs to be synchronized with this. 5# the python2-tkinter's pkgver needs to be synchronized with this.
6pkgver=3.7.5 6pkgver=3.7.5
7_basever="${pkgver%.*}" 7_basever="${pkgver%.*}"
8pkgrel=0 8pkgrel=1
9pkgdesc="A high-level scripting language" 9pkgdesc="A high-level scripting language"
10url="https://www.python.org" 10url="https://www.python.org"
11arch="all" 11arch="all"
@@ -19,6 +19,7 @@ makedepends="expat-dev openssl-dev zlib-dev ncurses-dev bzip2-dev xz-dev
19source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz 19source="https://www.python.org/ftp/python/$pkgver/Python-$pkgver.tar.xz
20 fix-xattrs-glibc.patch 20 fix-xattrs-glibc.patch
21 musl-find_library.patch 21 musl-find_library.patch
22 bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch
22 " 23 "
23builddir="$srcdir/Python-$pkgver" 24builddir="$srcdir/Python-$pkgver"
24 25
@@ -162,4 +163,5 @@ wininst() {
162 163
163sha512sums="f4f3879881f260f58dbb041fb0f2f210d4b70b02a739e41e50e6fea67d31855a7a29ce4ebef66bfde3d0edf54b946a48f78490f986da965357b835d4dbb3f414 Python-3.7.5.tar.xz 164sha512sums="f4f3879881f260f58dbb041fb0f2f210d4b70b02a739e41e50e6fea67d31855a7a29ce4ebef66bfde3d0edf54b946a48f78490f986da965357b835d4dbb3f414 Python-3.7.5.tar.xz
16437b6ee5d0d5de43799316aa111423ba5a666c17dc7f81b04c330f59c1d1565540eac4c585abe2199bbed52ebe7426001edb1c53bd0a17486a2a8e052d0f494ad fix-xattrs-glibc.patch 16537b6ee5d0d5de43799316aa111423ba5a666c17dc7f81b04c330f59c1d1565540eac4c585abe2199bbed52ebe7426001edb1c53bd0a17486a2a8e052d0f494ad fix-xattrs-glibc.patch
165ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e960c4889568d25753b9e4a1494834fea48291b33f07000ec2 musl-find_library.patch" 166ab8eaa2858d5109049b1f9f553198d40e0ef8d78211ad6455f7b491af525bffb16738fed60fc84e960c4889568d25753b9e4a1494834fea48291b33f07000ec2 musl-find_library.patch
167ad2715f2a4ddfed714f6040b79deed691f457e1e57c5d880c741ef71c5db5bad02a5faab50c32cd98e517ad1117ddf6d2fea0c3daf178d029e6a5fce2f95444a bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch"
diff --git a/main/python3/bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch b/main/python3/bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch
new file mode 100644
index 0000000000..b9b3ce35ce
--- /dev/null
+++ b/main/python3/bpo-36044-Reduce-number-of-unit-tests-run-for-PGO-build.patch
@@ -0,0 +1,233 @@
1From 2406672984e4c1b18629e615edad52928a72ffcc Mon Sep 17 00:00:00 2001
2From: "Miss Islington (bot)"
3 <31488909+miss-islington@users.noreply.github.com>
4Date: Mon, 22 Jul 2019 13:17:23 -0700
5Subject: [PATCH] bpo-36044: Reduce number of unit tests run for PGO build
6 (GH-14702)
7
8Reduce the number of unit tests run for the PGO generation task. This
9speeds up the task by a factor of about 15x. Running the full unit test
10suite is slow. This change may result in a slightly less optimized build
11since not as many code branches will be executed. If you are willing to
12wait for the much slower build, the old behavior can be restored using
13'./configure [..] PROFILE_TASK="-m test --pgo-extended"'. We make no
14guarantees as to which PGO task set produces a faster build. Users who
15care should run their own relevant benchmarks as results can depend on
16the environment, workload, and compiler tool chain.
17(cherry picked from commit 4e16a4a3112161a5c6981c0588142d4a4673a934)
18
19Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
20---
21 Lib/test/libregrtest/cmdline.py | 6 ++-
22 Lib/test/libregrtest/main.py | 4 ++
23 Lib/test/libregrtest/pgo.py | 52 +++++++++++++++++++
24 Makefile.pre.in | 7 +--
25 .../2019-07-11-01-28-24.bpo-36044.gIgfiJ.rst | 9 ++++
26 configure | 14 +++++
27 configure.ac | 8 +++
28 7 files changed, 96 insertions(+), 4 deletions(-)
29 create mode 100644 Lib/test/libregrtest/pgo.py
30 create mode 100644 Misc/NEWS.d/next/Build/2019-07-11-01-28-24.bpo-36044.gIgfiJ.rst
31
32diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
33index 9f1bf6800824a..c8fedc7ad329b 100644
34--- a/Lib/test/libregrtest/cmdline.py
35+++ b/Lib/test/libregrtest/cmdline.py
36@@ -264,7 +264,9 @@ def _create_parser():
37 help='only write the name of test cases that will be run'
38 ' , don\'t execute them')
39 group.add_argument('-P', '--pgo', dest='pgo', action='store_true',
40- help='enable Profile Guided Optimization training')
41+ help='enable Profile Guided Optimization (PGO) training')
42+ group.add_argument('--pgo-extended', action='store_true',
43+ help='enable extended PGO training (slower training)')
44 group.add_argument('--fail-env-changed', action='store_true',
45 help='if a test file alters the environment, mark '
46 'the test as failed')
47@@ -344,6 +346,8 @@ def _parse_args(args, **kwargs):
48 parser.error("-G/--failfast needs either -v or -W")
49 if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
50 parser.error("--pgo/-v don't go together!")
51+ if ns.pgo_extended:
52+ ns.pgo = True # pgo_extended implies pgo
53
54 if ns.nowindows:
55 print("Warning: the --nowindows (-n) option is deprecated. "
56diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
57index e2274254fdb89..78b6790685c9d 100644
58--- a/Lib/test/libregrtest/main.py
59+++ b/Lib/test/libregrtest/main.py
60@@ -17,6 +17,7 @@
61 INTERRUPTED, CHILD_ERROR, TEST_DID_NOT_RUN,
62 PROGRESS_MIN_TIME, format_test_result, is_failed)
63 from test.libregrtest.setup import setup_tests
64+from test.libregrtest.pgo import setup_pgo_tests
65 from test.libregrtest.utils import removepy, count, format_duration, printlist
66 from test import support
67
68@@ -214,6 +215,9 @@ def find_tests(self, tests):
69
70 removepy(self.tests)
71
72+ # add default PGO tests if no tests are specified
73+ setup_pgo_tests(self.ns)
74+
75 stdtests = STDTESTS[:]
76 nottests = NOTTESTS.copy()
77 if self.ns.exclude:
78diff --git a/Lib/test/libregrtest/pgo.py b/Lib/test/libregrtest/pgo.py
79new file mode 100644
80index 0000000000000..327f19374c3ff
81--- /dev/null
82+++ b/Lib/test/libregrtest/pgo.py
83@@ -0,0 +1,52 @@
84+# Set of tests run by default if --pgo is specified. The tests below were
85+# chosen based on the following criteria: either they exercise a commonly used
86+# C extension module or type, or they run some relatively typical Python code.
87+# Long running tests should be avoided because the PGO instrumented executable
88+# runs slowly.
89+PGO_TESTS = [
90+ 'test_array',
91+ 'test_base64',
92+ 'test_binascii',
93+ 'test_binop',
94+ 'test_bisect',
95+ 'test_bytes',
96+ 'test_cmath',
97+ 'test_codecs',
98+ 'test_collections',
99+ 'test_complex',
100+ 'test_dataclasses',
101+ 'test_datetime',
102+ 'test_decimal',
103+ 'test_difflib',
104+ 'test_embed',
105+ 'test_float',
106+ 'test_fstring',
107+ 'test_functools',
108+ 'test_generators',
109+ 'test_hashlib',
110+ 'test_heapq',
111+ 'test_int',
112+ 'test_itertools',
113+ 'test_json',
114+ 'test_long',
115+ 'test_math',
116+ 'test_memoryview',
117+ 'test_operator',
118+ 'test_ordered_dict',
119+ 'test_pickle',
120+ 'test_pprint',
121+ 'test_re',
122+ 'test_set',
123+ 'test_statistics',
124+ 'test_struct',
125+ 'test_tabnanny',
126+ 'test_time',
127+ 'test_unicode',
128+ 'test_xml_etree',
129+ 'test_xml_etree_c',
130+]
131+
132+def setup_pgo_tests(ns):
133+ if not ns.args and not ns.pgo_extended:
134+ # run default set of tests for PGO training
135+ ns.args = PGO_TESTS[:]
136diff --git a/Makefile.pre.in b/Makefile.pre.in
137index 88abb563600d8..6a9f4b52704d2 100644
138--- a/Makefile.pre.in
139+++ b/Makefile.pre.in
140@@ -255,9 +255,10 @@ TCLTK_INCLUDES= @TCLTK_INCLUDES@
141 TCLTK_LIBS= @TCLTK_LIBS@
142
143 # The task to run while instrumented when building the profile-opt target.
144-# We exclude unittests with -x that take a rediculious amount of time to
145-# run in the instrumented training build or do not provide much value.
146-PROFILE_TASK=-m test.regrtest --pgo
147+# To speed up profile generation, we don't run the full unit test suite
148+# by default. The default is "-m test --pgo". To run more tests, use
149+# PROFILE_TASK="-m test --pgo-extended"
150+PROFILE_TASK= @PROFILE_TASK@
151
152 # report files for gcov / lcov coverage report
153 COVERAGE_INFO= $(abs_builddir)/coverage.info
154diff --git a/Misc/NEWS.d/next/Build/2019-07-11-01-28-24.bpo-36044.gIgfiJ.rst b/Misc/NEWS.d/next/Build/2019-07-11-01-28-24.bpo-36044.gIgfiJ.rst
155new file mode 100644
156index 0000000000000..177c4cb6d17c7
157--- /dev/null
158+++ b/Misc/NEWS.d/next/Build/2019-07-11-01-28-24.bpo-36044.gIgfiJ.rst
159@@ -0,0 +1,9 @@
160+Reduce the number of unit tests run for the PGO generation task. This
161+speeds up the task by a factor of about 15x. Running the full unit test
162+suite is slow. This change may result in a slightly less optimized build
163+since not as many code branches will be executed. If you are willing to
164+wait for the much slower build, the old behavior can be restored using
165+'./configure [..] PROFILE_TASK="-m test --pgo-extended"'. We make no
166+guarantees as to which PGO task set produces a faster build. Users who
167+care should run their own relevant benchmarks as results can depend on
168+the environment, workload, and compiler tool chain.
169diff --git a/configure b/configure
170index 6e7f277bace9b..cb5f130d38e05 100755
171--- a/configure
172+++ b/configure
173@@ -686,6 +686,7 @@ target_vendor
174 target_cpu
175 target
176 LLVM_AR
177+PROFILE_TASK
178 DEF_MAKE_RULE
179 DEF_MAKE_ALL_RULE
180 ABIFLAGS
181@@ -856,6 +857,7 @@ LDFLAGS
182 LIBS
183 CPPFLAGS
184 CPP
185+PROFILE_TASK
186 PKG_CONFIG
187 PKG_CONFIG_PATH
188 PKG_CONFIG_LIBDIR'
189@@ -1559,6 +1561,8 @@ Some influential environment variables:
190 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
191 you have headers in a nonstandard directory <include dir>
192 CPP C preprocessor
193+ PROFILE_TASK
194+ Python args for PGO generation task
195 PKG_CONFIG path to pkg-config utility
196 PKG_CONFIG_PATH
197 directories to add to pkg-config's search path
198@@ -6426,6 +6430,16 @@ else
199 DEF_MAKE_RULE="all"
200 fi
201
202+
203+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking PROFILE_TASK" >&5
204+$as_echo_n "checking PROFILE_TASK... " >&6; }
205+if test -z "$PROFILE_TASK"
206+then
207+ PROFILE_TASK='-m test --pgo'
208+fi
209+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PROFILE_TASK" >&5
210+$as_echo "$PROFILE_TASK" >&6; }
211+
212 # Make llvm-relatec checks work on systems where llvm tools are not installed with their
213 # normal names in the default $PATH (ie: Ubuntu). They exist under the
214 # non-suffixed name in their versioned llvm directory.
215diff --git a/configure.ac b/configure.ac
216index 324ce0bd99a9c..b31ed242f1a81 100644
217--- a/configure.ac
218+++ b/configure.ac
219@@ -1293,6 +1293,14 @@ else
220 DEF_MAKE_RULE="all"
221 fi
222
223+AC_ARG_VAR(PROFILE_TASK, Python args for PGO generation task)
224+AC_MSG_CHECKING(PROFILE_TASK)
225+if test -z "$PROFILE_TASK"
226+then
227+ PROFILE_TASK='-m test --pgo'
228+fi
229+AC_MSG_RESULT($PROFILE_TASK)
230+
231 # Make llvm-relatec checks work on systems where llvm tools are not installed with their
232 # normal names in the default $PATH (ie: Ubuntu). They exist under the
233 # non-suffixed name in their versioned llvm directory.