23
23
raise unittest.SkipTest("test crash randomly on ASAN/MSAN/UBSAN build")
24
24
25
25
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
-
35
26
def supports_trampoline_profiling():
36
27
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
37
28
if not perf_trampoline:
@@ -71,11 +62,13 @@ def baz():
71
62
"""
72
63
with temp_dir() as script_dir:
73
64
script = make_script(script_dir, "perftest", code)
65
+ env = {**os.getenv(), "PYTHON_JIT": "0"}
74
66
with subprocess.Popen(
75
67
[sys.executable, "-Xperf", script],
76
68
text=True,
77
69
stderr=subprocess.PIPE,
78
70
stdout=subprocess.PIPE,
71
+ env=env,
79
72
) as process:
80
73
stdout, stderr = process.communicate()
81
74
@@ -139,11 +132,13 @@ def baz():
139
132
"""
140
133
with temp_dir() as script_dir:
141
134
script = make_script(script_dir, "perftest", code)
135
+ env = {**os.getenv(), "PYTHON_JIT": "0"}
142
136
with subprocess.Popen(
143
137
[sys.executable, "-Xperf", script],
144
138
text=True,
145
139
stderr=subprocess.PIPE,
146
140
stdout=subprocess.PIPE,
141
+ env=env,
147
142
) as process:
148
143
stdout, stderr = process.communicate()
149
144
@@ -188,11 +183,13 @@ def baz():
188
183
"""
189
184
with temp_dir() as script_dir:
190
185
script = make_script(script_dir, "perftest", code)
186
+ env = {**os.getenv(), "PYTHON_JIT": "0"}
191
187
with subprocess.Popen(
192
188
[sys.executable, script],
193
189
text=True,
194
190
stderr=subprocess.PIPE,
195
191
stdout=subprocess.PIPE,
192
+ env=env,
196
193
) as process:
197
194
stdout, stderr = process.communicate()
198
195
@@ -269,8 +266,9 @@ def perf_command_works():
269
266
"-c",
270
267
'print("hello")',
271
268
)
269
+ env = {**os.getenv(), "PYTHON_JIT": "0"}
272
270
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
274
272
)
275
273
except (subprocess.SubprocessError, OSError):
276
274
return False
@@ -286,7 +284,8 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
286
284
env = os.environ.copy()
287
285
env.update(env_vars)
288
286
else:
289
- env = None
287
+ env = os.environ.copy()
288
+ env['PYTHON_JIT'] = "0"
290
289
output_file = cwd + "/perf_output.perf"
291
290
if not use_jit:
292
291
base_cmd = ("perf", "record", "-g", "--call-graph=fp", "-o", output_file, "--")
@@ -455,11 +454,13 @@ def compile_trampolines_for_all_functions():
455
454
456
455
with temp_dir() as script_dir:
457
456
script = make_script(script_dir, "perftest", code)
457
+ env = {**os.getenv(), "PYTHON_JIT": "0"}
458
458
with subprocess.Popen(
459
459
[sys.executable, "-Xperf", script],
460
460
universal_newlines=True,
461
461
stderr=subprocess.PIPE,
462
462
stdout=subprocess.PIPE,
463
+ env=env,
463
464
) as process:
464
465
stdout, stderr = process.communicate()
465
466
0 commit comments