Skip to content

fix(metrics): resolve 3 GUI stats accuracy bugs#144

Merged
kianwoon merged 1 commit intomainfrom
fix/gui-stats-metrics-accuracy-133
Apr 2, 2026
Merged

fix(metrics): resolve 3 GUI stats accuracy bugs#144
kianwoon merged 1 commit intomainfrom
fix/gui-stats-metrics-accuracy-133

Conversation

@kianwoon
Copy link
Copy Markdown
Owner

@kianwoon kianwoon commented Apr 2, 2026

Summary

  • Bug 1 (High): Cache hit rate inflated ~2x by excluding zero-cache requests from denominator
  • Bug 2 (Medium): avgTokensPerSec dragged down by timed-out/aborted entries (0 tok/s)
  • Bug 3 (Medium): Window scope mismatch — avgCacheHitRate used 50-entry window while token totals used 1000-entry window

Changes

  • Add _nonZeroTpsCount running counter to track entries with tokensPerSec > 0
  • Replace per-request cache hit rate loop with sum-based division using running counters (_totalCacheReadTokens / totalInputAll)
  • Per-model cache hit rate also fixed with same sum-based approach

Closes #133

Test plan

  • npm run build — no type errors
  • npx vitest run — 261/261 tests pass
  • Manual: verify GUI dashboard shows consistent metrics across summary and per-model views
  • Manual: confirm cache hit rate no longer inflates with mixed zero-cache/non-zero-cache requests

- Cache hit rate no longer excludes zero-cache requests from denominator
  (was inflating 40% real rate to ~78%)
- avgTokensPerSec now filters out timed-out/aborted entries (0 tok/s),
  matching per-model stats behavior
- avgCacheHitRate now uses same 1000-entry window as token totals,
  eliminating scope mismatch with the 50-entry recent requests window
@kianwoon kianwoon merged commit b498425 into main Apr 2, 2026
5 checks passed
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.

GUI stats: cache hit rate inflated, avgTokensPerSec includes zeros, window scope mismatch

1 participant