perf(cli): reduce autosave write amplification for a growing session
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- json, typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Start with the autosave call sites in packages/squad-cli/src/cli/shell/index.ts (around lines 1319-1359) and the saveSession function in session-store.ts (lines 64-75), which rewrites the full shellMessages history on every save. The acceptance criteria require a fixed 2,000-message append trace, a round-trip restore of all messages in order, and tests for exit flush, injected write failure and restart. Done means cumulative logical bytes drop at least 50% with no lost messages and benchmark evidence published, but the issue asks for a measured technique choice and includes a proposed owner, so it is not a newcomer task.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Shell autosave synchronously serializes and rewrites the growing persisted message history. The persistence shellMessages array is independent of the UI's 200-message cap, so trimming rendered messages does not bound this work.
Proposed primary owner: state-storage-dev.
Baseline evidence
Revision: 47082a81799710c3e457b594123d190c00596ebf, observed 2026-11-12.
Code: autosave call sites in shell/index.ts:1319-1359, saveSession at session-store.ts:64-75, and the separate UI cap in components/App.tsx:70-80.
Independent repeat, 256-character synthetic messages:
| Messages in active session | Bytes rewritten/save | p50/save | p95/save |
|---|---|---|---|
| 200 | 75,159 | 0.296 ms | 0.378 ms |
| 2,000 | 750,159 | 1.742 ms | 2.144 ms |
| 10,000 | 3,750,159 | 8.378 ms | 9.390 ms |
The fixture measured one overwrite of an existing session at each size, including normal session-directory work. It did not measure complete-session physical disk writes or crash/power-loss durability. Earlier baseline passes measured approximately 8.9-9.5 ms at 10,000 messages; no before/after benefit is claimed.
Environment: Apple M4 arm64, 16 GiB, Darwin 25.6, Node 24.15.0; three rounds of ten sequential observations/case, two warmups, warm filesystem caches, setup/imports outside timing. Production source methods ran via Node's TypeScript transformation/relative-import hook, with the session store's SDK bindings supplied by direct reexports of the exact production FSStorageProvider/safeTimestamp modules.
Limit: dependency-feed E404 prevented locked restore and packaged build/tests. These are function-level persistence diagnostics, not packaged shell throughput or total-session memory results. Shared reproduction fixtures/raw evidence are required before optimization acceptance.
Scope
Parent: github/squad#2481.
One focused change to how the existing shell autosave persists a growing session. Latest-session lookup is separate (github/squad#2475). No UI redesign, history deletion, broad storage/backend migration or unrelated context compaction.
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 trace: append 2,000 messages of 256 characters, requesting the existing autosave after each append and a final flush. Also retain the 200/2,000/10,000-message single-save controls.
- Record cumulative logical bytes written, number of writes, per-save/flush p50/p95 and retained pending-write heap. Physical disk writes are separate and must not be inferred from logical bytes.
- Target at least 50% fewer cumulative logical bytes for the growing trace than the same built baseline, without dropping any message. Report CPU/latency trade-offs and smaller-size controls.
- A round-trip after final flush must restore all 2,000 messages in order, preserving content/timestamps and external stateDir support.
- Test exit/final flush, injected write failure and restart after interruption. Define which writes are acknowledged/durable and preserve or strengthen existing recovery; never hide lost pending messages behind successful output.
- Bound pending-write memory if coalescing/deferred persistence is chosen. Do not prescribe both an append format and coalescing; choose one measured technique.
- Check in the portable trace and publish before/after raw samples/byte counts. If the safe bounded change cannot meet the target, record the result rather than broaden to a new persistence architecture.
Related work
github/squad#1476 concerns coordinator token/context growth, not this synchronous JSON persistence path. This issue is separate from finding the latest saved session among archives.
Methodology: dotnet/aspnetcore#70219 and microsoft/waza#846.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.4k
- Fork
- 516
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 116
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/squad
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bot:ai-assisted component:platform-js status:untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
midnightntwrk/platform-js#38 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ranxianglei/billion-context#7068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vendor: bump whisper.cpp past 6a8addd — the current pin aborts the app on a failed Metal initĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mybigday/whisper.rn#348 ·
-
enhancement severity:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Battle-Cattle/BCUK-Bot-4#1075 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ilan-pinto/roaring-lions#1552 ·
Maintainer thường phản hồi trong vòng 1 ngày