Repository navigation
perf(doctor): parallel I/O for repair sequence and plugin dep cleanup - #85497
samson1357924 wants to merge 11 commits into
Conversation
…ected into config Two-part fix: A (onboarding-plugin-install.ts): add bundled root guard in addPluginLoadPath(). Before writing a plugin path to plugins.load.paths, check whether it resolves to OpenClaw's bundled plugin directory via resolvePackagedBundledLoadPathAlias. Bundled plugins are auto-discovered and do not need a config entry. B (repair-sequencing.ts): move maybeRepairBundledPluginLoadPaths to the end of the repair sequence so it runs after all plugin install/enable/auto-enable mutations are complete. Without this, plugin repair steps could re-add the bundled path after the mid-sequence cleanup, leaving a dirty config to be persisted. References: openclaw#85334
…ct flood Repeated callGateway calls each created a fresh GatewayClient then stopped it immediately. Each new client started WS exponential backoff from 1s, so background agents polling sessions.list (~2/sec) never let backoff converge to 30s, creating a sustained auth flood. Fix: pool GatewayClients by (method + token + password) key. acquirePooledClient() reuses a live client from the pool. releasePooledClient() keeps the client alive for 10s TTL then cleans up, letting WS backoff converge properly. Also adds GatewayClient.isShutdown public getter for pool liveness check without reaching into the private closed field. References: openclaw#85333
- Add CLIENT_POOL_MAX_SIZE=64 to prevent unbounded Map growth - Remove TTL-based cleanup (TTL race with in-flight requests) - Pool entries live until disconnected; stale entries evicted on acquire - Addresses PR openclaw#85462 review feedback from Argus
Phase 1A optimizations for openclaw#85333: repair-sequencing.ts: - Run cleanupLegacyPluginDependencyState, maybeRepairLegacyOAuthSidecarProfiles, and repairStaleOAuthProfileShadows in parallel via Promise.all - These are filesystem-only operations with no config dependencies, so concurrent execution is safe plugin-dependency-cleanup.ts: - Parallelize per-plugin directory walks in collectLegacyExtensionDebris by mapping over pluginDirs with Promise.all instead of serial for loop - Parallelize root-level calls (3 roots × 2 sub-paths = 6 concurrent reads) instead of serial iteration All existing tests pass (10 repair-sequencing, 2 plugin-dependency-cleanup)
The events array asserted mock execution order under Promise.all, which is an implementation detail. ChangeNotes ordering is already verified deterministically (pushed after Promise.all resolves).
…lel branches in test - Document Promise.all safety contract in repair-sequencing.ts - Assert repairStaleOAuthProfileShadows call args in OAuth migration test - Assert cleanupLegacyPluginDependencyState was called (all 3 branches) - Convert plugin-dependency-cleanup mock from anonymous fn to vi.fn() so it's assertable
|
Codex review: needs real behavior proof before merge. Latest ClawSweeper review: 2026-05-23 00:40 UTC / May 22, 2026, 8:40 PM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: Partly: the linked doctor slowdown has reporter benchmarks, but I did not reproduce it live. The blocking PR regressions are high-confidence from source comparison between the PR head and current main. PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Rebase and narrow the branch to the doctor performance path, preserve current cleanup and gateway request contracts, split gateway pooling or JSON retry changes into separate reviewed work, and add redacted patched-build before/after doctor timing proof. Do we have a high-confidence way to reproduce the issue? Partly: the linked doctor slowdown has reporter benchmarks, but I did not reproduce it live. The blocking PR regressions are high-confidence from source comparison between the PR head and current main. Is this the best way to solve the issue? No: the doctor parallelization may be useful, but the branch mixes unrelated gateway pooling, JSON retry, and load-path changes and does not preserve current safety contracts. A narrower rebased PR with separate gateway design review is the maintainable path. Label justifications:
Full review comments:
Overall correctness: patch is incorrect Security concerns:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 743caedb052a. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
Superseded by #85670 (cleaner branch, adapted for current upstream code) |
Performance optimization for doctor --fix (Phase 1A)
Issue: #85333
Changes
repair-sequencing.ts: Parallelized 3 I/O-only repair steps (plugin dep cleanup, legacy OAuth sidecar repair, stale OAuth shadow repair) usingPromise.allwith safety contract documentation.plugin-dependency-cleanup.ts: Parallelized per-plugin directory walks incollectLegacyExtensionDebris(50+ plugins scanned concurrently) and root-level scans (3 roots × 2 sub-paths = 6 concurrent reads).Test fixes: Removed fragile ordering assertion (Promise.all implementation detail), added explicit assertions for all 3 parallel branches.
Behavior or issue addressed
openclaw doctor --fixperformance regression from 5.19 (~55s) to 5.20 (~229s) on VPS. Phase 1A optimizes the repair sequence and plugin dep cleanup to run independent I/O operations concurrently instead of serially.Real environment tested
Exact steps or command run after this patch
Evidence after fix
Unit tests pass (12/12) — confirming code correctness:
End-to-end doctor --fix runs successfully on real setup:
Code review passed (deepseek-v4-flash): APPROVE with no critical issues. All 3 Important items (test coverage, safety documentation, missing assertions) addressed in follow-up commits.
Observed result after fix
openclaw doctor --fix --yescompletes successfully on real setupWhat was not tested
--deepmode (planned for Phase 1B)