Skip to content

experiment(control-ui): reduce registry read allocations [do not merge] - #184152

Closed
steipete wants to merge 7 commits into
mainfrom
steipete/coldload-child-owner-presentation
Closed

steipete wants to merge 7 commits into
mainfrom
steipete/coldload-child-owner-presentation

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Continued in #184698. GitHub refused to reopen this closed experiment after the branch rewrite; this PR retains the historical a8a00117 head. The replacement carries the reduced change rebased onto main after #184566. Neither PR has been merged.

What Problem This Solves

Repeated session presentation allocates temporary objects while resolving child controllers and counting active descendants. A settled profile attributed 3.41 MB per 30 seconds to child-run lookup and 4.73 MB to descendant counting. The broader campaign observed 14 intermediate states during a signed-in reload of a dashboard deep link; this change targets server allocation and makes no first-paint claim.

Why This Change Was Made

Registry buckets use arrays and their final element supplies the existing last-published lookup, deleting the redundant latest-insertion map. Presentation reads the existing child bucket without the old iterator, matching closure, composite lookup key, or parent-comparison array. Live executor/reservation authority, agent ownership, incarnation matching, and generation ordering stay at the owner. The read remains O(runs in the child's bucket), usually a singleton; array replacement is linear in bucket size.

Descendant reads share active-only options and index the existing topology. Entirely ended sets return zero without filling a fresh count map with zero entries; unended work retains its existing window-specific memo and clock semantics. Existing owner-tuple cache hits already reuse their result; legitimate misses remain.

User Impact

The intended result is less allocation during repeated list presentation with equivalent controller, parent, and navigation results. This experiment is stopped without a landing recommendation: final-head performance and Gateway gates could not be completed on the required hardware.

Evidence

Preserved head: a8a001173cdd94ccfaa5130e1836d988e55374c1. Frozen base: 92415c1e5fe71a311d6a3f72cf66b139d6d2df26. Closed as an experiment; not merged.

Runtime-only delta is +53 LOC across five files (113 insertions, 60 deletions), within the +60 limit. Preserving live authority and incarnation/generation matching in a direct owner query requires the growth; the gateway predicate and redundant latest-insertion map are deleted. Requested non-test/non-doc stat: 460 insertions, 140 deletions, +320 net, including +267 benchmark LOC.

Final gate status

The final benchmark samples separate temporal descendant-read and owner-resolution regions, counting every profile byte, including boundary/caller overhead. The owner region includes its existing argument spreads and CPU bookkeeping. Timing and whole-list global allocation are unchanged. This replaces frame-name attribution: a qualification run proved V8 could inline away the candidate helper and yield a misleading zero. Those frame-derived family figures are not valid final proof and are not used below.

The revised probe has a clean independent P2 review with the complete source. Its payload independently verifies raw profile sums, 240 epochs per region, 518,400 descendant queries, and 2,592,000 owner reads. The ≥80%/≥9-of-11 region gates, ≥9-of-11 whole-list allocation gate, and CPU non-regression rule remain unchanged. The revised probe has not completed remote validation or the final 11-pair comparison. The canonical Gateway timing AB pass has not run.

Final-head capacity attempt Result Cleanup
AWS eu-west-1 on-demand, cbx_b60f2ddb0068 c7a.4xlarge quota rejected; automatic t3.small fallback rejected before validation Release confirmed
AWS eu-west-1 Spot, cbx_f85c8411fa44 c7a.4xlarge capacity unavailable; automatic t3.small fallback rejected before validation Release confirmed
AWS us-east-1 request, cbx_2e4f981e5370 No admitted runner or workload; request cancelled while awaiting response Cancellation acknowledgement timed out; earlier status and native recovery returned 404, and the final status read also timed out. No host or local lease claim was observed

Every confirmed provisioned lease from this lane has been released. No Gateway was started. The final queued-create acknowledgement remains an explicit control-plane cleanup uncertainty; no unconfirmed release is claimed.

Valid earlier diagnostic, not final-head proof

AWS c7a.4xlarge lease cbx_b43d31a82240 completed 11 alternating pairs on baseline 845c3613ffa9c360c821d9fdff322d8fefa82261 and candidate f38236d4bc0ec41d560bcae6caeedea64dbf0dc1. Whole-list totals do not depend on frame attribution, so those diagnostic totals remain usable. They do not satisfy the final-head gate after the benchmark correction and rebase. The following values cover a real 100-row list page over the 10,800-session synthetic fixture, with fixed registry churn; no Mac timing results are used.

Metric Baseline median [Q1, Q3] Candidate median [Q1, Q3] Better pairs Median paired delta
Whole-list allocation (MB/pass) 4.774370 [4.747547, 4.820235] 4.599411 [4.528337, 4.692831] 10/11 -0.178603
List resolution CPU (ms/pass) 10.210194 [9.973194, 10.573278] 9.907833 [9.090569, 10.189208] 9/11 -0.410917
Whole-list CPU including updates (ms/pass) 11.869750 [11.507736, 12.205014] 11.437917 [10.675000, 11.721542] 9/11 -0.481889
Diagnostic per-pair deltas, candidate − baseline

Whole-list allocation (MB/pass): -0.235850, -0.048575, -0.153186, -0.375387, -0.178603, -0.155704, -0.122056, -0.210187, -0.199374, -0.203769, +0.051374
List resolution CPU (ms/pass): -0.132250, -0.322833, +1.660722, -0.410917, -1.861056, -1.179306, +0.240833, -1.461278, -0.991111, -1.031667, -0.001528
Whole-list CPU including updates (ms/pass): -0.154972, -0.347583, +1.513611, -0.481889, -1.920472, -1.184806, +0.212528, -1.433361, -1.128250, -0.954694, -0.066806

Correctness and validation

All 12 focused owner/consumer files and both full builds passed on head 05902aac8a7d6d16c905d8ecee3064762332e51a in AWS lease cbx_14b1226b7fae. The five modified runtime files have identical contents in the preserved final head. Complete changed-file validation took 929.49 s: all types, lint, format, and other guards passed; the only failure was 46 dead-export findings reproduced identically on untouched frozen main, with zero candidate-only findings. That lease's provider connection later failed during timing; its partial timings are excluded. Release is confirmed.

The three changed test files were repeated on AWS c7a.4xlarge lease cbx_4c22d29ea3be; all 67 tests passed and their logs were saved before cleanup. Each command was pnpm test <file> --maxWorkers=1:

Test file Passed Wall time
src/gateway/session-child-controller.test.ts 2 49.70 s
src/agents/tools/sessions-send-communication.test.ts 41 60.10 s
src/agents/subagents/registry/subagent-registry-queries.test.ts 24 43.19 s

The controller property compares the original owner-scoped scan with the direct query across 240 seeded operations and 12 rows, including generation replacement, status changes, executor withdrawal, queued reservations, incarnation changes, and agent-ID mismatch. Descendant properties cover nested/cyclic roots and finite/nonfinite completion timestamps. Both builds also passed on that lease; attribution qualification then stopped before paired runs because the helper frame disappeared. Release is confirmed.

Exact-head GitHub state at closeout: draft automation completed; broad CI was skipped while the experiment remained draft. This is not a broad-CI pass. No UI files change, and no visual claim is made.

Remaining work for the lead: confirm cancellation of the queued-create request if the broker later materializes it, obtain a qualified c7a.4xlarge lease, run the preserved final-head temporal comparison and canonical Gateway timing pass, then mark ready and obtain exact-head broad CI. The source branch is preserved; no merge was attempted.

Cleanup update: explicit AWS status by ID and slug and authoritative provider inspection all return 404 not_found for cbx_2e4f981e5370; there is no matching lease available to release. All subsequently provisioned validation leases have been released.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: L labels Oct 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR reduces temporary allocations in child-controller lookup and descendant counting while extending the existing benchmark.

Example: Present agent:main:subagent:child while agent:main:parent controls its live run.

  • Before: Controller resolution creates temporary lookup and predicate objects.
  • After: Controller resolution scans the existing array bucket directly and returns the same parent after checking live ownership.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is coherent with no discrete finding, but its performance and final-effect authority claims remain unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Repeated session-list presentation spends CPU and allocation resolving child controllers and active descendants.
Reason: The maintainer-authored experiment has a concrete profiled target and bounded acceptance criteria; its direction is approved, with no new setting or public contract.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open as a maintainer-authored performance experiment under an explicit do-not-merge hold; no definite introduced bug was identified.

Priority: P2
Reviewed head: 132b8c723597cc1c1b2b6f37f6459bcab14a7588

Before merge

  • Add real behavior proof - Authority-chain proof required: the changed registry selector feeds session-send admission, but no after-fix trace shows authorized delivery, foreign-controller rejection, or release/reassignment invalidating access before final I/O. The full body and discussion also supply no completed measurements or real-Gateway result for this candidate. Provide redacted logs or terminal output, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve merge risk - The PR owner must establish that direct-bucket controller selection preserves rejection of foreign, released, and reassigned controllers before child delivery.

Findings

None.

Tests

  • Missing end-to-end proof: Pending evidence includes the declared paired allocation/CPU comparison, real-Gateway workload, executed equivalence tests, and allowed versus forbidden final-dispatch scenarios.
Agent review details

How this fits together

The process-local subagent registry supplies current controller identities and descendant counts to Gateway session presentation and session-send admission.

flowchart TD
  A[Registry row publications] --> B[Registry array buckets]
  C[Executor and scheduler ownership] --> D[Controller selection]
  B --> D
  A --> E[Descendant topology]
  D --> F[Gateway session presentation]
  E --> F
  D --> G[Session send admission]
  G --> H[Guarded agent dispatch]
Loading

Technical review

Best possible solution:

Keep controller selection and descendant counting in the existing registry owners, retaining only allocation reductions that meet the declared performance gates without changing communication authority.

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

Current main visibly allocates lookup keys, predicates, iterators, and active-count options on the affected paths; the reported allocation magnitude was not independently reproduced.

Is this the best way to solve the issue?

The diff uses existing registry owners, preserves live ownership checks, and avoids the earlier experiment's controller cache; measurements must determine whether array maintenance and repeated settled-descendant scans deliver a net benefit.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify delivery authority (recommended)
    The PR owner should exercise authorized delivery and foreign-controller rejection, then release or reassign control during an awaited admission and demonstrate rejection before final I/O.
  2. Retain the experimental hold
    Keep this PR draft and unmerged while its predeclared measurements and authority validation remain pending.

Provenance checked

  • Registry bucket representation and publication order keeps the original intent (d8e684e: Consolidate registry index ownership; later performance work retained singleton membership and last-publication ordering during replacement.)
  • Child identity and controller authority keeps the original intent (5bb035b: Require recorded child ownership and reject mismatched session incarnations rather than infer authority across agents.)
  • Durable parent versus temporary controller relationships keeps the original intent (4e26493: Keep retained native children reachable while preventing a parent from taking over another live controller's execution.)
  • Descendant reads and owner benchmark keeps the original intent (11de7dd: Reuse descendant topology during status churn and measure owner costs separately from whole-Gateway behavior.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 619555b adds src/agents/subagents/registry/subagent-registry-memory.ts:132 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 619555ba0f53; files: src/agents/subagents/registry/subagent-registry-memory.ts)

PR surface

Source +51, Tests +214, Other +266. Total +531 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 111 60 +51
Tests 3 224 10 +214
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 344 78 +266
Total 9 679 148 +531

Review metrics

Metric Value Why it matters
Runtime versus test growth Runtime +111/-60 LOC, net +51; tests +224/-10 LOC, net +214. Runtime growth implements direct selection and the settled-descendant fast path; the added tests cover equivalence, ownership transitions, and descendant churn, while the performance payoff remains to be measured.

Root-cause cluster

Relationship: canonical
Canonical: #184152
Summary: This PR explicitly replaces the earlier closed controller-cache experiment with a direct-scan allocation experiment.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: This is a bounded server-allocation improvement without evidence of an urgent user-facing regression.
  • add merge-risk: 🚨 security-boundary: The replacement controller selector participates in cross-session send authorization, so selection equivalence matters at final delivery.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: This is a bounded server-allocation improvement without evidence of an urgent user-facing regression.
  • merge-risk: 🚨 security-boundary: The replacement controller selector participates in cross-session send authorization, so selection equivalence matters at final delivery.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Complete the predeclared paired benchmarks and real-Gateway comparison, including write-maintenance costs.
  • Add final-effect proof for a foreign controller and show release or reassignment invalidates temporary controller access before delivery.

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 October 25, 2026, 11:45 PM ET / October 26, 2026, 03:45 UTC.

@steipete
steipete force-pushed the steipete/coldload-child-owner-presentation branch 2 times, most recently from f38236d to 05902aa Compare October 26, 2026 07:54
Maintain the newest matching live controller in the registry and refresh it when executor or scheduler ownership changes. Remove row-time run scans while preserving generation ordering, partial session identities, foreign control, and durable parent navigation.

Release-note context: reduce session-list and Control UI row-presentation allocation without changing controller or parent relationships.
Share the existing execution ownership checks through a state-bound adapter, retain the controller scan negative control, and prepare runtime config before benchmark projection startup.
Match the Team harness 100-row list request while retaining the full 10,800-row fixture and all-row owner workload. This keeps setup within the existing exact-row preparation budget.
@steipete
steipete force-pushed the steipete/coldload-child-owner-presentation branch from 05902aa to a8a0011 Compare October 26, 2026 10:36
@steipete steipete changed the title experiment(control-ui): allocation-free child owner and descendant reads [do not merge] experiment(control-ui): reduce registry read allocations [do not merge] Oct 26, 2026
@steipete steipete closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant