Skip to content

perf: progressive cold start — paint the default 7-day view first, index the rest in the background #1107

Closed

Description

@iamtoruk

Cold start (empty cache: first install, cache-version bump) parses the full corpus (~31s on 21k files) before painting anything, yet the default npx codeburn view only displays the last 7 days. First install IS npx codeburn — this is the onboarding moment.

Design

  1. Scoped first paint. A session log's last event timestamp is <= its mtime, so a file with mtimeMs < rangeStart provably contains no in-range activity. On cold start with a dated default view, parse only files with mtime >= rangeStart (minus a small clock-skew margin) and paint. On this corpus that's a few hundred files -> ~1-3s to first dashboard instead of 31s.
  2. Background fill. After paint, index the remaining files (candidate worker: the resident serve child). Safe by construction: the daily cache is per-file, so each parsed file lands durably and independently — no partial-cache correctness hazard, no double-count, and a killed process just resumes where it left off on the next run.
  3. Honest partial UI. Switching to a period the index doesn't cover yet (month/lifetime) shows available data plus an explicit 'indexing N/M files…' indicator — never a silently short total. Dashboard refresh picks up completion.

Never-lose notes

  • The mtime-scoping argument holds for display only; nothing is skipped from the eventual index.
  • Clock-skew margin on the mtime cutoff (e.g. 48h) to be paranoid about machines with drifting clocks / restored backups.
  • Network providers (no on-disk mtime) always load in the first pass.
  • --format json / one-shot report commands must NOT return partial data silently: either keep full parse for non-TUI outputs or add an explicit flag/field.

Related: #1104 (PR #1105) cut the warm sweep; #1106 targets the 3x pipeline rerun; this one owns the cold path.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions