Skip to content

Commit 382cb85

Browse files
bpo-37707: Exclude expensive unit tests from PGO task (GH-15009) (#15024)
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. (cherry picked from commit 52a48e6) Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
1 parent 9265a87 commit 382cb85

File tree

8 files changed

+24
-0
lines changed

8 files changed

+24
-0
lines changed

Lib/test/libregrtest/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def _main(self, tests, kwargs):
643643
input("Press any key to continue...")
644644

645645
support.PGO = self.ns.pgo
646+
support.PGO_EXTENDED = self.ns.pgo_extended
646647

647648
setup_tests(self.ns)
648649

Lib/test/pickletester.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,7 @@ def test_setitems_on_non_dicts(self):
22812281
FRAME_SIZE_MIN = 4
22822282
FRAME_SIZE_TARGET = 64 * 1024
22832283

2284+
@support.skip_if_pgo_task
22842285
def check_frame_opcodes(self, pickled):
22852286
"""
22862287
Check the arguments of FRAME opcodes in a protocol 4+ pickle.
@@ -2328,6 +2329,7 @@ def check_frame_opcodes(self, pickled):
23282329
elif frameless_start is not None:
23292330
self.assertLess(pos - frameless_start, self.FRAME_SIZE_MIN)
23302331

2332+
@support.skip_if_pgo_task
23312333
def test_framing_many_objects(self):
23322334
obj = list(range(10**5))
23332335
for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
@@ -2417,6 +2419,7 @@ def remove_frames(pickled, keep_frame=None):
24172419
count_opcode(pickle.FRAME, pickled))
24182420
self.assertEqual(obj, self.loads(some_frames_pickle))
24192421

2422+
@support.skip_if_pgo_task
24202423
def test_framed_write_sizes_with_delayed_writer(self):
24212424
class ChunkAccumulator:
24222425
"""Accumulate pickler output in a list of raw chunks."""

Lib/test/support/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,10 @@ def dec(*args, **kwargs):
971971
# useful for PGO
972972
PGO = False
973973

974+
# Set by libregrtest/main.py if we are running the extended (time consuming)
975+
# PGO task. If this is True, PGO is also True.
976+
PGO_EXTENDED = False
977+
974978
@contextlib.contextmanager
975979
def temp_dir(path=None, quiet=False):
976980
"""Return a context manager that creates a temporary directory.
@@ -2636,6 +2640,12 @@ def skip_unless_xattr(test):
26362640
msg = "no non-broken extended attribute support"
26372641
return test if ok else unittest.skip(msg)(test)
26382642

2643+
def skip_if_pgo_task(test):
2644+
"""Skip decorator for tests not run in (non-extended) PGO task"""
2645+
ok = not PGO or PGO_EXTENDED
2646+
msg = "Not run for (non-extended) PGO task"
2647+
return test if ok else unittest.skip(msg)(test)
2648+
26392649
_bind_nix_socket_error = None
26402650
def skip_unless_bind_unix_socket(test):
26412651
"""Decorator for tests requiring a functional bind() for unix sockets."""

Lib/test/test_bz2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def testCompressChunks10(self):
643643
data += bz2c.flush()
644644
self.assertEqual(ext_decompress(data), self.TEXT)
645645

646+
@support.skip_if_pgo_task
646647
@bigmemtest(size=_4G + 100, memuse=2)
647648
def testCompress4G(self, size):
648649
# "Test BZ2Compressor.compress()/flush() with >4GiB input"
@@ -701,6 +702,7 @@ def testEOFError(self):
701702
self.assertRaises(EOFError, bz2d.decompress, b"anything")
702703
self.assertRaises(EOFError, bz2d.decompress, b"")
703704

705+
@support.skip_if_pgo_task
704706
@bigmemtest(size=_4G + 100, memuse=3.3)
705707
def testDecompress4G(self, size):
706708
# "Test BZ2Decompressor.decompress() with >4GiB input"

Lib/test/test_itertools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,7 @@ def gen2(x):
20622062
self.assertRaises(AssertionError, list, cycle(gen1()))
20632063
self.assertEqual(hist, [0,1])
20642064

2065+
@support.skip_if_pgo_task
20652066
def test_long_chain_of_empty_iterables(self):
20662067
# Make sure itertools.chain doesn't run into recursion limits when
20672068
# dealing with long chains of empty iterables. Even with a high

Lib/test/test_lzma.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def test_decompressor_multistream(self):
333333

334334
# Test with inputs larger than 4GiB.
335335

336+
@support.skip_if_pgo_task
336337
@bigmemtest(size=_4G + 100, memuse=2)
337338
def test_compressor_bigmem(self, size):
338339
lzc = LZMACompressor()
@@ -344,6 +345,7 @@ def test_compressor_bigmem(self, size):
344345
finally:
345346
ddata = None
346347

348+
@support.skip_if_pgo_task
347349
@bigmemtest(size=_4G + 100, memuse=3)
348350
def test_decompressor_bigmem(self, size):
349351
lzd = LZMADecompressor()

Lib/test/test_statistics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import random
1515
import sys
1616
import unittest
17+
from test import support
1718

1819
from decimal import Decimal
1920
from fractions import Fraction
@@ -2462,6 +2463,7 @@ def test_cdf(self):
24622463
self.assertEqual(X.cdf(float('Inf')), 1.0)
24632464
self.assertTrue(math.isnan(X.cdf(float('NaN'))))
24642465

2466+
@support.skip_if_pgo_task
24652467
def test_inv_cdf(self):
24662468
NormalDist = statistics.NormalDist
24672469

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Mark some individual tests to skip when --pgo is used. The tests marked
2+
increase the PGO task time significantly and likely don't help improve
3+
optimization of the final executable.

0 commit comments

Comments
 (0)