Skip to content

perf(cli): isolate inspect-artifact registration - #15100

Draft
Sonai124 wants to merge 1 commit into
morluto:mainfrom
Sonai124:perf/inspect-artifact-cli-startup-15080
Draft

Sonai124 wants to merge 1 commit into
morluto:mainfrom
Sonai124:perf/inspect-artifact-cli-startup-15080

Conversation

@Sonai124

Copy link
Copy Markdown
Contributor

Summary

Refs #15080. Give inspect-artifact its own lazy CLI registrar. Previously, starting an inspection registered the rest of the artifact command group and evaluated its contracts, including artifact comparison.

Change and scope

The CLI registrar and the MCP catalog use the same canonical inspection contract, including the input and Evidence output schemas. Inspection and extraction share their existing target and option declarations. The full registry keeps the original command order.

The command uses the existing artifact analysis, Evidence delivery, and cleanup paths. Successful inspection still loads the shared DirectAnalysis runtime. Per-operation service composition and first MCP call startup remain open in #15080. The adjacent #14759 concerns AnalysisView imports in the comparison runtime.

Evidence and regression coverage

The compiled import test checks that inspect-artifact --schema loads the canonical inspection contract without loading the broader artifact registrar, comparison command, or output-schema group. Extraction provides the positive control. The generated MCP catalog and recorded catalog digests matched the base byte for byte. Root help and inspection help, schema, and --llms matched as well.

Startup measurements

Compiled base 4dafa3a58e and candidate, Node 24.22.1, Ubuntu 24.04 x64 under WSL2, 12 logical CPUs. Each row is the median of five alternating A/B process pairs. Cold disables the Node compile cache. Warm primes a separate cache for each build and workload. Linux cgroup v2 accounts for process-family CPU and peak memory, including charged file cache.

CLI case Node cache Wall ms CPU ms Peak MiB
One-file ZIP inspection cold 1915 → 1835 2591 → 2375 267.9 → 218.9
One-file ZIP inspection warm 1716 → 1707 2282 → 2265 257.0 → 229.5
inspect-artifact --schema cold 1216 → 640 1581 → 787 162.1 → 85.2
inspect-artifact --schema warm 1031 → 586 1405 → 724 158.7 → 88.6
Malformed artifact limits cold 1185 → 695 1604 → 842 160.7 → 84.5
Malformed artifact limits warm 1114 → 586 1534 → 731 158.2 → 88.2

The separate cold import trace counted 307 → 159 CLI chunks for schema discovery and malformed-limit refusal. A successful ZIP inspection loaded 439 → 440 chunks and 11.84 → 11.69 MB of compiled modules. Its V8 profile still showed shared runtime initialization in DirectAnalysis.

All 80 pairs matched CLI stdout, stderr, and exit status or MCP JSON-RPC response bytes, as applicable. MCP diagnostic logs matched after excluding per-call timestamps and elapsed time.

CLI controls, repeat measurements, and MCP phases
CLI case Node cache Wall ms CPU ms Peak MiB
--version cold 311 → 310 378 → 380 43.7 → 44.2
--version warm 264 → 271 330 → 328 45.3 → 45.5
One-file JavaScript analysis cold 1664 → 1747 2076 → 2199 179.6 → 168.7
One-file JavaScript analysis warm 1534 → 1489 1941 → 1852 186.5 → 187.7
Absent-Ghidra refusal cold 1817 → 1840 2379 → 2378 260.7 → 233.2
Absent-Ghidra refusal warm 1625 → 1645 2282 → 2271 270.1 → 270.7

The full matrix used a shared dependency tree reached by a symlink from the candidate. A repeat gave both builds the same directory layout with hard-linked dependency files. Cold ZIP inspection measured 2004 → 1904 ms wall, 2625 → 2444 ms CPU, and 267.9 → 218.6 MiB peak. Cold JavaScript measured 1594 → 1638 ms wall (+2.7%) and 1926 → 1956 ms CPU. Individual pairs varied in both directions. The baseline compared with itself measured 1611 → 1640 ms wall. These samples leave the cold JavaScript difference inconclusive.

MCP catalog / case Spawn to initialize ms List ms First analysis ms Second analysis ms Total wall ms CPU ms Peak MiB
Full / ZIP 920 → 893 29 → 29 1530 → 1551 20 → 20 2627 → 2614 3211 → 3194 307.8 → 307.0
Full / JavaScript 931 → 905 29 → 30 2161 → 2150 52 → 54 3328 → 3321 4135 → 4140 363.1 → 365.4
Hot-cold / ZIP 955 → 921 6 → 7 1518 → 1522 20 → 20 2630 → 2595 3234 → 3210 303.5 → 303.6
Hot-cold / JavaScript 910 → 916 6 → 6 2056 → 2060 53 → 54 3203 → 3204 3972 → 3983 358.9 → 359.2

The full profile lists 274 tools. Hot-cold initially lists five tools. It discovered the target tool in 9–10 ms and refreshed the list in 2–3 ms before the first analysis request. Total wall time includes stdio shutdown.

Validation performed

  • npm run compile passed on base and candidate.
  • npm run typecheck, npm run lint, and npm run verify:architecture-guards passed on the candidate.
  • Ten focused files passed with 1,149 tests covering CLI startup, lazy registration, contract and schema parity, empty-target admission, ZIP inventory and retained views, CLI/MCP Evidence parity, and canonical contracts and examples.
  • The measurements cover Linux x64 under WSL2. Platform-specific provider runs and full fast-tier PR runner minutes remain unmeasured.

Author readiness

Human owner: @Sonai124

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge, with no actionable defects found.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge, with no actionable defects found.

Summary

Separates inspect-artifact registration from the broader artifact command group.

  • Inspection schema requests now load their own CLI registration path.

No actionable correctness or security issues were found. Tests were not rerun. Supersession could not be confirmed because GitHub access required credentials.

Acknowledged scope: @Sonai124 explicitly defers per-operation service composition and first MCP call startup to #15080. Loading the shared DirectAnalysis runtime after successful inspection remains intentional. Comparison-related AnalysisView imports remain separate work in #14759.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Loader["CLI loader"] --> Registrar["Inspection registrar"]
  Registrar --> Contract["Canonical inspection contract"]
  Registrar --> Runner["Existing session-target runner"]
  Catalog["MCP artifact catalog"] --> Contract
  Runner --> Runtime["Shared DirectAnalysis runtime"]
  Other["Other artifact commands"] --> Broad["Existing artifact registrar"]
Loading

Reviews (1) · Last reviewed commit: "perf(cli): isolate inspect-artifact regi..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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