研究者基于68,266条真实Claude Code会话请求和23,608条Mooncake请求进行了模拟实验,探索是否能在生产环境中的LRU缓存策略基础上实现性能突破1。结果表明,三种优化方案的尝试均以失败告终,这与当前关于KV缓存的学术文献所暗示的LRU策略改进空间存在显著差异1。
实验分析发现,容量约束而非生存时间(TTL)约束才是决定缓存性能的关键因素1。会话间的中位数请求间隔为2.1秒,p90分位数为51.1秒,其中仅9.5%的请求间隔超过60秒,1.0%超过3600秒1。在容量压力下,缓存重计算主要源于几秒间隔内的工具调用循环,而非会话因超出TTL而被驱逐1。进一步的数据显示,5分钟后到达的请求仅占重计算的17.5%,而10秒内到达的请求占比33.1%1。当将TTL设置为300秒时,其结果与基础LRU策略完全相同,印证了在所测容量条件下TTL机制从未被触发1。
研究还测试了包括会话返回概率预测、重计算成本建模和会话粒度驱逐在内的三个优化组件,但这些方案反而导致性能恶化1。即使采用理论上的Belady离线预言机策略,初次测试也未能战胜LRU,根本原因在于缺乏引用计数保护导致自我蚕食现象1。
A researcher conducted simulation experiments by replaying 68,266 authentic Claude Code conversation requests alongside 23,608 Mooncake requests to test whether alternative caching strategies could outperform a production LRU cache policy 1. All three proposed optimization approaches failed to beat the baseline performance 1.
The analysis revealed that under capacity constraints, cache recomputation stems primarily from tool invocation loops occurring within seconds apart, rather than from sessions idling beyond their time-to-live threshold 1. The median interval between requests within sessions was 2.1 seconds, with the 90th percentile at 51.1 seconds and a maximum span of 491,922 seconds (5.7 days) 1. Notably, requests arriving more than 5 minutes later accounted for 17.5 percent of recomputation events, while those arriving within 10 seconds represented 33.1 percent 1. The research found that capacity constraints, not TTL constraints, serve as the decisive factor in cache performance 1.
Three attempted optimization components—including session return probability prediction, recomputation cost modeling, and session-granularity eviction—all degraded performance rather than improving it 1. Even an offline Belady oracle, which uses perfect foresight about future references, initially underperformed LRU, with the root cause traced to the lack of reference counting protection leading to self-cannibalization 1. These findings suggest that the LRU-leaf baseline demonstrates substantially greater robustness than existing academic literature on KV-cache optimization techniques has indicated 1.
评论
还没有评论,欢迎留下第一条。