Skip to content

perf: period-level result cache shared across surfaces + stale-while-revalidate period switching in the app #1135

Closed

Description

@iamtoruk

0.9.21 user-observed: the desktop app is much faster than 0.9.20, but cycling Today > 7D > 30D > 6M > back to 7D refetches 7D and recomputes its aggregation (~1.5-6s per period on a ~21k-file corpus), because (a) the renderer's per-period payload cache has a 30s TTL, and (b) the resident serve child caches the parse, not the per-period aggregation.

Two-part proposal:

1. Stale-while-revalidate in the app renderer (small, big UX win). On period switch, render the last payload for that period immediately (marked via the existing add-only stale field semantics, #1100) and refresh behind it, exactly like the menubar's show-then-refresh pattern. No new wire format.

2. Period-result cache in the serve child (bigger). Cache the derived menubar-json payload per (period, provider, scope, filters) keyed on the session-cache fingerprint, so an unchanged corpus serves a repeat period in milliseconds, across ALL serve clients (app, menubar, web). Invalidation = the fingerprint/watch machinery serve already runs. Disk persistence of these results (surviving restarts) is the natural extension and is exactly the territory of #999 (dgabehar's disk-persisted snapshot PR, currently held) — coordinate rather than duplicate: #999 persists the snapshot across processes; this issue wants the in-memory result keyed per period first.

The parse-level cache is already shared cross-surface (why all surfaces agree on numbers); this issue is about sharing the finished answers too.

Measured today (0.9.21, real corpus): serve child warm, per-period first ask 1.4-6.4s, repeat ask within renderer TTL instant, repeat after TTL full recompute.

Activity

  1. iamtoruk commented on Aug 25, 2026

    @iamtoruk
    MemberAuthor

    Status: part 1 (stale-while-revalidate period switching in the desktop renderer) shipped in the desktop 0.9.21 asset refresh - revisited periods paint instantly for the whole app session. A large slice of part 2's goal ships in CLI 0.9.22 via #999: background menubar-json polls with an unchanged corpus are served from a disk-persisted snapshot instead of re-parsed. Remaining scope for this issue: per-(period, provider, scope) result caching inside the resident serve child for interactive period switches across app/menubar/web, invalidated by the same fingerprint machinery. Targeting 0.9.23.

  2. ozymandiashh commented on Sep 12, 2026

    @ozymandiashh
    Collaborator

    Closing as delivered: part 1 (stale-while-revalidate period switching in the desktop renderer) shipped in the desktop 0.9.21 asset refresh, and part 2's goal landed via #999 (background menubar-json polls with an unchanged corpus are served from the persisted snapshot). If a specific remaining case still recomputes on switch, please open a focused issue with the period sequence and corpus size.

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