Problem
apps/desktop/src/main/usage/store.ts L176–193
const lines = readFileSync(USAGE_FILE, 'utf8').split('\n').filter(Boolean);
// then a for-loop applies fromTs/toTs/agentId filters
usage.jsonl grows over time (the comment notes ~1–2 MB per 10,000 requests), but every query reads the entire file into memory, parses all lines, then discards most of them. For time-range queries such as "today's usage," the vast majority of records are thrown away.
Suggested fix
Maintain an in-memory index sorted by timestamp (line offset → ts) and use binary search to locate the fromTs starting point, reading and parsing only the relevant segment. Alternatively, switch to streaming reads for large files.
Problem
apps/desktop/src/main/usage/store.tsL176–193usage.jsonlgrows over time (the comment notes ~1–2 MB per 10,000 requests), but every query reads the entire file into memory, parses all lines, then discards most of them. For time-range queries such as "today's usage," the vast majority of records are thrown away.Suggested fix
Maintain an in-memory index sorted by timestamp (line offset → ts) and use binary search to locate the
fromTsstarting point, reading and parsing only the relevant segment. Alternatively, switch to streaming reads for large files.