Skip to content

Commit 7c4b358

Browse files
alexmalyshevfacebook-github-bot
authored andcommitted
Revert D73401869
Summary: This diff reverts D73401869 Failures with 3.14 and 3.12 refleak tests. The refleak tests are taking a while to debug and they're hitting brand new issues, I need more time to address them. Depends on D73401869 Reviewed By: jbower-fb, yoney Differential Revision: D79649298 fbshipit-source-id: 26722a14cb9b44b9e6a71aa7a412ca95bad10027
1 parent ae407fe commit 7c4b358

13 files changed

Lines changed: 230 additions & 310 deletions

File tree

cinderx/Jit/pyjit.cpp

Lines changed: 141 additions & 100 deletions
Large diffs are not rendered by default.

cinderx/Jit/pyjit.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ int initialize();
3333
*/
3434
void finalize();
3535

36-
/*
37-
* Check if a function should be scheduled for compilation.
38-
*
39-
* This doesn't guarantee that the function can or will be compiled, it just
40-
* checks if the JIT has been configured in such a way that compilation is
41-
* possible.
42-
*/
43-
bool shouldScheduleCompile(BorrowedRef<PyFunctionObject> func);
44-
45-
/*
46-
* Variant of shouldScheduleCompile() for nested code objects.
47-
*/
48-
bool shouldScheduleCompile(
49-
BorrowedRef<> module_name,
50-
BorrowedRef<PyCodeObject> code);
51-
5236
/*
5337
* Overwrite the entry point of a function so that it tries to JIT-compile
5438
* itself in the future.

cinderx/PythonLib/cinderx/test_support.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ def verify_stack(
7373
)
7474

7575

76-
def compiles_after_one_call() -> bool:
77-
"""
78-
Check if CinderX will automatically compile functions after they are called once.
79-
"""
80-
return cinderx.jit.auto_jit_threshold() == 1 or cinderx.jit.is_compile_all()
81-
82-
8376
def _identity(obj: object) -> object:
8477
return obj
8578

cinderx/PythonLib/test_cinderx/test_cinderjit.py

Lines changed: 29 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
if not AT_LEAST_312:
2424
import _testcindercapi
2525

26-
import cinderx
27-
28-
cinderx.init()
2926
import cinderx.jit
3027

3128
import cinderx.test_support as cinder_support
@@ -37,11 +34,7 @@
3734
jit_suppress,
3835
jit_unsuppress,
3936
)
40-
from cinderx.test_support import (
41-
compiles_after_one_call,
42-
run_in_subprocess,
43-
skip_unless_jit,
44-
)
37+
from cinderx.test_support import run_in_subprocess, skip_unless_jit
4538

4639
from .common import failUnlessHasOpcodes, with_globals
4740

@@ -55,9 +48,6 @@
5548

5649
ENCODING: str = sys.stdout.encoding or sys.getdefaultencoding()
5750

58-
# Hack to allow subprocesses to find where cinderx is.
59-
MOD_PATH: str = os.path.dirname(os.path.dirname(cinderx.__file__))
60-
6151

6252
class TestException(Exception):
6353
pass
@@ -182,9 +172,7 @@ def test_error_preloading_inlined(self):
182172
if lazy_imports:
183173
cmd.append("-L")
184174
cmd.append(str(root / "main.py"))
185-
proc = subprocess.run(
186-
cmd, cwd=root, capture_output=True, env={"PYTHONPATH": MOD_PATH}
187-
)
175+
proc = subprocess.run(cmd, cwd=root, capture_output=True)
188176
# We expect an exception, but not a crash!
189177
self.assertEqual(proc.returncode, 1, proc.stderr)
190178
self.assertEqual(
@@ -728,11 +716,9 @@ def test_cellvar_unbound(self):
728716

729717
self.assertEqual(
730718
str(ctx.exception),
731-
(
732-
"cannot access local variable 'a' where it is not associated with a value"
733-
if AT_LEAST_312
734-
else "local variable 'a' referenced before assignment"
735-
),
719+
"cannot access local variable 'a' where it is not associated with a value"
720+
if AT_LEAST_312
721+
else "local variable 'a' referenced before assignment",
736722
)
737723

738724
def test_freevars(self):
@@ -986,7 +972,7 @@ async def main():
986972
with self.assertRaises(asyncio.CancelledError):
987973
asyncio.run(main())
988974

989-
if compiles_after_one_call():
975+
if cinderx.jit.is_enabled() and cinderx.jit.auto_jit_threshold() <= 1:
990976
self.assertTrue(is_jit_compiled(a))
991977
self.assertTrue(is_jit_compiled(b))
992978
self.assertTrue(is_jit_compiled(c.__wrapped__))
@@ -1547,7 +1533,7 @@ def testfunc():
15471533
testfunc = mod.testfunc
15481534
self.assertTrue(testfunc())
15491535

1550-
if compiles_after_one_call():
1536+
if cinderx.jit.is_enabled() and cinderx.jit.auto_jit_threshold() <= 1:
15511537
self.assertTrue(is_jit_compiled(testfunc))
15521538

15531539

@@ -1583,7 +1569,7 @@ def g():
15831569

15841570
self.assertFalse(is_jit_compiled(f))
15851571

1586-
if compiles_after_one_call():
1572+
if cinderx.jit.auto_jit_threshold() <= 1:
15871573
self.assertTrue(is_jit_compiled(g))
15881574

15891575
@unittest.skipIf(
@@ -1608,19 +1594,11 @@ def g():
16081594

16091595
self.assertFalse(is_jit_compiled(f))
16101596

1611-
if compiles_after_one_call():
1597+
if cinderx.jit.auto_jit_threshold() <= 1:
16121598
self.assertTrue(is_jit_compiled(g))
16131599

16141600
self.assertEqual(cinderx.jit.get_num_inlined_functions(g), 1)
16151601

1616-
@unittest.skipIf(
1617-
(
1618-
cinderx.jit.auto_jit_threshold() == 0
1619-
or cinderx.jit.auto_jit_threshold() > 10000
1620-
)
1621-
and not cinderx.jit.is_compile_all(),
1622-
"Expecting the JIT to be compiling a bunch of code automatically",
1623-
)
16241602
def test_max_code_size_slow(self):
16251603
code = textwrap.dedent(
16261604
"""
@@ -1649,15 +1627,11 @@ def junk{i}(j):
16491627
codepath.write_text(code)
16501628

16511629
def run_test(asserts_func, params):
1652-
args = [sys.executable, "-X", "jit-all"]
1630+
args = [sys.executable, "-X", "jit"]
16531631
args.extend(params)
16541632
args.append("mod.py")
16551633
proc = subprocess.run(
1656-
args,
1657-
cwd=tmp,
1658-
stdout=subprocess.PIPE,
1659-
encoding=ENCODING,
1660-
env={"PYTHONPATH": MOD_PATH},
1634+
args, cwd=tmp, stdout=subprocess.PIPE, encoding=ENCODING
16611635
)
16621636
self.assertEqual(proc.returncode, 0, proc)
16631637
actual_stdout = [x.strip() for x in proc.stdout.split("\n")]
@@ -1732,106 +1706,49 @@ def test_max_code_size_fast(self):
17321706

17331707
def run_proc():
17341708
proc = subprocess.run(
1735-
args,
1736-
cwd=tmp,
1737-
stdout=subprocess.PIPE,
1738-
encoding=ENCODING,
1739-
env={"PYTHONPATH": MOD_PATH},
1709+
args, cwd=tmp, stdout=subprocess.PIPE, encoding=ENCODING
17401710
)
17411711
self.assertEqual(proc.returncode, 0, proc)
17421712
actual_stdout = [x.strip() for x in proc.stdout.split("\n")]
17431713
return actual_stdout[0]
17441714

1745-
args = [sys.executable, "-X", "jit-all", "mod.py"]
1715+
args = [sys.executable, "-X", "jit", "mod.py"]
17461716
self.assertEqual(run_proc(), "max_size: 0")
17471717
args = [
17481718
sys.executable,
17491719
"-X",
1750-
"jit-all",
1720+
"jit",
17511721
"-X",
17521722
"jit-max-code-size=1234567",
17531723
"mod.py",
17541724
]
17551725
self.assertEqual(run_proc(), "max_size: 1234567")
1756-
args = [
1757-
sys.executable,
1758-
"-X",
1759-
"jit-all",
1760-
"-X",
1761-
"jit-max-code-size=1k",
1762-
"mod.py",
1763-
]
1726+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1k", "mod.py"]
17641727
self.assertEqual(run_proc(), "max_size: 1024")
1765-
args = [
1766-
sys.executable,
1767-
"-X",
1768-
"jit-all",
1769-
"-X",
1770-
"jit-max-code-size=1K",
1771-
"mod.py",
1772-
]
1728+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1K", "mod.py"]
17731729
self.assertEqual(run_proc(), "max_size: 1024")
1774-
args = [
1775-
sys.executable,
1776-
"-X",
1777-
"jit-all",
1778-
"-X",
1779-
"jit-max-code-size=1m",
1780-
"mod.py",
1781-
]
1730+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1m", "mod.py"]
17821731
self.assertEqual(run_proc(), "max_size: 1048576")
1783-
args = [
1784-
sys.executable,
1785-
"-X",
1786-
"jit-all",
1787-
"-X",
1788-
"jit-max-code-size=1M",
1789-
"mod.py",
1790-
]
1732+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1M", "mod.py"]
17911733
self.assertEqual(run_proc(), "max_size: 1048576")
1792-
args = [
1793-
sys.executable,
1794-
"-X",
1795-
"jit-all",
1796-
"-X",
1797-
"jit-max-code-size=1g",
1798-
"mod.py",
1799-
]
1734+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1g", "mod.py"]
18001735
self.assertEqual(run_proc(), "max_size: 1073741824")
1801-
args = [
1802-
sys.executable,
1803-
"-X",
1804-
"jit-all",
1805-
"-X",
1806-
"jit-max-code-size=1G",
1807-
"mod.py",
1808-
]
1736+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=1G", "mod.py"]
18091737
self.assertEqual(run_proc(), "max_size: 1073741824")
18101738

18111739
def run_proc():
18121740
proc = subprocess.run(
1813-
args,
1814-
cwd=tmp,
1815-
stderr=subprocess.PIPE,
1816-
encoding=ENCODING,
1817-
env={"PYTHONPATH": MOD_PATH},
1741+
args, cwd=tmp, stderr=subprocess.PIPE, encoding=ENCODING
18181742
)
18191743
self.assertEqual(proc.returncode, -6, proc)
18201744
return proc.stderr
18211745

1822-
args = [
1823-
sys.executable,
1824-
"-X",
1825-
"jit-all",
1826-
"-X",
1827-
"jit-max-code-size=-1",
1828-
"mod.py",
1829-
]
1746+
args = [sys.executable, "-X", "jit", "-X", "jit-max-code-size=-1", "mod.py"]
18301747
self.assertIn("Invalid unsigned integer in input string: '-1'", run_proc())
18311748
args = [
18321749
sys.executable,
18331750
"-X",
1834-
"jit-all",
1751+
"jit",
18351752
"-X",
18361753
"jit-max-code-size=1.1",
18371754
"mod.py",
@@ -1840,7 +1757,7 @@ def run_proc():
18401757
args = [
18411758
sys.executable,
18421759
"-X",
1843-
"jit-all",
1760+
"jit",
18441761
"-X",
18451762
"jit-max-code-size=dogs",
18461763
"mod.py",
@@ -1849,7 +1766,7 @@ def run_proc():
18491766
args = [
18501767
sys.executable,
18511768
"-X",
1852-
"jit-all",
1769+
"jit",
18531770
"-X",
18541771
"jit-max-code-size=1152921504606846976g",
18551772
"mod.py",
@@ -2567,10 +2484,9 @@ class PerfMapTests(unittest.TestCase):
25672484
@skip_unless_jit("Runs a subprocess with the JIT enabled")
25682485
def test_forked_pid_map(self):
25692486
proc = subprocess.run(
2570-
[sys.executable, "-X", "jit-all", "-X", "jit-perfmap", self.HELPER_FILE],
2487+
[sys.executable, "-X", "jit", "-X", "jit-perfmap", self.HELPER_FILE],
25712488
stdout=subprocess.PIPE,
25722489
encoding=ENCODING,
2573-
env={"PYTHONPATH": MOD_PATH},
25742490
)
25752491
self.assertEqual(proc.returncode, 0)
25762492

@@ -2609,12 +2525,7 @@ def test_batch_compile_nested_func(self):
26092525
"jit-batch-compile-workers=2",
26102526
str(root / "main.py"),
26112527
]
2612-
proc = subprocess.run(
2613-
cmd,
2614-
cwd=root,
2615-
capture_output=True,
2616-
env={"PYTHONPATH": MOD_PATH},
2617-
)
2528+
proc = subprocess.run(cmd, cwd=root, capture_output=True)
26182529
self.assertEqual(proc.returncode, 0, proc.stderr)
26192530
self.assertEqual(b"42\n", proc.stdout, proc.stdout)
26202531

@@ -2628,7 +2539,7 @@ def test_func_destroyed_during_preload(self):
26282539
[
26292540
sys.executable,
26302541
"-X",
2631-
"jit-all",
2542+
"jit",
26322543
"-X",
26332544
"jit-batch-compile-workers=4",
26342545
# Enable lazy imports
@@ -2640,7 +2551,6 @@ def test_func_destroyed_during_preload(self):
26402551
cwd=os.path.dirname(__file__),
26412552
stdout=subprocess.PIPE,
26422553
encoding=ENCODING,
2643-
env={"PYTHONPATH": MOD_PATH},
26442554
)
26452555
self.assertEqual(proc.returncode, 0)
26462556
expected_stdout = """resolving a_func
@@ -2693,7 +2603,6 @@ def test_preload_error(self):
26932603
cmd,
26942604
cwd=root,
26952605
capture_output=True,
2696-
env={"PYTHONPATH": MOD_PATH},
26972606
)
26982607
self.assertEqual(proc.returncode, 1, proc.stderr)
26992608
self.assertIn(b"RuntimeError: boom\n", proc.stderr)
@@ -2709,7 +2618,7 @@ def lme_test_func(self, flag=False):
27092618
def test_multiple_call_method_same_load_method(self):
27102619
self.assertEqual(self.lme_test_func(), "1")
27112620
self.assertEqual(self.lme_test_func(True), "1 flag")
2712-
if compiles_after_one_call():
2621+
if cinderx.jit.is_enabled() and cinderx.jit.auto_jit_threshold() <= 1:
27132622
self.assertTrue(is_jit_compiled(LoadMethodEliminationTests.lme_test_func))
27142623

27152624

cinderx/PythonLib/test_cinderx/test_compiler/test_static/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
TYPED_UINT64,
5252
TYPED_UINT8,
5353
)
54-
from cinderx.test_support import compiles_after_one_call
5554

5655
from ..common import CompilerTest
5756

@@ -614,7 +613,7 @@ def assert_jitted(self, func: Callable[..., object]) -> None:
614613
return
615614

616615
# Can't guarantee that functions will be called with arbitrary JitAuto settings.
617-
if not compiles_after_one_call():
616+
if cinderx.jit.auto_jit_threshold() != 0:
618617
return
619618

620619
self.assertTrue(cinderx.jit.is_jit_compiled(func), func.__name__)

0 commit comments

Comments
 (0)