Skip to content

perf(cli): avoid unrelated transcript reads on latest-session lookup #2475

Backlog

Description

@spboyer

Summary

loadLatestSession discovers saved sessions by parsing every archived transcript before loading the newest eligible session again. The common resume path scales with total retained history even when almost all archives are outside the 24-hour eligibility window.

Proposed primary owner: state-storage-dev.

Baseline evidence

Revision: 47082a81799710c3e457b594123d190c00596ebf, observed 2026-11-12.

Code: session-store.ts:81-124; shell startup caller at shell/index.ts:221.

Independent repeat with daily retained archives, 200 messages of 256 characters per archive, and only the newest archive recently active:

Retained sessions p50/resume lookup p95 Synchronous reads
10 0.945 ms 2.355 ms 11
100 8.277 ms 11.917 ms 101
1,000 121.578 ms 137.704 ms 1,001

At 1,000 archives, separate untimed instrumentation observed 75,212,137 bytes read for the lookup. Original audit passes had p50 116.6-206.8 ms with differing timestamp distributions; these are baseline observations, not optimization speedups.

Environment: Apple M4 arm64, 16 GiB, Darwin 25.6, Node 24.15.0; three rounds of ten sequential observations per case, two warmups, warm filesystem caches, setup/imports outside timing. Assertions verified the selected session and message count. Source methods ran via Node's built-in TypeScript transformation/relative-import hook; the session store's two SDK barrel imports were bound directly to the exact production FSStorageProvider and safeTimestamp exports.

Limit: configured-feed E404 blocked locked dependency restoration, packaged build and startup measurements. These numbers measure session lookup only, not packaged shell startup. Shared reproduction fixtures/raw evidence are required before optimization acceptance.

Scope

Parent: github/squad#2481.

One change to latest-session discovery in session-store.ts; the shell caller is a correctness integration point, not a second optimization. No autosave redesign, history compaction, UI changes or broad storage migration.

Measurable acceptance and tests

For an optimization, use at least three interleaved built-baseline/change rounds with at least 30 observations per case per round; publish raw observations, per-round p50/p95, exact SHA/environment and correctly labeled CPU/I/O/memory evidence. The budgets below are proposed acceptance targets, not already-demonstrated gains. If a safe material win cannot be reproduced, record rejection/defer rather than broaden the implementation to chase the target.

  • Fixed workload: 10/100/1,000 retained daily archives, each 200 messages of 256 characters, with only the newest eligible. Publish transcript read/parse counts and bytes as well as time.
  • On the valid, metadata-current common path, read/parse at most one transcript body, independent of archive count. Metadata discovery is measured separately; explicitly label fallback scans.
  • Target at least 25% lower p50 at 1,000 archives versus the same built baseline. Report all smaller-size and p95 results, not just the winning case.
  • Focused tests verify the selected session and Date rehydration, equal-time ordering, the 24-hour boundary, a malformed newest file, and external stateDir.
  • If metadata is introduced, tests remove/corrupt it and change a transcript from another process; discovery must recover the same eligible session. Recovery may scan, but cannot silently omit sessions.
  • Publish a portable fixture/reproduction command and actual before/after table; preserve public API and error behavior.

Related work

The closed resume/rendering issue github/squad#663 does not cover this measured all-transcripts discovery cost. This is distinct from growing-history autosave write amplification.

Methodology: dotnet/aspnetcore#70219 and microsoft/waza#846.

Activity

  1. changed the title [-]perf(cli): resume the latest session without parsing every archived transcript[/-] [+]perf(cli): avoid unrelated transcript reads on latest-session lookup[/+] on Nov 12, 2026
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