mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-122320: Limit dict key versions used by test_opcache. (gh-132961)
The `test_load_global_module()` test consumes a lot of dict key versions. Skip the test if we have consumed half of the available versions that can be used for the "load global" cache.
This commit is contained in:
parent
336322b341
commit
22f0730d40
3 changed files with 43 additions and 1 deletions
|
@ -16,6 +16,16 @@ if check_impl_detail(cpython=False):
|
|||
_testinternalcapi = import_module("_testinternalcapi")
|
||||
|
||||
|
||||
def have_dict_key_versions():
|
||||
# max version value that can be stored in the load global cache. This is
|
||||
# determined by the type of module_keys_version and builtin_keys_version
|
||||
# in _PyLoadGlobalCache, uint16_t.
|
||||
max_version = 1<<16
|
||||
# use a wide safety margin (use only half of what's available)
|
||||
limit = max_version // 2
|
||||
return _testinternalcapi.get_next_dict_keys_version() < limit
|
||||
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
def assert_specialized(self, f, opname):
|
||||
instructions = dis.get_instructions(f, adaptive=True)
|
||||
|
@ -1029,6 +1039,8 @@ class TestRacesDoNotCrash(TestBase):
|
|||
|
||||
@requires_specialization_ft
|
||||
def test_load_global_module(self):
|
||||
if not have_dict_key_versions():
|
||||
raise unittest.SkipTest("Low on dict key versions")
|
||||
def get_items():
|
||||
items = []
|
||||
for _ in range(self.ITEMS):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue