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
@@ -282,11 +280,10 @@ def perf_command_works():
282
280
283
281
284
282
def run_perf (cwd , * args , use_jit = False , ** env_vars ):
283
+ env = os .environ .copy ()
285
284
if env_vars :
286
- env = os .environ .copy ()
287
285
env .update (env_vars )
288
- else :
289
- env = None
286
+ env ['PYTHON_JIT' ] = "0"
290
287
output_file = cwd + "/perf_output.perf"
291
288
if not use_jit :
292
289
base_cmd = ("perf" , "record" , "-g" , "--call-graph=fp" , "-o" , output_file , "--" )
@@ -455,11 +452,13 @@ def compile_trampolines_for_all_functions():
455
452
456
453
with temp_dir () as script_dir :
457
454
script = make_script (script_dir , "perftest" , code )
455
+ env = {** os .getenv (), "PYTHON_JIT" : "0" }
458
456
with subprocess .Popen (
459
457
[sys .executable , "-Xperf" , script ],
460
458
universal_newlines = True ,
461
459
stderr = subprocess .PIPE ,
462
460
stdout = subprocess .PIPE ,
461
+ env = env ,
463
462
) as process :
464
463
stdout , stderr = process .communicate ()
465
464
0 commit comments