Skip to content

perf: optimize manifest-registry-installed lstat hotspot on Windows #90362

Description

@211-lee

Context

Follow-up from #85264 (scoped Windows path realpath caches).

The scoped-cache PR addresses plugin hook/skill resolution and sandbox host-path validation paths, but the largest remaining lstat gap is in src/plugins/manifest-registry-installed.ts:

  • buildInstalledManifestRegistryIndexKey() is called ~179 times per config validation
  • Each call creates a new scoped Map(), causing redundant filesystem lookups
  • This accounts for most of the ~13s gap between global cache (8.7s startup) and scoped cache (14.0s startup) on Windows

Proposed approaches

  1. Lift cache scope — reuse a single Map across the ~179 calls within one config-validation pass
  2. Short-lived module-level cache — cache at the module level with a short TTL, cleared after validation completes
  3. Accept current improvement — the scoped cache already achieves a 55% lstat reduction vs no cache; further optimization is optional

Performance data

Metric No cache (baseline) Global cache Scoped cache (current)
lstat total 47,834ms 8,016ms (-83%) 21,376ms (-55%)
Startup to ready ~17s 8.7s 14.0s

CPU profile artifacts: https://gist.github.com/211-lee/cd460d7292a7797043a877f5a3980d25

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions