Skip to content

perf(plugins): reuse one plugin metadata snapshot per CLI process - #129181

Merged
steipete merged 4 commits into
mainfrom
perf/cli-current-plugin-metadata-snapshot
Aug 25, 2026
Merged

steipete merged 4 commits into
mainfrom
perf/cli-current-plugin-metadata-snapshot

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

CLI commands repeatedly rebuilt the complete plugin discovery and manifest registry because only Gateway startup installed the process-current plugin metadata snapshot. On the measured state copy, status --json rebuilt that metadata dozens of times in one process, producing large filesystem fanout and multi-second latency. agents list --json followed the same path.

Why This Change Was Made

The first authoritative CLI config read now retains the metadata snapshot it already built, promotes a validation-scoped snapshot to a complete process generation without rerunning registry discovery, and adopts it only when the process-current slot is empty. Equivalent config objects continue to reuse the snapshot through the existing policy/control-plane fingerprint comparison.

Gateway behavior remains lifecycle-owned and explicit: its existing setCurrentPluginMetadataSnapshot calls still replace any prior value, while CLI adoption is first-wins only. Installed-index persistence already invalidates the same lifecycle slot for install, update, remove, rollback, onboarding, and Doctor repair flows.

Production LOC: +113/-31 (net +82) | Tests: +148/-21

The production growth is the explicit CLI ownership seam, first-wins publication contract, config-wide snapshot handoff, and registry-free scoped-to-complete promotion. It adds no config or public product surface and removes the repeated discovery work instead of adding a second cache.

Two test-only current-main repairs are included from the broad plugin pass: the geolocation startup inventory now matches its manifest, and optional-tool tests assert the stronger descriptor-cache behavior instead of requiring a redundant scoped loader call.

User Impact

Read-only CLI status and agent inventory commands perform materially less filesystem work and complete faster on plugin-heavy installations. Plugin and Gateway lifecycle semantics are unchanged.

Evidence

Built CLI, isolated copies of the provided state, same --require filesystem shim for every sample:

  • status --json: 174,303 / 174,291 -> 52,823 / 52,821 counted fs calls (about 70% fewer); 4.33s / 4.41s -> 3.94s / 2.63s.
  • agents list --json: 50,745 / 50,745 -> 38,279 / 38,279 counted fs calls (about 25% fewer); 2.93s / 2.32s -> 2.28s / 2.20s.
  • The shim counts nested Node fs entrypoints, so its absolute totals are higher than the earlier external trace; before and after use the identical method set.
  • Regression proof: the real isolated status --json overview built the registry 5 times before the fix and exactly once after it.
  • node scripts/run-vitest.mjs src/plugins: 356 files passed; 5,530 tests passed, 1 skipped.
  • Focused touched-file pass: 184 tests passed across runtime-config, commands, and plugin shards.
  • pnpm build: passed.
  • Dev Gateway on port 19792: reached ready; a status probe reported gateway.reachable=true for ws://127.0.0.1:19792; SIGINT shutdown completed cleanly.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs: passed. Blacksmith delegation did not complete, so this used the authorized local fallback.
  • .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main: clean, no accepted/actionable findings.

CHANGELOG.md is intentionally unchanged.

Built CLI measurements with the same fs shim and isolated state copy:\n- status --json: 174.3k -> 52.8k fs calls; 4.33-4.41s -> 2.63-3.94s\n- agents list --json: 50.7k -> 38.3k fs calls; 2.32-2.93s -> 2.20-2.28s
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 09:06
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 25, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up note: the exact-head review lease expired at 2026-08-25T10:03:46Z while the comment remained at review started; no completed review or Rank-up moves: list was published. There are therefore no published rank-up moves to apply or skip individually. Exact-head hosted CI, native review artifacts, final branch autoreview, focused regressions, the full plugin suite, built CLI proof, and prepare-run are green, so I am proceeding under the repository policy that a queued or late publisher does not block landing.

@steipete
steipete merged commit 83e7fa1 into main Aug 25, 2026
237 checks passed
@steipete
steipete deleted the perf/cli-current-plugin-metadata-snapshot branch August 25, 2026 10:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…enclaw#129181)

* perf(plugins): reuse one plugin metadata snapshot per CLI process

Built CLI measurements with the same fs shim and isolated state copy:\n- status --json: 174.3k -> 52.8k fs calls; 4.33-4.41s -> 2.63-3.94s\n- agents list --json: 50.7k -> 38.3k fs calls; 2.32-2.93s -> 2.20-2.28s

* style(config): use type-only snapshot imports

* fix(cli): scope plugin snapshot adoption to inventory reads

* test(cli): align snapshot harnesses with adoption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant