mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
Cache stats: - hit_rate is now token-level (cache_read / total_input) not request-level - Track uncached_input_tokens per provider in metrics - Preserve request_hit_rate as secondary metric Compression-vs-cache: - Detect when compression busts the prefix cache (expected_cached - actual_read) - Two simple session-level numbers: tokens_saved vs cache_bust_tokens - Log CACHE-BUST per request, aggregate in /stats and telemetry beacon - Single new column in proxy_telemetry_v2: cache_bust_tokens Dashboard infra: - SQL for dashboard_summary table + pg_cron hourly refresh - Hourly + daily aggregation from proxy_telemetry_v2 - Upgrade scripts for adding hourly_stats and cache bust columns
19 lines
824 B
SQL
19 lines
824 B
SQL
-- Simplify cache bust tracking in proxy_telemetry_v2
|
|
-- Run in Supabase SQL Editor
|
|
|
|
-- 1. Drop the over-engineered columns from the previous version
|
|
ALTER TABLE proxy_telemetry_v2
|
|
DROP COLUMN IF EXISTS cache_bust_count,
|
|
DROP COLUMN IF EXISTS cache_bust_net_negative,
|
|
DROP COLUMN IF EXISTS cache_bust_verdict;
|
|
|
|
-- 2. Keep just one column: tokens that lost their cache discount due to compression.
|
|
-- Compare with tokens_saved to see if compression is net-positive:
|
|
-- tokens_saved > cache_bust_tokens → compression wins
|
|
-- tokens_saved < cache_bust_tokens → should freeze more of the prefix
|
|
ALTER TABLE proxy_telemetry_v2
|
|
ADD COLUMN IF NOT EXISTS cache_bust_tokens bigint DEFAULT 0;
|
|
|
|
-- 3. Drop the over-engineered dashboard column too
|
|
ALTER TABLE dashboard_summary
|
|
DROP COLUMN IF EXISTS cache_bust_stats;
|