feat: split and evict CP HiCache metadata
This commit is contained in:
@@ -1084,6 +1084,9 @@ class HiRadixCache(RadixCache):
|
||||
return parent
|
||||
|
||||
def _evict_host_for_physical_slots(self, required_host_slots: int) -> int:
|
||||
if required_host_slots <= 0:
|
||||
return 0
|
||||
|
||||
leaves = list(self.evictable_host_leaves)
|
||||
eviction_heap = [
|
||||
(self.eviction_strategy.get_priority(node), node) for node in leaves
|
||||
@@ -1098,6 +1101,9 @@ class HiRadixCache(RadixCache):
|
||||
if not x.evicted:
|
||||
continue
|
||||
|
||||
if not self._node_backuped(x):
|
||||
continue
|
||||
|
||||
if x.pin_expiry > 0 and time.monotonic() > x.pin_expiry:
|
||||
self._clear_pin(x)
|
||||
|
||||
@@ -1124,6 +1130,9 @@ class HiRadixCache(RadixCache):
|
||||
return num_evicted
|
||||
|
||||
def evict_host(self, num_tokens: int):
|
||||
if self._uses_cp_hicache:
|
||||
return self._evict_host_for_physical_slots(num_tokens)
|
||||
|
||||
leaves = list(self.evictable_host_leaves)
|
||||
eviction_heap = [
|
||||
(self.eviction_strategy.get_priority(node), node) for node in leaves
|
||||
@@ -1596,7 +1605,14 @@ class HiRadixCache(RadixCache):
|
||||
else:
|
||||
new_node.value = child.value[:split_len].clone()
|
||||
child.value = child.value[split_len:].clone()
|
||||
if child.backuped:
|
||||
if self._uses_cp_hicache:
|
||||
if self._node_backuped(child):
|
||||
new_node.cp_hicache, child.cp_hicache = child.cp_hicache.split(
|
||||
split_len
|
||||
)
|
||||
new_node.host_len = split_len
|
||||
child.host_len = child.host_len - split_len
|
||||
elif child.backuped:
|
||||
new_node.host_value = child.host_value[:split_len].clone()
|
||||
child.host_value = child.host_value[split_len:].clone()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user