Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

mlxrunner: keep the reused head of a cached edge safe from eviction

Jesse Grossb859a94509d1
diff --git a/x/mlxrunner/prefix_cache.go b/x/mlxrunner/prefix_cache.go
index 79050de6f..4ced29fb1 100644
--- a/x/mlxrunner/prefix_cache.go
+++ b/x/mlxrunner/prefix_cache.go
@@ -283,11 +283,19 @@ pageIn:
}
}
}
+
+ // If the live offset falls inside the last node, split it so the reused
+ // head stays on the active path and only the unused tail can be evicted.
for i := len(c.activePath) - 1; i >= 0; i-- {
- if c.activePath[i].endOffset <= minOff {
- c.activePath = c.activePath[:i+1]
- break
+ node := c.activePath[i]
+ if i > 0 && node.startOffset() >= minOff {
+ continue
+ }
+ if node.endOffset > minOff {
+ node = splitNode(node, minOff-node.startOffset(), c.caches, &c.pagedOutBytes)
}
+ c.activePath = append(c.activePath[:i], node)
+ break
}
// Update last-used time on only the final used node. For recurrent