Floor CP HiCache tail splits to page boundaries

CP HiCache ownership is page-granular, so a backed radix node must not be split inside a padded physical tail page. When a shorter hit would require an interior tail-page boundary, matching now floors to the previous page boundary and sacrifices the sub-page cache prefix instead of splitting ownership metadata.

Constraint: Host/device/draft CP HiCache metadata tracks page owners and padded physical spans.

Rejected: Split one padded tail page across two radix nodes | it would require half-page ownership semantics and risks double-counting capacity.

Confidence: high

Scope-risk: moderate

Directive: Keep exact valid-tail hits, but floor partial backed-node splits to page boundaries unless metadata gains explicit sub-page ownership.

Tested: Remote py_compile for hiradix_cache.py and test_cp_hicache_metadata.py in g0034 container.

Tested: Remote pytest targeted backed-tail split tests plus exact valid-tail hit test: 3 passed.

Tested: Remote pytest test_cp_hicache_metadata.py test_cp_hicache_load_back_owner_lanes.py: 92 passed, 5 warnings.

Not-tested: Live ETE traffic under divergent short-prefix prompts.

Co-authored-by: OmX <omx@oh-my-codex.dev>
This commit is contained in:
laoyao0822
2026-05-29 06:57:16 +08:00
parent c9f790cde9
commit 8001c4ae8e
3 changed files with 118 additions and 6 deletions

View File

@@ -3350,6 +3350,15 @@ class HiRadixCache(RadixCache):
and child.id in getattr(self, "pending_host_backups", {})
):
raise HiCachePendingBackupSplit(child)
if (
self._uses_cp_hicache
and self.page_size > 1
and self._node_backuped(child)
and prefix_len % self.page_size != 0
):
prefix_len = prefix_len // self.page_size * self.page_size
if prefix_len == 0:
break
new_node = self._split_node(child.key, child, prefix_len)
if not new_node.evicted:
value.append(new_node.value)