Skip to content

Commit

Permalink
Remove most of interpreter type profiling
Browse files Browse the repository at this point in the history
Summary:
We're not currently using it and it's unclear when we'd be able to invest more
into it.  If we want to come back to feeding better types into the JIT it would
make sense to try to tap into the machinery used by the specializing adaptive
interpreter.

This deletes pretty much everything except ProfileRuntime, which is still used
by the simplifier for LoadAttr on split dicts.  Will get that in a future diff.

Reviewed By: jbower-fb

Differential Revision: D59603172

fbshipit-source-id: 1cd4ca33d4e29faa77e7597e30cd943c65c141a2
  • Loading branch information
Alex Malyshev authored and facebook-github-bot committed Jul 15, 2024
1 parent 28614d8 commit 0c8b47a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 55 deletions.
6 changes: 0 additions & 6 deletions Lib/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@
clear_all_shadow_caches,
clear_caches,
clear_classloader_caches,
clear_type_profiles,
disable_parallel_gc,
enable_parallel_gc,
get_and_clear_type_profiles_with_metadata,
get_and_clear_type_profiles,
get_parallel_gc_settings,
set_profile_interp_all,
set_profile_interp_period,
set_profile_interp,
strict_module_patch_delete,
strict_module_patch_enabled,
strict_module_patch,
Expand Down
49 changes: 0 additions & 49 deletions Lib/test/test_cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,55 +1979,6 @@ def a1():
)


@cinder_support.skipUnderJIT("Profiling only works under interpreter")
class TestInterpProfiling(unittest.TestCase):
def tearDown(self):
cinder.set_profile_interp(False)

def test_profiles_instrs(self):
def workload(a, b, c):
r = 0.0
for i in range(c):
r += a * b

cinder.set_profile_interp_period(1)
was_enabled_before = cinder.set_profile_interp(True)
repetitions = 101
result = workload(1, 2, repetitions)
was_enabled_after = cinder.set_profile_interp(False)
profiles = cinder.get_and_clear_type_profiles()

self.assertFalse(was_enabled_before)
self.assertTrue(was_enabled_after)

profile_by_op = {}
for item in profiles:
if (
item["normal"]["func_qualname"].endswith("<locals>.workload")
and "opname" in item["normal"]
):
opname = item["normal"]["opname"]
self.assertNotIn(opname, profile_by_op)
profile_by_op[opname] = item

# We don't want to overfit to the current shape of the bytecode, so do
# a quick sanity check of a few key instructions.
self.assertIn("FOR_ITER", profile_by_op)
item = profile_by_op["FOR_ITER"]
self.assertEqual(item["int"]["count"], repetitions + 1)
self.assertEqual(item["normvector"]["types"], ["range_iterator"])

self.assertIn("BINARY_MULTIPLY", profile_by_op)
item = profile_by_op["BINARY_MULTIPLY"]
self.assertEqual(item["int"]["count"], repetitions)
self.assertEqual(item["normvector"]["types"], ["int", "int"])

self.assertIn("INPLACE_ADD", profile_by_op)
item = profile_by_op["INPLACE_ADD"]
self.assertEqual(item["int"]["count"], repetitions)
self.assertEqual(item["normvector"]["types"], ["float", "int"])


class TestWaitForAwaiter(unittest.TestCase):
def setUp(self) -> None:
loop = asyncio.new_event_loop()
Expand Down

0 comments on commit 0c8b47a

Please sign in to comment.