Skip to content

perf: accelerate usage loading, reports, and repeated CLI exports - #143

Merged
ya-nsh merged 2 commits into
mainfrom
perf/measured-latency-audit
Sep 5, 2026
Merged

ya-nsh merged 2 commits into
mainfrom
perf/measured-latency-audit

Conversation

@ya-nsh

@ya-nsh ya-nsh commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Repeated dashboard loads and CLI exports reparsed unchanged transcript history, repeated filesystem discovery for the same projects, and retried slow Cursor requests on every automatic run. This change caches extracted Codex/Claude usage, memoizes repository discovery within each calculation, and reuses automatic Cursor sync results for 60 seconds.

On the local ~58,400-event dataset, repeated full JSON exports improved from 5.95–6.73 seconds to 0.95–1.02 seconds. Ingestion improved from 3.17–3.76 seconds to 0.23–0.41 seconds; detailed report generation improved from 0.40–0.46 seconds to 0.13–0.15 seconds. These are populated-cache measurements; first ingestion and expired Cursor syncs still take longer.

Behavior and tradeoffs

  • Usage caching validates source identity, size, nanosecond timestamps and parser policy. Changed files are reparsed with full session context. Date filtering, deduplication and current pricing remain outside the cache.
  • Cached parse warnings are retained; cache persistence failures are nonfatal. Atomic snapshots use private permissions and include existing bounded prompt excerpts. The local snapshots used approximately 146 MB; memory improvement is not claimed.
  • Automatic Cursor sync reuses successes and failures while retaining failure warnings. Explicit Cursor selection and TUI refresh still retry immediately. Credential/cache changes invalidate reuse; setting TOKENLEAK_CURSOR_SYNC_INTERVAL_MS=0 disables it.
  • Adds a reproducible phase benchmark and a detailed audit in docs/performance-audit.md. Fixes two date-dependent Focus tests by specifying their fixture date range.

Validation

  • 1,179 tests passed, 1 skipped, 0 failed.
  • All 10 workspace build/type-check tasks passed.
  • Original and optimized session, project and attribution output structures matched on a saved 58,414-event dataset.
  • Regression coverage includes cache invalidation, cold/warm/uncached parity, date ranges, repricing, warning retention, persistence failures and Cursor retry behavior.
  • Launched the actual TUI in a PTY, refreshed and exited successfully; timed full CLI JSON exports in separate processes.
  • Targeted lint passed for the performance modules. Full-repository lint has 25 pre-existing unused-variable/import errors, including unchanged lines in CLI files.

Review fixes

Both inline findings are resolved in a4343c2: cached record/warning schema validation rebuilds malformed payloads, and sync results are only memoized when the request credentials remain current. Added regression coverage for both reproductions. Integrated current main, preserving the newer accounting, archive and prompt-identity behavior; bumped provider cache parser versions.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 3b7f4182-4be6-4fc9-b5b8-ca25cdfe2000


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/registry/src/parsers/usage-cache.ts
Comment thread packages/registry/src/cursor-auth.ts
@ya-nsh
ya-nsh merged commit d212ae4 into main Sep 5, 2026
2 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.

1 participant