[Cache] Forward fast prefix matching capability (#37844)
This commit is contained in:
@@ -369,6 +369,10 @@ class UnifiedTreeCoreInterface(ABC):
|
|||||||
"""Match a key against the tree; returns device indices + boundary NodeIds."""
|
"""Match a key against the tree; returns device indices + boundary NodeIds."""
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def supports_fast_match_prefix(self) -> bool:
|
||||||
|
"""Whether matching every waiting request is cheap enough for scheduling."""
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def empty_match_result(self) -> MatchResult:
|
def empty_match_result(self) -> MatchResult:
|
||||||
|
|||||||
@@ -538,6 +538,9 @@ class UnifiedRadixCache(BasePrefixCache):
|
|||||||
result = self.linker.match(params.key, params.req, result)
|
result = self.linker.match(params.key, params.req, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def supports_fast_match_prefix(self) -> bool:
|
||||||
|
return self.tree_core.supports_fast_match_prefix()
|
||||||
|
|
||||||
def is_chunk_cache(self) -> bool:
|
def is_chunk_cache(self) -> bool:
|
||||||
return self.disable
|
return self.disable
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,14 @@ class TestSchedulePolicyWaitingQueueMatching(unittest.TestCase):
|
|||||||
policy.tree_cache = SimpleNamespace(supports_fast_match_prefix=lambda: True)
|
policy.tree_cache = SimpleNamespace(supports_fast_match_prefix=lambda: True)
|
||||||
self.assertTrue(policy.waiting_queue_prefix_matched([]))
|
self.assertTrue(policy.waiting_queue_prefix_matched([]))
|
||||||
|
|
||||||
def test_lpm_queue_limit_can_disable_matching(self):
|
def test_lpm_queue_limit_respects_fast_matching_capability(self):
|
||||||
policy = self.make_policy(CacheAwarePolicy.LPM, False)
|
policy = self.make_policy(CacheAwarePolicy.LPM, False)
|
||||||
self.assertTrue(policy.waiting_queue_prefix_matched([None] * 128))
|
self.assertTrue(policy.waiting_queue_prefix_matched([None] * 128))
|
||||||
self.assertFalse(policy.waiting_queue_prefix_matched([None] * 129))
|
self.assertFalse(policy.waiting_queue_prefix_matched([None] * 129))
|
||||||
|
|
||||||
|
policy.tree_cache = SimpleNamespace(supports_fast_match_prefix=lambda: True)
|
||||||
|
self.assertTrue(policy.waiting_queue_prefix_matched([None] * 129))
|
||||||
|
|
||||||
|
|
||||||
class TestSchedulerLoadInquirer(unittest.TestCase):
|
class TestSchedulerLoadInquirer(unittest.TestCase):
|
||||||
def make_inquirer(self, waiting_queue_prefix_matched):
|
def make_inquirer(self, waiting_queue_prefix_matched):
|
||||||
|
|||||||
Reference in New Issue
Block a user