Skip to content

Commit 9f15d25

Browse files
[3.13] gh-124613: Deactivate perf support in tests if the jit is set (GH-124794) (GH-148214)
gh-124613: Deactivate perf support in tests if the jit is set (GH-124794) gh-124613: Deactivate the JIT during perf tests (cherry picked from commit 5e9e506) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
1 parent 5af6ce3 commit 9f15d25

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ def baz():
6363
"""
6464
with temp_dir() as script_dir:
6565
script = make_script(script_dir, "perftest", code)
66+
env = {**os.environ, "PYTHON_JIT": "0"}
6667
with subprocess.Popen(
6768
[sys.executable, "-Xperf", script],
6869
text=True,
6970
stderr=subprocess.PIPE,
7071
stdout=subprocess.PIPE,
72+
env=env,
7173
) as process:
7274
stdout, stderr = process.communicate()
7375

@@ -131,11 +133,13 @@ def baz():
131133
"""
132134
with temp_dir() as script_dir:
133135
script = make_script(script_dir, "perftest", code)
136+
env = {**os.environ, "PYTHON_JIT": "0"}
134137
with subprocess.Popen(
135138
[sys.executable, "-Xperf", script],
136139
text=True,
137140
stderr=subprocess.PIPE,
138141
stdout=subprocess.PIPE,
142+
env=env,
139143
) as process:
140144
stdout, stderr = process.communicate()
141145

@@ -232,11 +236,13 @@ def baz():
232236
"""
233237
with temp_dir() as script_dir:
234238
script = make_script(script_dir, "perftest", code)
239+
env = {**os.environ, "PYTHON_JIT": "0"}
235240
with subprocess.Popen(
236241
[sys.executable, script],
237242
text=True,
238243
stderr=subprocess.PIPE,
239244
stdout=subprocess.PIPE,
245+
env=env,
240246
) as process:
241247
stdout, stderr = process.communicate()
242248

@@ -333,8 +339,9 @@ def perf_command_works():
333339
"-c",
334340
'print("hello")',
335341
)
342+
env = {**os.environ, "PYTHON_JIT": "0"}
336343
stdout = subprocess.check_output(
337-
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT
344+
cmd, cwd=script_dir, text=True, stderr=subprocess.STDOUT, env=env
338345
)
339346
except (subprocess.SubprocessError, OSError):
340347
return False
@@ -346,11 +353,10 @@ def perf_command_works():
346353

347354

348355
def run_perf(cwd, *args, use_jit=False, **env_vars):
356+
env = os.environ.copy()
349357
if env_vars:
350-
env = os.environ.copy()
351358
env.update(env_vars)
352-
else:
353-
env = None
359+
env["PYTHON_JIT"] = "0"
354360
output_file = cwd + "/perf_output.perf"
355361
if not use_jit:
356362
base_cmd = (
@@ -529,11 +535,13 @@ def compile_trampolines_for_all_functions():
529535

530536
with temp_dir() as script_dir:
531537
script = make_script(script_dir, "perftest", code)
538+
env = {**os.environ, "PYTHON_JIT": "0"}
532539
with subprocess.Popen(
533540
[sys.executable, "-Xperf", script],
534541
universal_newlines=True,
535542
stderr=subprocess.PIPE,
536543
stdout=subprocess.PIPE,
544+
env=env,
537545
) as process:
538546
stdout, stderr = process.communicate()
539547

0 commit comments

Comments
 (0)