Skip to content

perf(storage): eliminate swarm ledger full-scan hot path - #2040

Merged
likun666661 merged 1 commit into
apache:mainfrom
likun666661:fix/swarm-ledger-hot-path
Aug 4, 2026
Merged

perf(storage): eliminate swarm ledger full-scan hot path#2040
likun666661 merged 1 commit into
apache:mainfrom
likun666661:fix/swarm-ledger-hot-path

Conversation

@likun666661

Copy link
Copy Markdown
Member

Summary

  • cache workspace-wide tool-ledger health and invalidate it with SQLite data_version
  • validate each hot-path transition against only the affected invocation history
  • coalesce bursty session-list refreshes into one in-flight IPC plus one trailing refresh
  • preserve fail-stop behavior when another session ledger is corrupt

Performance

Measured against a copy of a real workspace database with 28,619 runtime events and 77.47 MB of payload JSON:

  • before: 20 tool boundaries in 6,268 ms (313.41 ms per boundary)
  • after: 20 tool boundaries in 10 ms (0.52 ms per boundary)
  • one-time workspace integrity scan on open: 305 ms

A real 32-way deepseek-flash-reader swarm spawned all 32 children. During the active swarm, renderer CDP latency was 28 ms median, 124 ms p95, and 166 ms max; the previous build reached 15.8 seconds. Main-process profiling no longer showed decodeStoredRuntimeEvent, scanToolLedger, or assertToolLedgerTransition as hotspots.

Validation

  • 66 targeted SQLite runtime/recovery tests passed
  • 1,544 desktop tests passed
  • storage and desktop typechecks passed
  • full workspace build passed
  • Biome check passed for all changed files
  • real desktop/CDP 32-subagent swarm reproduction passed

@likun666661
likun666661 force-pushed the fix/swarm-ledger-hot-path branch from 957b64f to 5567fde Compare August 4, 2026 02:27
@likun666661
likun666661 marked this pull request as ready for review August 4, 2026 02:27
@likun666661
likun666661 merged commit 1f69053 into apache:main Aug 4, 2026
11 checks passed
sunheyi6 added a commit to sunheyi6/maka-agent that referenced this pull request Aug 4, 2026
) conflicts

- sandbox-boundary-path: adopt main realpath-space model (no followFinalSymlink)
- builtin-tools ApplyPatch adapter: writes follow the canonical target (apache#2059),
  lstat/delete keep directory-entry semantics via realpathAllowMissing parents
- filesystem worker client: entry-mode normalizer for delete/lstat/create;
  writable roots back to main narrow dirname form
- operations: worker write resolves through followed path; delete/lstat operands
  stay entry-scoped with containment
- storage: drop FileSessionStore per main apache#2040; restore editingProtocol
  persistence in buildSessionHeader + normalizeSessionHeader
- tests: merge symlink suites (replace-mode now follow-final), keep PR lstat/
  delete entry tests, add editingProtocol persistence regression
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