Skip to content

perf(worktrees): preserve no-op projection identity and skip unchanged evidence replay #806

Closed

Description

@Juliusolsson05

Confirmed problem

At main 5d64184, canonicalizeWorktreeActivity creates new state/context objects for identical catalogs. The renderer treats those references as changes and appends worktree_catalog_reconciled diagnostics for quiet sessions. LiveWorktreeReconciler.observe also replays up to 500 retained records for unrelated transcript batches.

Evidence

A production-module probe returned new projection references for 1000/1000 value-identical results. In a 120-second audit window, eight sessions each received ten reconciliation records with unchanged diagnostic payloads. A synthetic recorded-fixture benchmark measured approximately 2 ms per unrelated batch with 500 retained worktree events, versus approximately 0.003 ms with none. These are isolated costs, not an app-wide latency measurement.

Expected / acceptance

  • Identical canonical projections preserve references.
  • Unchanged catalog contents, baseline, cwd and retained evidence reuse the previous projection without replay.
  • Relevant evidence, catalog expansion/removal/branch changes and authoritative history replacement invalidate correctly.
  • Preserve stale-hydration contribution reversal, evidence eviction, failed-load retry, disposal and session cleanup behavior.
  • Add meaningful regression tests and reproducible before/after measurements using sanitized fixtures.

Scope is renderer worktree reconciliation and the shared canonicalizer. Main-process index persistence, #763/#762/#767, and A6 issues #802-805 remain separate increments. No lifecycle/readiness or raw terminal input changes.

Activity

  1. Juliusolsson05 commented on Sep 5, 2026

    @Juliusolsson05
    OwnerAuthor

    Implemented in #808 with seven identity/invalidation regressions and a checked-in benchmark. Both CI gates now pass. For 200 unrelated batches with 500 retained records, redundant projection identity changes fell from 200 to zero; isolated median reconciliation cost fell from 2.118166 ms to 0.000333 ms. Not an app-wide typing-latency claim. PR remains open pending review and explicit merge confirmation.

  2. Juliusolsson05 commented on Sep 6, 2026

    @Juliusolsson05
    OwnerAuthor

    Review boundary recorded (from independent review of #808): sameCatalog compares head for every checkout, so ANY commit change in a worktree invalidates catalog identity for that cwd and triggers the full bounded retained-evidence replay at the next refresh. This is correct attribution behavior — an actual checkout change is genuinely relevant evidence — but it is a deliberate boundary of this optimization: a busy repo that moves main every few seconds will not see quiet-session replay savings for sessions on that cwd.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions