Skip to content

Commit 9717e7a

Browse files
committed
gh-124613: Deactivate the JIT during perf tests
1 parent 7bdfabe commit 9717e7a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
2424

2525

26-
def is_jit_build():
27-
cflags = (sysconfig.get_config_var("PY_CORE_CFLAGS") or '')
28-
return "_Py_JIT" in cflags
29-
30-
31-
if is_jit_build():
32-
raise unittest.SkipTest("Perf support is not available in JIT builds")
33-
34-
3526
def supports_trampoline_profiling():
3627
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
3728
if not perf_trampoline:
@@ -71,11 +62,13 @@ def baz():
7162
"""
7263
with temp_dir() as script_dir:
7364
script = make_script(script_dir, "perftest", code)
65+
env = {**.os.getenv(), "PYTHON_JIT": "0"}
7466
with subprocess.Popen(
7567
[sys.executable, "-Xperf", script],
7668
text=True,
7769
stderr=subprocess.PIPE,
7870
stdout=subprocess.PIPE,
71+
env=env,
7972
) as process:
8073
stdout, stderr = process.communicate()
8174

@@ -139,11 +132,13 @@ def baz():
139132
"""
140133
with temp_dir() as script_dir:
141134
script = make_script(script_dir, "perftest", code)
135+
env = {**.os.getenv(), "PYTHON_JIT": "0"}
142136
with subprocess.Popen(
143137
[sys.executable, "-Xperf", script],
144138
text=True,
145139
stderr=subprocess.PIPE,
146140
stdout=subprocess.PIPE,
141+
env=env,
147142
) as process:
148143
stdout, stderr = process.communicate()
149144

@@ -188,11 +183,13 @@ def baz():
188183
"""
189184
with temp_dir() as script_dir:
190185
script = make_script(script_dir, "perftest", code)
186+
env = {**.os.getenv(), "PYTHON_JIT": "0"}
191187
with subprocess.Popen(
192188
[sys.executable, script],
193189
text=True,
194190
stderr=subprocess.PIPE,
195191
stdout=subprocess.PIPE,
192+
env=env,
196193
) as process:
197194
stdout, stderr = process.communicate()
198195

@@ -269,8 +266,9 @@ def perf_command_works():
269266
"-c",
270267
'print("hello")',
271268
)
269+
env = {**.os.getenv(), "PYTHON_JIT": "0"}
272270
stdout = subprocess.check_output(
273-
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT
271+
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT, env=env
274272
)
275273
except (subprocess.SubprocessError, OSError):
276274
return False
@@ -286,7 +284,8 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
286284
env = os.environ.copy()
287285
env.update(env_vars)
288286
else:
289-
env = None
287+
env = os.environ.copy()
288+
env['PYTHON_JIT'] = "0"
290289
output_file = cwd + "/perf_output.perf"
291290
if not use_jit:
292291
base_cmd = ("perf", "record", "-g", "--call-graph=fp", "-o", output_file, "--")
@@ -455,11 +454,13 @@ def compile_trampolines_for_all_functions():
455454

456455
with temp_dir() as script_dir:
457456
script = make_script(script_dir, "perftest", code)
457+
env = {**.os.getenv(), "PYTHON_JIT": "0"}
458458
with subprocess.Popen(
459459
[sys.executable, "-Xperf", script],
460460
universal_newlines=True,
461461
stderr=subprocess.PIPE,
462462
stdout=subprocess.PIPE,
463+
env=env,
463464
) as process:
464465
stdout, stderr = process.communicate()
465466

0 commit comments

Comments
 (0)