From 0c8b47ad83b2f5af74abb9207cfb6ef51567b72d Mon Sep 17 00:00:00 2001 From: Alex Malyshev Date: Mon, 15 Jul 2024 12:03:01 -0700 Subject: [PATCH] Remove most of interpreter type profiling 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 --- Lib/cinder.py | 6 ----- Lib/test/test_cinder.py | 49 ----------------------------------------- 2 files changed, 55 deletions(-) diff --git a/Lib/cinder.py b/Lib/cinder.py index 466852576be..53a41d10bec 100644 --- a/Lib/cinder.py +++ b/Lib/cinder.py @@ -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, diff --git a/Lib/test/test_cinder.py b/Lib/test/test_cinder.py index 789b3cec131..fa598cf88a2 100644 --- a/Lib/test/test_cinder.py +++ b/Lib/test/test_cinder.py @@ -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(".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()