Skip to content
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

gh-126255: Ignore warning about JIT being deactivated when perf support is active in test_embed.InitConfigTests.test_initconfig_api #126302

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 7 additions & 1 deletion Lib/test/test_embed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Run the tests in Programs/_testembed.c (tests for the CPython embedding APIs)
from test import support
from test.libregrtest.utils import get_build_info
from test.support import import_helper, os_helper, threading_helper, MS_WINDOWS
import unittest

Expand Down Expand Up @@ -1780,8 +1781,13 @@ def test_initconfig_api(self):
'perf_profiling': 2,
}
config_dev_mode(preconfig, config)
using_jit = any(x.startswith("JIT") for x in get_build_info())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this won't work for --enable-experimental-jit=interpreter since it doesn't raise a warning about perf profiling support (because there's no conflict with tier 2 and perf profiler)

Copy link
Member

@Eclips4 Eclips4 Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and get_build_info probably does not work on Windows

if using_jit:
stderr = "<sys>:0: RuntimeWarning: JIT deactivated as perf profiling support is active"
else:
stderr = ""
self.check_all_configs("test_initconfig_api", config, preconfig,
api=API_ISOLATED)
api=API_ISOLATED, stderr=stderr)

def test_initconfig_get_api(self):
self.run_embedded_interpreter("test_initconfig_get_api")
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_perf_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ def test_sys_api_with_existing_trampoline(self):
sys.activate_stack_trampoline("perf")
sys.activate_stack_trampoline("perf")
"""
assert_python_ok("-c", code)
assert_python_ok("-c", code, PYTHON_JIT="0")

def test_sys_api_with_invalid_trampoline(self):
code = """if 1:
import sys
sys.activate_stack_trampoline("invalid")
"""
rc, out, err = assert_python_failure("-c", code)
rc, out, err = assert_python_failure("-c", code, PYTHON_JIT="0")
self.assertIn("invalid backend: invalid", err.decode())

def test_sys_api_get_status(self):
Expand All @@ -228,7 +228,7 @@ def test_sys_api_get_status(self):
sys.deactivate_stack_trampoline()
assert sys.is_stack_trampoline_active() is False
"""
assert_python_ok("-c", code)
assert_python_ok("-c", code, PYTHON_JIT="0")


def is_unwinding_reliable_with_frame_pointers():
Expand Down
1 change: 1 addition & 0 deletions Python/optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,4 +1699,5 @@ _Py_Executors_InvalidateCold(PyInterpreterState *interp)
_Py_Executors_InvalidateAll(interp, 0);
}


#endif /* _Py_TIER2 */
5 changes: 4 additions & 1 deletion Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,12 +1310,15 @@ init_interp_main(PyThreadState *tstate)
enabled = *env != '0';
}
if (enabled) {
#ifdef _Py_JIT
if (config->perf_profiling > 0) {
(void)PyErr_WarnEx(
PyExc_RuntimeWarning,
"JIT deactivated as perf profiling support is active",
0);
} else {
} else
#endif
{
PyObject *opt = _PyOptimizer_NewUOpOptimizer();
if (opt == NULL) {
return _PyStatus_ERR("can't initialize optimizer");
Expand Down
1 change: 1 addition & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,7 @@ sys_activate_stack_trampoline_impl(PyObject *module, const char *backend)
#ifdef _Py_JIT
_PyOptimizerObject* optimizer = _Py_GetOptimizer();
if (optimizer != NULL) {
Py_DECREF(optimizer);
PyErr_SetString(PyExc_ValueError, "Cannot activate the perf trampoline if the JIT is active");
return NULL;
}
Expand Down
Loading