Repository navigation
fix(agents): avoid repeated config copies on catalog refresh - #190848
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR reuses the runtime snapshot owner's immutable config capture for both catalog-worker registration paths. Example: Four refreshes use config revisions 0, 0, 1, 1 with different remote catalog revisions.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain The previous fixture finding is fixed, and this review found no new correctness or security defects; the explicit performance hold still requires owner disposition. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe catalog worker receives configuration, provenance, metadata, and request-local credentials, registers provider plugins, and returns discovered catalog rows and credential facts. flowchart LR
A[Worker request] --> B[Runtime snapshot owner]
B --> C[Immutable config capture]
C --> D[Plugin registration]
A --> E[Request local credentials]
D --> F[Catalog discovery]
E --> F
F --> G[Catalog result]
Technical reviewBest possible solution: Retain the existing snapshot owner and request-local credential path, with landing held until the catalog owner resolves the reported performance tradeoffs. Do we have a high-confidence way to reproduce the issue? Current-main source shows fresh transport configs reaching registration despite an existing reusable publication capture; the PR reports a baseline-negative and candidate-positive real-worker regression, which this read-only review did not execute. Is this the best way to solve the issue? Carrying the existing owner's capture through both registration paths is the smallest complete fix, preserving registration invalidation, authored-source provenance, and request-local credentials without another cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 796b14713458. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +11, Tests +40, Other +2. Total +53 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 2, 2026, 1:58 AM ET / 06:58 UTC (Revision 2). |
|
@clawsweeper re-review Please review exact head Merge remains held for explicit owner disposition of the reported cold-heap increase and additional worker-loop diagnostic, plus required CI/review. This request is for review only. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…w#190848) * fix(agents): reuse captured config during catalog refresh * test(agents): pin catalog capture fixture memory policy
What Problem This Solves
Catalog refreshes repeatedly clone and freeze unchanged runtime and authored config during plugin registration, adding avoidable allocation pressure.
Related: #190564
User Impact
This change reduces repeated config preparation during catalog refreshes. Measured: 18.685% less warm allocation and 30.636% lower peak worker heap. The maintainer explicitly accepted the reported cold-heap increase and unresolved worker-loop timer tradeoff after reviewing both metrics. No config, storage, or operator action changes.
Why This Change Was Made
The worker already publishes each restored config/source pair through the runtime snapshot owner, which retains an immutable capture across equivalent publications. Registration was still consuming each fresh transport clone and missing that reuse.
Pass the publisher's captured config into both initial registration and expanded provider-scope registration. The existing runtime-plugin loader retrieves its paired authored source. Keep the transport config for request-local synthetic-auth receipts, credentials, and catalog processing. Remote revisions still rebuild registrations; no new cache or invalidation policy is introduced.
Production delta: +11 lines. The explicit parameter carries the existing owner's captured pair across both registration paths. Test delta: +40 lines in the existing real-worker fixture, with a matching dedicated test-line allocation; the shared baseline is unchanged.
Evidence
7b5f7c6a4d8f1595a11cea77bf05179e235a26c7..98bda84c16b945fae15670f6bf5f4af8107ebef6: scoped-clean, no actionable findings. The review included the unchanged publication, capture, projection, synthetic-auth, registration, and fingerprint owners; it explicitly notes unrun tests and measurements. This uses the documented fallback because the local ClawSweeper checkout contains unrelated untracked work. Hosted review of exact headb01fd1c805349c80fd9d43bee0532f0bd343482cfound no correctness or security findings and requested only maintainer disposition of the performance tradeoffs: fix(agents): avoid repeated config copies on catalog refresh #190848 (comment). That decision is recorded below; no source changes followed the review.git diff --check: passed.1, 1, 2, 2across two catalog revisions, a config change, and another catalog revision, while registration count advances1, 2, 3, 4.2, expected1) and passes on the candidate. Source tree9d3d802d6ea23876bf5b5f2234e0277e436c2428, now committed asb01fd1c805349c80fd9d43bee0532f0bd343482c. Native wrapper exited 0. Run: https://github.com/openclaw/openclaw/actions/runs/41400017229plugins.slots.memory = "none"preserves the same effective policy without that rewrite; capture-count assertions are unchanged. Independent source review of this correction was clean.scripts/worktree-setup.mjs full, with independent installs/build outputs and matching dependency-input digestb354dcbaf10f65858635172b5615b132a4824d3c8f206df7e8398f9745852fae. Baseline build commit7b5f7c6a4d8f1595a11cea77bf05179e235a26c7; candidate build carriercc955091495687ba5d3783b91b0714201217188acontains the exact candidate tree9d3d802d6ea23876bf5b5f2234e0277e436c2428. Paired measurements completed; acceptance decision below.b01fd1c805349c80fd9d43bee0532f0bd343482c: complete, with 52 successful jobs, 81 skipped jobs, one neutral job, and all three status contexts successful. Theopenclaw/ci-gate, dependency-review, and security-sensitive-review contexts passed: https://github.com/openclaw/openclaw/actions/runs/41402494941Performance acceptance — declared before measurement
Baseline:
7b5f7c6a4d8f1595a11cea77bf05179e235a26c7. Candidate: this PR's reviewed head.Use separate complete compiled builds and identical dependency inputs. Run five serial paired fresh-process comparisons, alternating order BC, CB, BC, CB, BC. Record actual CPU availability/affinity/quota, usable RAM, host load, Node version, source/build identities, and all results.
Committed workload:
Run separate allocation-profile pairs with the same workload plus
--sample-allocation; do not mix profiled timings into the timing comparison. The 19 warm operations are catalog rebuilds after remote-revision changes, not chat turns or cached reads.Acceptance:
Results: maintainer accepted the reported cold-heap and worker-loop tradeoffs. All 20 fresh-process runs completed successfully and every paired request retained equal catalog/runtime hashes and row counts. Native worker closure and process exit were clean; the wrapper exited 0 after native removal of both temporary build worktrees. None of the predeclared scored paired metrics regressed by 20%; the additional worker-loop diagnostic below did.
Host: Node 24.22.1, 4 CPUs with affinity
0-3, CPU quotamax 100000, memory cgroup limitmax, 15.419 GiB physical RAM, 14.286 GiB available after the builds; load average before measurement2.947, 2.063, 1.165. Both builds and all measurements ran serially on the same Testbox. The compiled proof command took 647.696 s. Source dependency inputs matched exactly.Values below are medians of the five per-process summaries, with min–max ranges. Warm p95 is calculated within each run's 19 warm requests. Allocation results come from five separate profiled pairs; their timings are excluded from the timing table. RSS includes the source-based controller plus the compiled worker and instrumentation; it is not whole-Gateway RSS or catalog-worker private RSS.
The allocation reduction is 418.415 MiB over 19 warm rebuilds (18.685%); median peak worker heap falls by 65.104 MiB. The adverse median is cold post-GC heap: +0.042221 MiB, or +43.234 KiB (+0.047264%). Individual cold-latency and final-heap cells also moved upward; every cell is retained below. The predeclared rule requires owner acceptance of a worse metric, so this result is not an automatic merge approval.
All paired cells (baseline → candidate; change)
Timing passes (BC, CB, BC, CB, BC):
Separate allocation passes (BC, CB, BC, CB, BC):
Additional worker event-loop diagnostic
This histogram was recorded but was not in the predeclared scored metric list. It must still remain visible. It measures the worker's 1 ms timer sampling over the warm window, including inter-request gaps and the harness's 100 ms start/stop polling; it is a different population from catalog request latency. Node 24.22.1 creates an interval histogram and records elapsed time between timer callbacks (upstream source).
Unresolved diagnostic: loop p95 increases by 102.478% at the cohort median, including >20% increases in pairs 1, 4 and 5. Loop p99 and maximum medians improve. A sampling-distribution explanation is plausible: 19 warm operations exceed 5% of histogram samples only in the three candidate runs with the p95 jump, while the other seven timing runs stay below 5%. This is an inference, not attribution proof: raw histogram bins and request-correlated timer samples were not retained. It does not erase the adverse result or establish client responsiveness. No unchanged performance rerun was used to replace these results.
Independent evidence audit reproduced all headline calculations and all 400 request hashes/cardinalities. Maintainer decision: accepted for landing on 2026-11-02. After being asked specifically about cold post-GC heap increasing by 43.234 KiB and worker timer p95 increasing from 27.770879 to 56.229887 ms, with attribution explicitly unproven, the maintainer approved continuation conditional on clean review. The exact-head review reports no correctness or security findings; CI passed. This resolves both maintainer-decision items in the review. The adverse measurements and uncertainty remain unchanged above; this is acceptance of the tradeoff, not a claim that the timer result was disproven. Testbox cleanup is confirmed completed.
Next diagnostic
Generated plugin catalogs are emitted by
models-config.plan.tswithJSON.stringify, thenModelRegistry.loadCustomModelssends them through two JSONC replacement passes. Investigate a strict-JSON fast path inparseModelCatalogJson, retaining its existing JSONC path after a syntax error. This is a source-grounded follow-up, not part of this patch or a measured saving.