Skip to content

Commit e5fc033

Browse files
committed
gh-124613: Deactivate the JIT during perf tests
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
1 parent 7bdfabe commit e5fc033

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 12 additions & 13 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
@@ -282,11 +280,10 @@ def perf_command_works():
282280

283281

284282
def run_perf(cwd, *args, use_jit=False, **env_vars):
283+
env = os.environ.copy()
285284
if env_vars:
286-
env = os.environ.copy()
287285
env.update(env_vars)
288-
else:
289-
env = None
286+
env['PYTHON_JIT'] = "0"
290287
output_file = cwd + "/perf_output.perf"
291288
if not use_jit:
292289
base_cmd = ("perf", "record", "-g", "--call-graph=fp", "-o", output_file, "--")
@@ -455,11 +452,13 @@ def compile_trampolines_for_all_functions():
455452

456453
with temp_dir() as script_dir:
457454
script = make_script(script_dir, "perftest", code)
455+
env = {**os.getenv(), "PYTHON_JIT": "0"}
458456
with subprocess.Popen(
459457
[sys.executable, "-Xperf", script],
460458
universal_newlines=True,
461459
stderr=subprocess.PIPE,
462460
stdout=subprocess.PIPE,
461+
env=env,
463462
) as process:
464463
stdout, stderr = process.communicate()
465464

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy