From 9d905a5962a5a1bd3a3966988a1d43e6aec1126c Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Mon, 29 Jul 2019 11:26:49 -0700 Subject: [PATCH 1/3] Add @skip_if_pgo_task decorator, use it. Mark some individual tests to skip when --pgo is used. The tests marked increase the PGO task time significantly and likely don't help improve optimization of the final executable. --- Lib/test/pickletester.py | 3 +++ Lib/test/support/__init__.py | 6 ++++++ Lib/test/test_bz2.py | 2 ++ Lib/test/test_itertools.py | 1 + Lib/test/test_lzma.py | 2 ++ Lib/test/test_statistics.py | 2 ++ 6 files changed, 16 insertions(+) diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 2bc99e6becfd0d..5d402a4711bff6 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -2281,6 +2281,7 @@ def test_setitems_on_non_dicts(self): FRAME_SIZE_MIN = 4 FRAME_SIZE_TARGET = 64 * 1024 + @support.skip_if_pgo_task def check_frame_opcodes(self, pickled): """ Check the arguments of FRAME opcodes in a protocol 4+ pickle. @@ -2328,6 +2329,7 @@ def check_frame_opcodes(self, pickled): elif frameless_start is not None: self.assertLess(pos - frameless_start, self.FRAME_SIZE_MIN) + @support.skip_if_pgo_task def test_framing_many_objects(self): obj = list(range(10**5)) for proto in range(4, pickle.HIGHEST_PROTOCOL + 1): @@ -2417,6 +2419,7 @@ def remove_frames(pickled, keep_frame=None): count_opcode(pickle.FRAME, pickled)) self.assertEqual(obj, self.loads(some_frames_pickle)) + @support.skip_if_pgo_task def test_framed_write_sizes_with_delayed_writer(self): class ChunkAccumulator: """Accumulate pickler output in a list of raw chunks.""" diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 9efb3d91705ff0..cca5c7f656991f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2638,6 +2638,12 @@ def skip_unless_xattr(test): msg = "no non-broken extended attribute support" return test if ok else unittest.skip(msg)(test) +def skip_if_pgo_task(test): + """Skip decorator for tests that should not run in PGO task""" + ok = not PGO + msg = "Not run for PGO task" + return test if ok else unittest.skip(msg)(test) + _bind_nix_socket_error = None def skip_unless_bind_unix_socket(test): """Decorator for tests requiring a functional bind() for unix sockets.""" diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py index f158b901b9c90a..eb2f72ee4a5d3b 100644 --- a/Lib/test/test_bz2.py +++ b/Lib/test/test_bz2.py @@ -643,6 +643,7 @@ def testCompressChunks10(self): data += bz2c.flush() self.assertEqual(ext_decompress(data), self.TEXT) + @support.skip_if_pgo_task @bigmemtest(size=_4G + 100, memuse=2) def testCompress4G(self, size): # "Test BZ2Compressor.compress()/flush() with >4GiB input" @@ -701,6 +702,7 @@ def testEOFError(self): self.assertRaises(EOFError, bz2d.decompress, b"anything") self.assertRaises(EOFError, bz2d.decompress, b"") + @support.skip_if_pgo_task @bigmemtest(size=_4G + 100, memuse=3.3) def testDecompress4G(self, size): # "Test BZ2Decompressor.decompress() with >4GiB input" diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index ea060a98a5eef4..573739fde14c93 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -2062,6 +2062,7 @@ def gen2(x): self.assertRaises(AssertionError, list, cycle(gen1())) self.assertEqual(hist, [0,1]) + @support.skip_if_pgo_task def test_long_chain_of_empty_iterables(self): # Make sure itertools.chain doesn't run into recursion limits when # dealing with long chains of empty iterables. Even with a high diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py index 3dc2c1e7e3b779..117de0a1b5548b 100644 --- a/Lib/test/test_lzma.py +++ b/Lib/test/test_lzma.py @@ -333,6 +333,7 @@ def test_decompressor_multistream(self): # Test with inputs larger than 4GiB. + @support.skip_if_pgo_task @bigmemtest(size=_4G + 100, memuse=2) def test_compressor_bigmem(self, size): lzc = LZMACompressor() @@ -344,6 +345,7 @@ def test_compressor_bigmem(self, size): finally: ddata = None + @support.skip_if_pgo_task @bigmemtest(size=_4G + 100, memuse=3) def test_decompressor_bigmem(self, size): lzd = LZMADecompressor() diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index ed2f6579b0b9a9..104718ed7db6c3 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -14,6 +14,7 @@ import random import sys import unittest +from test import support from decimal import Decimal from fractions import Fraction @@ -2462,6 +2463,7 @@ def test_cdf(self): self.assertEqual(X.cdf(float('Inf')), 1.0) self.assertTrue(math.isnan(X.cdf(float('NaN')))) + @support.skip_if_pgo_task def test_inv_cdf(self): NormalDist = statistics.NormalDist From b2881ccfcbb38f007736fc85748a0c3cca5c9d1e Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Mon, 29 Jul 2019 11:36:20 -0700 Subject: [PATCH 2/3] Add NEWS file. --- .../NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst diff --git a/Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst b/Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst new file mode 100644 index 00000000000000..c0d58ab747b2b8 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst @@ -0,0 +1,3 @@ +Mark some individual tests to skip when --pgo is used. The tests marked +increase the PGO task time significantly and likely don't help improve +optimization of the final executable. From c0b746915181a44290f10a4bb2a3bbb0a162fac0 Mon Sep 17 00:00:00 2001 From: Neil Schemenauer Date: Mon, 29 Jul 2019 13:05:40 -0700 Subject: [PATCH 3/3] Don't skip the tests if --pgo-extended enabled. --- Lib/test/libregrtest/main.py | 1 + Lib/test/support/__init__.py | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 2b6607df15dd8e..87278d0c76a2a5 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -643,6 +643,7 @@ def _main(self, tests, kwargs): input("Press any key to continue...") support.PGO = self.ns.pgo + support.PGO_EXTENDED = self.ns.pgo_extended setup_tests(self.ns) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index cca5c7f656991f..dbbbdb0ee339ff 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -973,6 +973,10 @@ def dec(*args, **kwargs): # useful for PGO PGO = False +# Set by libregrtest/main.py if we are running the extended (time consuming) +# PGO task. If this is True, PGO is also True. +PGO_EXTENDED = False + @contextlib.contextmanager def temp_dir(path=None, quiet=False): """Return a context manager that creates a temporary directory. @@ -2639,9 +2643,9 @@ def skip_unless_xattr(test): return test if ok else unittest.skip(msg)(test) def skip_if_pgo_task(test): - """Skip decorator for tests that should not run in PGO task""" - ok = not PGO - msg = "Not run for PGO task" + """Skip decorator for tests not run in (non-extended) PGO task""" + ok = not PGO or PGO_EXTENDED + msg = "Not run for (non-extended) PGO task" return test if ok else unittest.skip(msg)(test) _bind_nix_socket_error = None