Skip to content

perf: cache session scan metadata#108

Merged
sorafujitani merged 1 commit into
mainfrom
perf/session-scan-cache
Jul 3, 2026
Merged

perf: cache session scan metadata#108
sorafujitani merged 1 commit into
mainfrom
perf/session-scan-cache

Conversation

@sorafujitani

Copy link
Copy Markdown
Owner

Summary

  • add an mtime/size-validated on-disk cache for Claude session scan metadata
  • cache unusable transcripts as empty records so dead files are not reparsed every launch
  • keep cache failures non-fatal and fall back to parsing
  • isolate scan cache dirs in tests and add cold/warm scan benchmarks

Fixes #99

Benchmark

Baseline was measured on origin/main with the same benchmark body added temporarily and no scan cache implementation.

Commands:

go test -bench=BenchmarkScanManySessions -benchmem ./internal/session -count=10

benchstat /tmp/ccsession-99-before.txt /tmp/ccsession-99-after.txt:

ScanManySessions/warm-cache-12  21.86m ± 7%   11.63m ± 15%  -46.81% (p=0.000 n=10)
ScanManySessions/cold-cache-12                 134.3m ± 10%

ScanManySessions/warm-cache-12  19.275Mi ± 0%   3.694Mi ± 0%  -80.83% (p=0.000 n=10)
ScanManySessions/cold-cache-12                  22.82Mi ± 0%

ScanManySessions/warm-cache-12  57.06k ± 0%   31.05k ± 0%  -45.59% (p=0.000 n=10)
ScanManySessions/cold-cache-12                 87.14k ± 0%

The cold-cache sub-benchmark includes cache writes, so it is expected to be slower than the old no-cache scan. The user-facing win is repeated picker/list reloads once the metadata cache is warm.

Verification

go test ./...
go vet ./...
golangci-lint run
gofmt -l $(git ls-files '*.go') internal/session/cache.go internal/session/cache_test.go
git diff --check

@sorafujitani sorafujitani merged commit f341f9f into main Jul 3, 2026
7 checks passed
@sorafujitani sorafujitani deleted the perf/session-scan-cache branch July 3, 2026 05:50
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.

perf: add an on-disk metadata cache for session scans

1 participant