Skip to content

perf(macos): append the execution log in place, skip unchanged tab saves, read agent CLI pipes apart and release closed agent sessions - #4212

Merged
datlechin merged 3 commits into
mainfrom
fix/perf-exec-storage
Nov 12, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/perf-exec-storage

Conversation

@datlechin

@datlechin datlechin commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Performance audit 2026-11-11, lane L1.

  • CPU-01: every query run re-encoded and rewrote the whole execution audit log before the query started. A record now goes in over the array's closing bracket, and only the chain head stays in memory.
    • Same file, ExecutionAudit.json, same array the previous stable reads and rewrites, so the chain stays one chain across an upgrade and a downgrade.
    • Copy of a real 7,754-record, 3.3 MB log: first record 102 ms to 0.6 ms, each later record 58 ms (median, max 194 ms) to 0.08 ms.
    • A file cut short mid-record is closed after its last whole record; one with no readable record is set aside. Both keep the original as ExecutionAudit.damaged-<time>.json. Before, an unreadable log was overwritten by a new chain.
    • A record that cannot be written stays in memory and goes in ahead of the next one, linked to the chain on disk at that time.
  • CPU-05: the 30 s timer, the draft save, tab switches and structure changes rewrote the tab file and every oversized-query sidecar each time. A save now hashes what it would write and skips a file whose bytes are already on disk. Idle connection with ten 100 KB queries and one 5 MB dump: 6 MB per save (720 MB an hour) to 0.
  • NET-01: the Claude Agent chat read both CLI pipes with FileHandle.bytes, whose reads share one serial queue. The quiet stderr read blocked stdout, so text arrived only at exit and a reply past 64 KB hung. Copilot's LSP reader parked the same queue. Both now read each pipe with PipeReader (readabilityHandler). AgentCLIProcess.run read its pipe only at exit and also hung past 64 KB.
  • MEM-03: agent sessions kept their transcript, a full copy of every stored conversation and the schema caches until quit.
    • A session closed or left with no window drops them and reads them back when opened. A transcript longer than the 50 turns a file keeps stays in memory.
    • The conversation list holds titles only; a transcript loads when picked.
    • A session's mention index follows only its own connection's schema.
    • A session restored at launch and not yet opened lost its conversation link on the next session save. Fixed.
  • MEM-05: the Copilot and Cloud SQL Proxy checksum kept every 1 MB read alive until the check ended: +117 MB to +3 MB and +34 MB to +3 MB. Same pattern in .gz decompression: a 393 MB file +397 MB to +2 MB.
  • MEM-02, part: a new file or encoding in the Import dialog now cancels the previous statement count instead of leaving it to read the whole file, and its result no longer lands under the new file. Picking a second file while a .gz decompresses no longer imports the first file.

Needs the maintainer

  • Execution log retention: none, as before. Appends no longer grow with the file, but the file grows about 430 bytes a decision. A cap drops the head of the chain, and the previous stable numbers new records by count, so a prune in this file breaks its numbering.
  • MEM-03 rest: a question sent in the moment a reopened session's transcript is still loading starts its own conversation, as one sent right after a relaunch already does. Holding it until the transcript lands was cut after review.
  • MEM-02 rest: the statement count still keeps every 64 KB chunk alive (SQLFileParser). The wave 5 editor lane is rewriting that file and has not merged, so that part follows it.

Test plan

  • ExecutionAuditLogTests: an earlier build's log goes on, the file decodes as the array after appends, a tail past 64 KB, torn tail repaired, unreadable log set aside byte for byte, held record linked at write time, same-size replacement read again.
  • TabDiskUnchangedSaveTests: an unchanged save keeps the same file (inode), a removed or unreadable file is written again, a changed sidecar is rewritten.
  • AgentCLIProcessTests: 30,000 lines beside a silent stderr (hangs on main), a line arrives before the child exits, run past 64 KB.
  • LSPTransportReadTests: server messages arrive while an AsyncBytes read elsewhere waits (hangs on main).
  • AIChatSessionReleaseTests, AIChatStorageSummaryTests, AgentSessionRegistryTests, AIChatTableMentionsTests.
  • Changed on purpose: AgentSessionRegistryTests "Stopping a session keeps it and its transcript" now checks the transcript is on disk and memory is empty.
  • ImportStatementCountTests: a cancelled count stops before the end of the file.
  • Local: every suite that covers a changed type, 775 tests, all pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant