Skip to content

feat: add 'rate' cache mode to show cache hit percentage (CH%)#4

Open
Ambiel127 wants to merge 3 commits into
LinYS77:mainfrom
Ambiel127:main
Open

feat: add 'rate' cache mode to show cache hit percentage (CH%)#4
Ambiel127 wants to merge 3 commits into
LinYS77:mainfrom
Ambiel127:main

Conversation

@Ambiel127

Copy link
Copy Markdown

改动说明

添加了新的 rate 缓存模式,显示缓存命中率 (CH%) 而不是缓存读写 token 数。

改动内容

  • 新增 TokensCacheMode"rate" 选项
  • rate 模式下计算 cacheRead / (input + cacheRead + cacheWrite) * 100
  • 计算公式与 pi 自带的相同
  • 显示格式为 CH87%

使用场景

缓存命中率比 token 数更直观,方便快速判断缓存效果。

配置方式

{
 "tokens": {
   "cache": "rate"
 }
}

ambiel added 3 commits July 18, 2026 22:42
Replace R{tokens} display with CH{percent}% in the tokens segment.
The hit rate formula is consistent with Pi's default status bar:
  cacheHitRate = cacheRead / (input + cacheRead + cacheWrite) × 100%
Add a new 'rate' option to tokens.cache config:
- auto: show cache details in full width mode (original behavior)
- show: always show cache details (original behavior)
- hide: never show cache details (original behavior)
- rate: show cache hit rate as CH{percent}% (new)

When 'rate' is selected, the tokens segment displays:
  ↑12.3k ↓4.5k CH65%

The hit rate formula is consistent with Pi's default status bar:
  cacheHitRate = cacheRead / (input + cacheRead + cacheWrite) × 100%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants