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

オープン
#2,475 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript
領域
cli

調査の方向性

Start with loadLatestSession in packages/squad-cli/src/cli/shell/session-store.ts (lines 81-124) and its shell startup caller in shell/index.ts near line 221. Reproduce the benchmark from the issue's fixture description, counting transcript reads and bytes at 10, 100 and 1,000 archives. Done means the common metadata-current path reads and parses at most one transcript body, the focused tests for the 24-hour boundary, equal timestamps, malformed newest file and external stateDir pass, and before/after results are published.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
3.4k
フォーク
516
平均マージ
1日 15時間
マージ済み PR(30日)
116

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/squad のほかの issue

github/squad の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。