[Unified Tree] Preserve aux LRU recency when splitting nodes (#38482)
This commit is contained in:
@@ -615,7 +615,10 @@ class SWAComponent(TreeComponent):
|
||||
new_parent.component_data[self.component_type].value is None
|
||||
and parent_swa_data.host_lock_ref == 0
|
||||
):
|
||||
host_lru.insert_mru(new_parent)
|
||||
if host_lru.in_list(child):
|
||||
host_lru.insert_after(child, new_parent)
|
||||
else:
|
||||
host_lru.insert_mru(new_parent)
|
||||
if (
|
||||
child.component_data[self.component_type].value is None
|
||||
and child_swa_data.host_lock_ref == 0
|
||||
|
||||
@@ -239,6 +239,12 @@ class UnifiedLRUList:
|
||||
self.cache[node.id] = node
|
||||
self._add_node(node)
|
||||
|
||||
def insert_after(self, prev_node: UnifiedTreeNode, node: UnifiedTreeNode):
|
||||
assert prev_node.id in self.cache
|
||||
assert node.id not in self.cache
|
||||
self.cache[node.id] = node
|
||||
self._add_node_after(prev_node, node)
|
||||
|
||||
def remove_node(self, node: UnifiedTreeNode):
|
||||
assert node.id in self.cache
|
||||
del self.cache[node.id]
|
||||
@@ -1307,8 +1313,6 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
|
||||
# owner (b + P) % N on both sides of the split).
|
||||
new_node.rotation_base = child.rotation_base
|
||||
|
||||
self._for_each_component_lru(child, UnifiedLRUList.remove_node)
|
||||
|
||||
child.parent = new_node
|
||||
child.key = child.key[split_len:]
|
||||
new_node.hash_value, child.hash_value = split_node_hash_value(
|
||||
@@ -1334,11 +1338,12 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
|
||||
new_child_node_id=child.id,
|
||||
)
|
||||
|
||||
# Splitting does not access the suffix; retain its recency and place
|
||||
# the inherited prefix beside it, in the same session partition.
|
||||
self._for_each_component_lru(
|
||||
new_node, UnifiedLRUList.insert_mru, skip_existing=True
|
||||
)
|
||||
self._for_each_component_lru(
|
||||
child, UnifiedLRUList.insert_mru, skip_existing=True
|
||||
new_node,
|
||||
lambda lru, node: lru.insert_after(child, node),
|
||||
skip_existing=True,
|
||||
)
|
||||
child.last_access_time = get_and_increase_time_counter()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user