Repository navigation
Conversation
Plugin manifest discovery and bundled directory scanning probe the same read-only paths repeatedly during cold start (`<rootDir>/skills`, `<rootDir>/.cursor/rules`, etc.). CPU profiles on Windows show fs.existsSync as the single largest self-time contributor (~25s of ~50s cold start). Add a process-level memoization cache and route the 41 fs.existsSync call sites in bundle-manifest, bundled-dir, and sdk-alias through it. The pnpm-workspace diagnostic in bundled-dir keeps the uncached fs.existsSync call so it re-evaluates after `pnpm install`. Fixes openclaw#76209
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. Current main still contains the direct Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land the per-scan cache only after public-surface alias lookup shares the scan resolver, unrelated changelog lines are removed, CI is green, and current-head runtime or profiling proof shows the startup improvement. Do we have a high-confidence way to reproduce the issue? Yes. Current main still contains the direct Is this the best way to solve the issue? No, not as submitted. A per-scan cache is the right boundary, but the public-surface alias helper must receive the same resolver and the changelog/proof blockers need closure first. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 9fa685e3b3e4. |
Address clawsweeper [P2]: the previous module-level Map<string, boolean> in src/shared/cached-fs.ts persisted for the lifetime of the Node process. A false miss recorded during one plugin scan could be re-served on later scans after marker files (skills/, .cursor/rules, SDK artifacts) appeared in the same process — violating the plugin-discovery freshness boundary. Refactor to a closure-owned cache: - Replace existsSyncCached / invalidateExistsSyncCache with a createExistsSyncCache() factory returning an ExistsSyncCache instance. - Thread an optional resolveExists callback (or ExistsSyncCache instance) through bundle-manifest, bundled-dir, and sdk-alias entry points. Each top-level scan creates ONE cache and passes it down to its private helpers; without one the helpers fall back to plain fs.existsSync (no cache) so one-off callers stay correct. - Tests now cover the per-instance shape and add a regression for cross- instance isolation (caching a false in instance A does not leak into instance B), plus an explicit stale-false invalidate-and-reprobe path. Verified locally: pnpm test src/shared/cached-fs.test.ts (6 passed) pnpm test src/plugins/bundle-manifest.test.ts (15 passed) pnpm test src/plugins/bundled-dir.test.ts (19 passed)
|
Addressed clawsweeper [P2] + [P3] in Bug: the previous Surface: plugin scan/install paths in Fix: replaced the bare exports with a [P3] CHANGELOG: added the required Why best: keeps the cold-start CPU win ( Verified locally:
|
…he-exists-sync # Conflicts: # CHANGELOG.md
…he-exists-sync # Conflicts: # CHANGELOG.md
…he-exists-sync # Conflicts: # CHANGELOG.md
7771c0d to
60ebf0d
Compare
909b9a3 to
0c047ea
Compare
0c047ea to
8f4ae59
Compare
…he-exists-sync # Conflicts: # CHANGELOG.md
|
Closing — CI shows 15 failures across the matrix and the change has grown beyond what a perf-only PR should be (size: L). Will revisit as a smaller, scoped patch with a real benchmark proof if the perf gain still holds on current main. Thanks. |
Plugin manifest discovery and bundled directory scanning call
fs.existsSync41 times across hot paths during cold start. CPU profiling on Windows reportedfs.existsSyncself-time of ~25 s (≈50% of profile) for a single cold start (#76209).This PR adds a process-level memoization cache (
src/shared/cached-fs.ts) and routes those 41 probes through it across:src/plugins/bundle-manifest.tssrc/plugins/bundled-dir.tssrc/plugins/sdk-alias.tsThe pnpm-workspace diagnostic in
bundled-dirkeeps a directfs.existsSyncso it re-evaluates after the user runspnpm install(preserves the existing test contract).Why caching is safe here
Paths probed during the plugin scan are stable for the lifetime of the process — no scan-time path creation. The cache exposes
invalidateExistsSyncCachefor tests / future callers that need to force a fresh probe.Tests
src/shared/cached-fs.test.tscover hits, misses, single-key invalidation, and full clear.pnpm test:changedgreen (plugins shard: 83 tests pass).Fixes #76209