Skip to content

Commit 036c09b

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

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 16 additions & 10 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:
@@ -58,12 +49,15 @@ def tearDown(self) -> None:
5849

5950
def test_trampoline_works(self):
6051
code = """if 1:
52+
from test import support
53+
6154
def foo():
6255
pass
6356
6457
def bar():
6558
foo()
6659
60+
@support.without_optimizer
6761
def baz():
6862
bar()
6963
@@ -110,6 +104,7 @@ def baz():
110104
def test_trampoline_works_with_forks(self):
111105
code = """if 1:
112106
import os, sys
107+
from test import support
113108
114109
def foo_fork():
115110
pass
@@ -132,6 +127,7 @@ def foo():
132127
def bar():
133128
foo()
134129
130+
@support.without_optimizer
135131
def baz():
136132
bar()
137133
@@ -168,6 +164,8 @@ def baz():
168164
def test_sys_api(self):
169165
code = """if 1:
170166
import sys
167+
from test import support
168+
171169
def foo():
172170
pass
173171
@@ -180,6 +178,7 @@ def bar():
180178
sys.activate_stack_trampoline("perf")
181179
spam()
182180
181+
@support.without_optimizer
183182
def baz():
184183
bar()
185184
@@ -344,6 +343,8 @@ def run_perf(self, script_dir, perf_mode, script):
344343
def test_python_calls_appear_in_the_stack_if_perf_activated(self):
345344
with temp_dir() as script_dir:
346345
code = """if 1:
346+
from test import support
347+
347348
def foo(n):
348349
x = 0
349350
for i in range(n):
@@ -352,6 +353,7 @@ def foo(n):
352353
def bar(n):
353354
foo(n)
354355
356+
@support.without_optimizer
355357
def baz(n):
356358
bar(n)
357359
@@ -368,6 +370,8 @@ def baz(n):
368370
def test_python_calls_do_not_appear_in_the_stack_if_perf_deactivated(self):
369371
with temp_dir() as script_dir:
370372
code = """if 1:
373+
from test import support
374+
371375
def foo(n):
372376
x = 0
373377
for i in range(n):
@@ -376,6 +380,7 @@ def foo(n):
376380
def bar(n):
377381
foo(n)
378382
383+
@support.without_optimizer
379384
def baz(n):
380385
bar(n)
381386
@@ -428,12 +433,14 @@ def test_pre_fork_compile(self):
428433
def foo_fork():
429434
pass
430435
436+
@support.without_optimizer
431437
def bar_fork():
432438
foo_fork()
433439
434440
def foo():
435441
import time; time.sleep(1)
436442
443+
@support.without_optimizer
437444
def bar():
438445
foo()
439446
@@ -442,7 +449,6 @@ def compile_trampolines_for_all_functions():
442449
for _, obj in globals().items():
443450
if callable(obj) and hasattr(obj, '__code__'):
444451
compile_perf_trampoline_entry(obj.__code__)
445-
446452
if __name__ == "__main__":
447453
compile_trampolines_for_all_functions()
448454
pid = os.fork()

0 commit comments

Comments
 (0)