@@ -52,7 +52,7 @@ PIP_WHEEL="${ROOT}/pip-${PIP_VERSION}-py3-none-any.whl"
5252SETUPTOOLS_WHEEL=" ${ROOT} /setuptools-${SETUPTOOLS_VERSION} -py3-none-any.whl"
5353
5454# Put critical config files in logs to aid debugging.
55- for f in Setup.local Makefile.extra stdlib-test-annotations.json; do
55+ for f in Setup.local Makefile.extra stdlib-test-annotations.json profiling-training-ignores.txt ; do
5656 echo " BEGIN $f "
5757 cat $f
5858 echo " END $f "
@@ -593,7 +593,27 @@ if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
593593fi
594594
595595# Define the base PGO profiling task, which we'll extend below with ignores
596- export PROFILE_TASK=' -m test --pgo'
596+ #
597+ # --pgo-extended implies --pgo. And --pgo mode significantly changes the behavior
598+ # of the test harness. Notably, it disables richer reporting of test failures,
599+ # making it vastly more difficult to debug test failures. This behavior undermines
600+ # our ability to debug failures when running tests for PGO instrumentation.
601+ #
602+ # The only material downside to not using --pgo is some tests that self-skip
603+ # when run under PGO don't do so. When we audited for such tests in 2026-03,
604+ # all such tests had the reason "PGO isn't useful" or some such. There were
605+ # ~10 such tests. Since we run the entire test suite anyway, the inclusion of
606+ # such "worthless" tests isn't impactful. The test failure observability is
607+ # worth their loss.
608+ export PROFILE_TASK=' -m test'
609+
610+ # Display test output on failure. This helps immensely with debugging PGO
611+ # failures.
612+ PROFILE_TASK=" ${PROFILE_TASK} -W"
613+
614+ # Force kill tests taking too long. This prevents deadlocks that can cause
615+ # CI jobs to run for potentially hours while doing nothing.
616+ PROFILE_TASK=" ${PROFILE_TASK} --timeout 300"
597617
598618# Run tests in parallel to reduce wall time.
599619#
@@ -608,29 +628,26 @@ export PROFILE_TASK='-m test --pgo'
608628# and there will be no loss in profile quality.
609629PROFILE_TASK=" ${PROFILE_TASK} -j ${NUM_CPUS} "
610630
611- # On 3.14+ `test_strftime_y2k` fails when cross-compiling for `x86_64_v2` and `x86_64_v3` targets on
612- # Linux, so we ignore it. See https://github.com/python/cpython/issues/128104
613- if [[ -n " ${PYTHON_MEETS_MINIMUM_VERSION_3_14} " && -n " ${CROSS_COMPILING} " && " ${PYBUILD_PLATFORM} " != macos* ]]; then
614- PROFILE_TASK=" ${PROFILE_TASK} --ignore test_strftime_y2k"
631+ IGNORE_TESTS=()
632+
633+ # Possible race condition.
634+ IGNORE_TESTS+=(" test.test_audit.AuditTest.test_time_fail" )
635+
636+ if [[ -n " ${CPYTHON_FREETHREADED} " ]]; then
637+ IGNORE_TESTS+=(" test.test_bytes.FreeThreadingTest.test_free_threading_bytearrayiter" )
615638fi
616639
617640# On 3.14+ `test_json.test_recursion.TestCRecursion.test_highly_nested_objects_decoding` fails during
618641# PGO due to RecursionError not being raised as expected. See https://github.com/python/cpython/issues/140125
619642if [[ -n " ${PYTHON_MEETS_MINIMUM_VERSION_3_14} " ]]; then
620- PROFILE_TASK= " ${PROFILE_TASK} --ignore test_json"
643+ IGNORE_TESTS+=( " test. test_json.test_recursion.TestCRecursion.test_highly_nested_objects_decoding " )
621644fi
622645
623- # PGO optimized / BOLT instrumented binaries segfault in a test_bytes test. Skip it.
624- if [[ -n " ${PYTHON_MEETS_MINIMUM_VERSION_3_13} " && " ${TARGET_TRIPLE} " == x86_64* ]]; then
625- PROFILE_TASK=" ${PROFILE_TASK} --ignore test.test_bytes.BytesTest.test_from_format"
626- fi
646+ PROFILE_TASK=" ${PROFILE_TASK} --ignorefile ${ROOT} /profiling-training-ignores.txt"
627647
628- # Some tests aren't race friendly on freethreaded builds. Disable as a mitigation.
629- if [[ -n " ${CPYTHON_FREETHREADED} " ]]; then
630- PROFILE_TASK=" ${PROFILE_TASK} --ignore test.test_bytes.FreeThreadingTest.test_free_threading_bytearrayiter"
631- PROFILE_TASK=" ${PROFILE_TASK} --ignore test.test_hashlib.HashlibTestCase.test_threaded_hashing_fast"
632- PROFILE_TASK=" ${PROFILE_TASK} --ignore test.test_itertools.TestBasicOps.test_count_threading"
633- PROFILE_TASK=" ${PROFILE_TASK} --ignore test.test_itertools.TestBasicOps.test_count_with_step_threading"
648+ # Exclude whole modules from profiling based on stdlib test annotations.
649+ if [ -n " ${PROFILING_EXCLUDE_MODULES} " ]; then
650+ PROFILE_TASK=" ${PROFILE_TASK} --exclude ${PROFILING_EXCLUDE_MODULES} "
634651fi
635652
636653# ./configure tries to auto-detect whether it can build 128-bit and 256-bit SIMD helpers for HACL,
0 commit comments