Repository navigation
improve: reduce plugin invocation allocation overhead - #148080
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: needs maintainer review before merge. Reviewed September 14, 2026, 4:17 AM ET / 08:17 UTC. ClawSweeper reviewWhat this changesThe PR reuses one private, stateless callback across three plugin invocation scope constructors to reduce temporary allocations. Merge readiness✅ Ready for maintainer review Keep open: this is a focused, behavior-preserving optimization that remains absent from current main. No actionable correctness or security findings were identified. Priority: P3 Review scores
Verification
How this fits togetherPlugin invocation scopes carry Gateway request context and plugin identity through asynchronous execution. Plugin wrappers create these scopes before invoking registered operations. flowchart TD
A[Plugin invocation] --> B[Read inherited request context]
B --> C[Create fresh plugin scope]
D[Shared default callback] --> C
C --> E[Async execution frame]
E --> F[Plugin operation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +2. Total +2 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the optimization inside the existing scope owner while preserving fresh mutable scopes and inherited callback identity. Do we have a high-confidence way to reproduce the issue? Not applicable to a functional bug: source confirms repeated callback construction, while the reported allocation measurements were not independently rerun in this read-only review. Is this the best way to solve the issue? Yes. Sharing this stateless private callback removes repeated construction without changing public APIs, scope ownership, or lifecycle checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e27efbd2ed47. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* commit 'a08cdc50bc049074ed7ad2db9e18e0ed3f5415ec': (81 commits) perf: reuse stateless plugin scope defaults (#148080) fix(gateway): flush slow-consumer 1008 close frame before terminating socket (#147707) fix: keep model catalogs loading during other session updates (#147878) fix: show queued external chat messages and their source (#147848) refactor(chat): share math label configuration (#148073) perf(ui): trim eager debug overlay icon payload (#147954) improve(logbook): sample batch frame metadata in SQLite (#147999) fix(ui): dismiss suggested task cards without waiting (#148021) fix(maturity): cover governance, interoperability, fleet, and state (#143528) chore(ui): restore core lint and startup budget checks (#148010) fix: chat startup loads unnecessary session setup text (#147973) perf: speed up fresh cloud worker activation (#147945) fix: recover PR preparation after committed merge conflicts (#148063) test(plugins): isolate ClawHub Docker fixture identity (#148074) fix(release): acknowledge ClawHub risk on moving installs (#148041) fix: restore context reads for installed official Discord and Slack plugins (#143341) fix: identify source capsule filesystem failures (#147778) fix(linux): keep Quick Chat widgets bound to their Gateway (#146049) refactor(infra): consolidate update campaign reset ownership (#146555) refactor: simplify Gateway health response parsing (#147834) ...
What Problem This Solves
Plugin invocation scopes repeatedly construct the same stateless default callback, including when an inherited request callback immediately replaces it.
User Impact
No user-visible behavior changes. Request callbacks, registry selection, fresh mutable scopes, and plugin lifecycle checks retain their existing behavior.
Why This Change Was Made
The existing scope owner shares one private always-false callback across its three fallback sites. Inherited callbacks keep their exact identity.
Evidence
All 11 selected scope, invocation-isolation, and registry-adoption tests passed. Fresh independent P2 review found no actionable issues.
A four-process before/after/after/before comparison exercised the real wrapped plugin invocation path, with 100,000 calls per inherited/default mode after warmup. Both repetitions passed output, callback identity, sibling-scope isolation, and post-disposal checks. Mean sampled allocation fell 8.17% with an inherited callback and 10.18% with the default. The observation ran at an earlier author base with identical supplied owner/support bytes and fixed unrelated edits in both arms; the final 11 tests ran on this branch's base.
These are synthetic invocation-allocation results on a shared host, not whole-Gateway, retained-memory, RSS, or exact per-closure byte measurements. Every process group exited and temporary state was removed. No full local build was run; current-head hosted CI remains required before landing.