Skip to content

perf(subagent): overlap session store initialization - #1220

Open
TheGreatAxios wants to merge 3 commits into
mainfrom
cl-9010-cold-start
Open

TheGreatAxios wants to merge 3 commits into
mainfrom
cl-9010-cold-start

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Start each leaf session store while independent workdir and agent setup proceeds
  • Keep session stores scoped to their originating worker without pooling
  • Prove the overlap with blocked promises rather than sleeps or filesystem polling

Verification

  • bun test src/subagent/run-audit-store.test.ts passes: 3 tests, 0 failures
  • bun run typecheck passes
  • bun run check passes: lint, typecheck, dead-export guard, build, and 8,597 tests across 551 files
  • The overlap test fails the old sequential ordering at expect(storeStarted).toBe(true) while mkdir remains unresolved, then verifies both mkdir and store resolution are required before agent construction
  • Benchmark source: scripts/measure-subagent-cold-start.ts
  • Benchmark command: bun scripts/measure-subagent-cold-start.ts --samples=7
  • Boundaries: a = assemble inference dependencies; b = discover skills and construct skill tools; c = make the workdir and initialize session stores; readiness = a + b + c immediately before agent construction
  • The benchmark runs one excluded warmup per mode and alternates measured mode order. Sequential models the parent/base ordering (mkdir, then stores); overlap models this branch (start stores, mkdir, then await stores).

Raw samples in milliseconds:

N sequential a/b/c/readiness overlap a/b/c/readiness paired savings
1 0.025 / 0.631 / 3.610 / 4.267 0.030 / 0.809 / 3.655 / 4.494 -0.227
2 0.020 / 0.770 / 2.616 / 3.407 0.031 / 0.680 / 2.800 / 3.512 -0.105
3 0.022 / 0.599 / 2.493 / 3.114 0.019 / 0.625 / 2.494 / 3.139 -0.025
4 0.020 / 0.613 / 3.907 / 4.540 0.019 / 0.586 / 2.632 / 3.238 1.302
5 0.021 / 0.681 / 4.072 / 4.775 0.037 / 0.664 / 2.489 / 3.191 1.584
6 0.019 / 0.581 / 2.659 / 3.260 0.023 / 0.579 / 2.208 / 2.811 0.450
7 0.044 / 0.835 / 2.804 / 3.684 0.024 / 0.662 / 2.688 / 3.376 0.309
  • Before sequential readiness: 3.684 ms median, 3.864 ms mean
  • After overlap readiness: 3.238 ms median, 3.394 ms mean
  • Realized paired savings: 0.309 ms median, 0.470 ms mean
  • Residual c latency on the overlap critical path: 2.632 ms median, 2.710 ms mean

Fixes CL-9010

@linear-code

linear-code Bot commented Sep 28, 2026

Copy link
Copy Markdown

CL-9010

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