Skip to content

improve: reduce repeated receipt copies during plugin catalog refresh - #206464

Merged
vincentkoc merged 1 commit into
mainfrom
perf/group-plugin-native-admission-overlays
Nov 27, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/group-plugin-native-admission-overlays

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Preparing a model catalog worker copies published native plugin receipts into the requested plugin inventory. When any receipts exist, the Gateway currently copies the entire receipt map into an array and filters it again for every plugin. An inventory with 40 plugins and 40 receipts visits 1,600 entries during one overlay.

User Impact

Catalog refreshes that carry native plugin receipts can use less temporary allocation. JavaScript-only inventories with no receipts retain the existing fast path. Operators need no configuration change.

Why This Change Was Made

Index the resolved roots visible to this inventory, then scan the current receipt map once. Matching uses the first NUL in the producer’s key and preserves the full key and receipt object. Records for the same root keep separate admission dictionaries. Unmatched rows keep their identity. The index is rebuilt for each overlay so mutable inputs and narrower registry views are respected.

Evidence

Signed 60fb69f7306d on 7d461e504914. Focused formatter, whitespace checks and exact-range local review passed. The regression covers receipt order and overrides, mutable roots and receipts, duplicate roots, a filtered inventory, malformed keys, and row identity.

In an isolated Node 24.22.1 comparison of the two overlay functions with a fixed view lookup, serialized outputs matched across all five shapes. Ten alternating batches per shape gave these median microseconds per call.

Visible plugins Cached receipts Before After Map entries visited
187 0 0.02 0.03 0 → 0
1 1 0.57 0.76 1 → 1
187 1 50.88 49.95 187 → 1
1 40 3.98 3.61 40 → 40
40 40 106.66 19.92 1,600 → 40

The 187-plugin case uses the number of manifests in this revision. The 40/40 shape matches the repository’s synthetic catalog fingerprint benchmark. These timings describe the isolated join. The one-plugin/one-receipt case took 0.19 µs longer.

The repository's complete worker-input benchmark builds the real catalog worker input and fingerprints it. On macOS arm64, Node 26.7.0, two counterbalanced runs per arm each measured 2,000 calls after 200 warmups. CPU and allocation used separate processes. The allocation pass sampled newly allocated bytes, including collected objects, at a 4 KiB interval.

Visible plugins / receipts Stock CPU µs/call Candidate CPU µs/call Stock sampled B/call Candidate sampled B/call
1 / 1 15.93–16.80 16.06–17.24 23,733–23,941 23,583–23,990
40 / 40 115.35–123.02 39.21–39.39 245,883–246,200 53,103–53,310

All 16 processes produced the same complete fingerprint for each cardinality. The 40/40 test uses synthetic receipts with empty native-artifact inventories. Gateway process RSS was outside this measurement.

Three focused suites passed all five tests, including persisted native companion recovery. With just the new regression on stock, the expected one receipt-map traversal failed with three. The candidate passed the same assertion. Production +28/−11 lines, tests +59/−2.

Related to #192547.

@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. labels Nov 27, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 27, 2026 07:13
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR groups native plugin receipts by visible plugin root once instead of scanning all receipts separately for every plugin.

Example: A catalog refresh prepares an inventory containing 40 plugins and 40 native receipts.

  • Before: The overlay visits 1,600 receipt entries.
  • After: The overlay visits 40 receipt entries while preserving receipt precedence and plugin inventory contents.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused and appears correct; evidence exercises the production input builder in process, while the dependency-check failure remains unclassified.
Proof confidence 🦐 gold shrimp (3/6) This internal allocation optimization has author-reported production-builder benchmark results and a red/green work-count regression; it changes no user-visible output, and no shipped-entry-point proof is required for this maintainer-authored change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Preparing catalog worker input allocates repeated temporary receipt arrays when native plugin receipts exist.
Reason: The maintainer-authored direction is established, and the focused change has measured allocation savings without changing configuration or catalog results; its Related wording appropriately avoids claiming to fix the broader memory issue.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides a focused allocation improvement still absent from main, with no actionable correctness or security findings.

Reviewed head: 60fb69f7306ddcd321de1a22aac4d25cc67e9a1d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The native admission owner overlays cached receipts onto plugin metadata before the model catalog owner constructs worker input, preserving published metadata and passing matching receipts to the worker.

flowchart TD
  A[Plugin metadata inventory] --> D[Native receipt overlay]
  B[Admission cache receipts] --> D
  D --> E[Catalog worker input]
  E --> F[Model catalog worker]
  F --> G[Published model catalog]
Loading

Technical review

Best possible solution:

Retain the single-pass overlay in the existing admission owner while preserving receipt keys, precedence, references, and inventory scope.

Do we have a high-confidence way to reproduce the issue?

Current main visibly copies and filters the complete receipt map for every inventory row, and the author reports a matching red/green traversal regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The local grouping pass removes repeated work at its existing owner without adding a persistent cache, parallel API, or changed admission policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against af91b89f6524.

Provenance checked

  • Native receipt overlay and reference sharing keeps the original intent (9faa93d: Carry reusable admitted native facts into workers without mutating published metadata; the subsequent lifecycle refactor deliberately removed redundant deep copying.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9faa93d adds src/plugins/plugin-native-admission-state.ts:149 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9faa93d44c85; files: src/plugins/plugin-native-admission-state.ts)
  • Goutam Adwant: Raw commit 58962d7 adds src/plugins/plugin-native-admission-source-index.test.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 58962d7f6d6a; files: src/plugins/plugin-native-admission-source-index.test.ts)

PR surface

Source +17, Tests +57. Total +74 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 28 11 +17
Tests 1 59 2 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 87 13 +74

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Inspect the failed dependency-check log and establish whether it requires a branch repair or qualifies as an external failure.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 2:19 AM ET / 07:19 UTC.

@vincentkoc

Copy link
Copy Markdown
Member Author

I checked the failed dependency job requested in review. Its unused exports are in Nextcloud Talk webhook state and subagent delivery. This PR changes only the native receipt overlay and its regression test. The subagent warnings also appeared on main and were repaired in #206429. The two Nextcloud exports came from #203172 and have a separate repair in #206470. The draft dependency check remains failed. Draft job · Main job · Ready-head CI.

@vincentkoc
vincentkoc merged commit 1da3590 into main Nov 27, 2026
270 of 273 checks passed
@vincentkoc
vincentkoc deleted the perf/group-plugin-native-admission-overlays branch November 27, 2026 07:27
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 27, 2026
…restoration-ci-189390-20261127

* commit '6feeb50a3f14fbf0aa5167d342f186dc4d67fc18': (9846 commits)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  fix(agents): skip the bootstrap ritual in one-shot runs (#206477)
  fix(test): preserve stack coordinates in redacted failure reports (#152384)
  fix(gateway): return consistent unavailable response guidance (#191933)
  fix: preserve emphasis in Markdown table row labels (#205349)
  fix(nextcloud-talk): keep webhook spool helpers private (#206470)
  perf(plugins): overlay native receipts once per visible root (#206464)
  fix: keep GitHub comment approvals alive and skip repeat approval on the session PR (#206129)
  perf(config): retain one snapshot for unchanged validation results (#206465)
  refactor(test): reuse canonical secret fixture cleanup (#189492)
  refactor(subagents): own descendant Stop cancellation (#206444)
  refactor(subagents): keep announce cleanup action type private (#206407)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant