Skip to content

perf: cache Copilot CLI/App sessions per folder on cached loads - #406

Merged
Aymen (aymenfurter) merged 2 commits into
mainfrom
aymenfurter-sync-main-update-canvas
Dec 1, 2026
Merged

Aymen (aymenfurter) merged 2 commits into
mainfrom
aymenfurter-sync-main-update-canvas

Conversation

@aymenfurter

@aymenfurter Aymen (aymenfurter) commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: c2c5e9d7f01dc975c45964a38168bb425fd6eff7

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ npm run check passes (4,267 tests), with new tests for unchanged, changed and same-named CLI folders.
↑ Real data: the second load re-read 7 of 7,017 CLI sessions; the total went from 33 s to 6.3 s.
↓ Custom instructions of an unchanged CLI session can be stale until its log changes (same as editor workspaces).
↓ Tested on macOS only.

Description

Each cached load (disk-cache hit or incremental) read all Copilot CLI/App session folders in ~/.copilot/session-state again, serially. On a machine with about 7,000 sessions this was most of the load time. The cache (~/.copilot-analytics-cache/parsed.json + meta.json) did not record these folders.

Changes:

  • computeDirMetas(Async) now stores a fingerprint (size and mtime of events.jsonl and workspace.yaml) for each CLI/App session folder that has a log.
  • Cached loads keep unchanged CLI/App sessions. They read only the changed folders, through the existing shard pool (serial fallback without a runner). A folder with the same name in another directory is read again too, so no session is lost.
  • The disk cache (about 150 MB of JSON) is loaded only once per parse; before, the stale path loaded it two times.
  • An existing cache has no CLI fingerprints, so the first load reads all CLI sessions one time and saves them. No cache version change is needed.

Measured with the canvas on real data (runtime.log, worker-phase-timing):

Load CLI sessions read Total
Before (cache hit) 7,009 33.1 s
First load after upgrade 7,017 12.6 s
Next load 7 6.3 s

Related Issues

Relates to #402

Checklist

  • npm run check passes (typecheck + lint + spellcheck + knip + tests)
  • Changes are covered by tests (if applicable)
  • Documentation updated (if applicable)
  • User-visible changes are described in a changelog.d/<PR number>.md fragment

Aymen Furter and others added 2 commits December 1, 2026 13:03
Every cached load read all Copilot CLI/App session folders again, serially.
Fingerprint each session folder in the directory metadata, keep unchanged
CLI/App sessions from the cache, and read only changed folders through the
shard pool. Load the disk cache only once per parse.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1dc5f486-30b8-42cb-9bcc-27638e93d668
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1dc5f486-30b8-42cb-9bcc-27638e93d668
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@aymenfurter
Aymen (aymenfurter) merged commit f8117e9 into main Dec 1, 2026
7 checks passed
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.

2 participants