mirror of https://github.com/python/cpython
gh-124613: Deactivate perf support in tests if the jit is set (#124794)
gh-124613: Deactivate the JIT during perf tests Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
c8db0e817e
commit
5e9e50612e
|
@ -23,15 +23,6 @@ if support.check_sanitizer(address=True, memory=True, ub=True):
|
|||
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
|
||||
|
||||
|
||||
def is_jit_build():
|
||||
cflags = (sysconfig.get_config_var("PY_CORE_CFLAGS") or '')
|
||||
return "_Py_JIT" in cflags
|
||||
|
||||
|
||||
if is_jit_build():
|
||||
raise unittest.SkipTest("Perf support is not available in JIT builds")
|
||||
|
||||
|
||||
def supports_trampoline_profiling():
|
||||
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
|
||||
if not perf_trampoline:
|
||||
|
@ -71,11 +62,13 @@ class TestPerfTrampoline(unittest.TestCase):
|
|||
"""
|
||||
with temp_dir() as script_dir:
|
||||
script = make_script(script_dir, "perftest", code)
|
||||
env = {**os.environ, "PYTHON_JIT": "0"}
|
||||
with subprocess.Popen(
|
||||
[sys.executable, "-Xperf", script],
|
||||
text=True,
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env,
|
||||
) as process:
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
|
@ -139,11 +132,13 @@ class TestPerfTrampoline(unittest.TestCase):
|
|||
"""
|
||||
with temp_dir() as script_dir:
|
||||
script = make_script(script_dir, "perftest", code)
|
||||
env = {**os.environ, "PYTHON_JIT": "0"}
|
||||
with subprocess.Popen(
|
||||
[sys.executable, "-Xperf", script],
|
||||
text=True,
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env,
|
||||
) as process:
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
|
@ -188,11 +183,13 @@ class TestPerfTrampoline(unittest.TestCase):
|
|||
"""
|
||||
with temp_dir() as script_dir:
|
||||
script = make_script(script_dir, "perftest", code)
|
||||
env = {**os.environ, "PYTHON_JIT": "0"}
|
||||
with subprocess.Popen(
|
||||
[sys.executable, script],
|
||||
text=True,
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env,
|
||||
) as process:
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
|
@ -269,8 +266,9 @@ def perf_command_works():
|
|||
"-c",
|
||||
'print("hello")',
|
||||
)
|
||||
env = {**os.environ, "PYTHON_JIT": "0"}
|
||||
stdout = subprocess.check_output(
|
||||
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT
|
||||
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT, env=env
|
||||
)
|
||||
except (subprocess.SubprocessError, OSError):
|
||||
return False
|
||||
|
@ -282,11 +280,10 @@ def perf_command_works():
|
|||
|
||||
|
||||
def run_perf(cwd, *args, use_jit=False, **env_vars):
|
||||
env = os.environ.copy()
|
||||
if env_vars:
|
||||
env = os.environ.copy()
|
||||
env.update(env_vars)
|
||||
else:
|
||||
env = None
|
||||
env["PYTHON_JIT"] = "0"
|
||||
output_file = cwd + "/perf_output.perf"
|
||||
if not use_jit:
|
||||
base_cmd = ("perf", "record", "-g", "--call-graph=fp", "-o", output_file, "--")
|
||||
|
@ -455,11 +452,13 @@ class TestPerfProfiler(unittest.TestCase, TestPerfProfilerMixin):
|
|||
|
||||
with temp_dir() as script_dir:
|
||||
script = make_script(script_dir, "perftest", code)
|
||||
env = {**os.environ, "PYTHON_JIT": "0"}
|
||||
with subprocess.Popen(
|
||||
[sys.executable, "-Xperf", script],
|
||||
universal_newlines=True,
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env,
|
||||
) as process:
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
|
|
Loading…
Reference in New Issue