Skip to content

[3.12] gh-103053: Skip test_freeze_simple_script() on PGO build (#109591) #109614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Lib/test/libregrtest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,8 @@ def get_build_info():
elif '-flto' in ldflags_nodist:
optimizations.append('LTO')

# --enable-optimizations
pgo_options = (
# GCC
'-fprofile-use',
# clang: -fprofile-instr-use=code.profclangd
'-fprofile-instr-use',
# ICC
"-prof-use",
)
if any(option in cflags_nodist for option in pgo_options):
if support.check_cflags_pgo():
# PGO (--enable-optimizations)
optimizations.append('PGO')
if optimizations:
build.append('+'.join(optimizations))
Expand Down
10 changes: 10 additions & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,15 @@ def collect_fips(info_add):
pass


def collect_libregrtest_utils(info_add):
try:
from test.libregrtest import utils
except ImportError:
return

info_add('libregrtests.build_info', ' '.join(utils.get_build_info()))


def collect_info(info):
error = False
info_add = info.add
Expand Down Expand Up @@ -904,6 +913,7 @@ def collect_info(info):
collect_tkinter,
collect_windows,
collect_zlib,
collect_libregrtest_utils,

# Collecting from tests should be last as they have side effects.
collect_test_socket,
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,21 @@ def python_is_optimized():
return final_opt not in ('', '-O0', '-Og')


def check_cflags_pgo():
# Check if Python was built with ./configure --enable-optimizations:
# with Profile Guided Optimization (PGO).
cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or ''
pgo_options = (
# GCC
'-fprofile-use',
# clang: -fprofile-instr-use=code.profclangd
'-fprofile-instr-use',
# ICC
"-prof-use",
)
return any(option in cflags_nodist for option in pgo_options)


_header = 'nP'
_align = '0n'
if hasattr(sys, "getobjects"):
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_tools/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
@support.requires_zlib()
@unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows')
@support.skip_if_buildbot('not all buildbots have enough space')
# gh-103053: Skip test if Python is built with Profile Guided Optimization
# (PGO), since the test is just too slow in this case.
@unittest.skipIf(support.check_cflags_pgo(),
'test is too slow with PGO')
class TestFreeze(unittest.TestCase):

@support.requires_resource('cpu') # Building Python is slow
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Skip test_freeze_simple_script() of test_tools.test_freeze if Python is built
with ``./configure --enable-optimizations``, which means with Profile Guided
Optimization (PGO): it just makes the test too slow. The freeze tool is tested
by many other CIs with other (faster) compiler flags. Patch by Victor Stinner.