Skip to content

Commit

Permalink
bpo-37707: Exclude expensive unit tests from PGO task (GH-15009)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nascheme authored Jul 30, 2019
1 parent 27eeaf0 commit 52a48e6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions Lib/test/pickletester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
Expand Down
10 changes: 10 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -2638,6 +2642,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 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
def skip_unless_bind_unix_socket(test):
"""Decorator for tests requiring a functional bind() for unix sockets."""
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_bz2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_lzma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import random
import sys
import unittest
from test import support

from decimal import Decimal
from fractions import Fraction
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 52a48e6

Please sign in to comment.