Skip to content

perf(gateway): reduce session PR subscription allocation - #179909

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-session-pr-subscription-alloc-20260919
Oct 21, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-session-pr-subscription-alloc-20260919

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Accepted for landing by the lead under decision rule v5.1 (2026-10-21). All four corrected interleaved/swapped pairs completed without guard interruption. The lead explicitly superseded the earlier v5 rejection and directed reopening and landing this PR. Full measurements, including adverse pause and internal-span results, remain below.

What Problem This Solves

Open Control UI tabs repeatedly select and sort the same session lineage when stored session rows change, creating avoidable allocation while reconciling session pull-request subscriptions.

User Impact

Session pull-request responses and viewer permissions stay unchanged. The Gateway shares structural selection work between readers of the same row revision and uses one async-work tracking operation for each notification.

Why This Change Was Made

The row owner already indexes parent links. This change reuses its structural child selections under its existing sharing revision; it does not cache authorized results. Every reader still performs live audience checks, excludes incognito rows, and prunes inaccessible ancestors. Preparing row state before looking up the revision also handles deferred registry-only parent changes. Selections acquired while a revision advances remain associated with the earlier revision.

The old per-key notification tracking loop is replaced by one tracked concurrent reconciliation. Runtime production grows by 20 lines: revision-bound structural reuse needs a weak map, while preserving per-reader authority prevents sharing the final selected response. The complete non-test delta is +606 lines: +20 Gateway, +538 standalone measurement harness, and +48 benchmark documentation; regression tests add 122 lines. The harness exercises a real Gateway and records per-tab allocation and native settlement. There is no new config, TTL, schema, public API, or dependency.

Evidence

Base: f28e75c0f721a62b409658032648ef987383206b. Candidate: 7efd3492da728a10e0fcd54e25d991b790025934.

Real source Gateways on a deterministic 5,000-session / 4,000-retained-run fixture, 50 PR keys/tab, 256 subscribe RPCs and 1,000 category mutations per side. Each side records 2,000 eligible notifications at a 100 ms mutation schedule. Collected allocations are included; allocation sampling interval is 32,768 bytes. MB/GB are decimal.

Each workload uses two concurrent pairs under slot A, interleaved CPUs 96–127, swapping baseline/candidate placement in pair 2. The shared guard uses 2,500 ms and three consecutive failed minute checks, plus unchanged load/Dirty limits. All four corrected completed pairs are included in this decision. Prior-harness diagnostics and guard-interrupted attempts are excluded.

The committed workload is scripts/perf/session-pr-subscriptions-measure.ts; fixture preparation is documented alongside it in scripts/perf/README.md. Per-side invocation, repeated for --clients 1 and --clients 8:

node --import ./scripts/tsx.mjs scripts/perf/session-pr-subscriptions-measure.ts \
  --root <side-state> --output <side-results> --port <side-port> \
  --clients <1-or-8> --keys 50 --operations 1000 --subscribes 256 \
  --interval-ms 100 --start-at <shared-future-epoch-ms> --revision <side-sha>

The candidate adds --owner-suffix candidate to load the two hash-verified owner files beside the unchanged baseline owners. Pair 1 baseline uses 96,98,…,126 and candidate uses 97,99,…,127; pair 2 reverses them. Each pair holds .quiet.lock. Each side uses a systemd scope with CPUWeight=10, IOWeight=10, MemoryMax=12G, nice 19 and idle I/O. Preparation runs sequentially on CPUs 0–63. Corrected harness SHA-256: 6618c29cee747300ddc19c4bca74e036cfbeefe9373a29dcd2df55c9e30bb218.

Deltas are (candidate / baseline − 1) × 100. Decision is the mean of the two percentage deltas, not the ratio of aggregate metrics. Reject at ≥20% adverse mean, or ≥10% adverse in both pairs. P95 requires ≥200 samples/side and p99 ≥1,000. Major GC needs ≥50 collections/side; below that it is context and total GC carries the gate.

Decision rule v5.1 and lead acceptance

The updated rule is: per-pause minor-GC p95 is context, not a gate, when collection count fell at least 20% and total GC time did not rise. The lead explicitly declared this PR PASS and directed landing it under v5.1. This records that overall decision; the remaining sample-qualified adverse diagnostics below are preserved without relabeling their measured direction.

In the eight-tab pairs, minor collections fell 1,907→1,148 (−39.80%) and 1,821→1,167 (−35.91%). Total GC time fell in both pairs, with a −31.09% mean paired delta; promotion fell 50.44% and allocation per notification fell 37.67%. The full minor-GC p95 evidence remains in the table as context under v5.1. The one-tab pairs also meet the exception: minor collections fell 334→252 and 344→252, and total GC time fell in both pairs.

For accuracy, the recorded eight-tab candidate maximum minor-GC pause in pair 2 was 103.497 ms (n=1,167). The summary claim that all maximum pauses were below 50 ms does not hold. The updated minor-GC p95 rule uses collection-count reduction and total GC time; no measured values have been removed or changed for this acceptance.

Eight tabs

Metric Pair 1 baseline → candidate Δ1 Pair 2 baseline → candidate Δ2 Mean paired Δ Eligibility
Total sampled allocation (GB) 56.886 → 35.334 -37.89% 56.834 → 35.545 -37.46% -37.67% eligible
Allocation / notification (MB) 28.443 → 17.667 -37.89% 28.417 → 17.772 -37.46% -37.67% eligible
Allocation / notification / tab (MB) 3.555 → 2.208 -37.89% 3.552 → 2.222 -37.46% -37.67% eligible
Family allocation (GB) 54.991 → 33.422 -39.22% 54.951 → 33.659 -38.75% -38.98% eligible
Family allocation / notification / tab (MB) 3.437 → 2.089 -39.22% 3.434 → 2.104 -38.75% -38.98% eligible
Promotion (GB) 3.260 → 1.529 -53.11% 3.008 → 1.571 -47.76% -50.44% eligible
Total GC (ms; collections) 3,552.403 (n=1,947) → 2,296.579 (n=1,174) -35.35% 5,089.281 (n=1,861) → 3,723.724 (n=1,195) -26.83% -31.09% eligible
Minor GC (ms; collections) 3,159.123 (n=1,907) → 2,062.232 (n=1,148) -34.72% 4,593.415 (n=1,821) → 3,259.846 (n=1,167) -29.03% -31.88% eligible
Total GC pause mean (ms) 1.825 (n=1,947) → 1.956 (n=1,174) +7.22% 2.735 (n=1,861) → 3.116 (n=1,195) +13.95% +10.58% eligible
Total GC pause p50 (ms) 1.614 (n=1,947) → 1.758 (n=1,174) +8.92% 1.774 (n=1,861) → 1.918 (n=1,195) +8.12% +8.52% eligible
Total GC pause p95 (ms) 2.174 (n=1,947) → 2.382 (n=1,174) +9.57% 4.382 (n=1,861) → 6.718 (n=1,195) +53.31% +31.44% eligible
Total GC pause p99 (ms) 14.270 (n=1,947) → 14.718 (n=1,174) +3.14% 18.686 (n=1,861) → 26.878 (n=1,195) +43.84% +23.49% eligible
Minor GC pause mean (ms) 1.657 (n=1,907) → 1.796 (n=1,148) +8.44% 2.522 (n=1,821) → 2.793 (n=1,167) +10.74% +9.59% eligible
Minor GC pause p50 (ms) 1.614 (n=1,907) → 1.750 (n=1,148) +8.43% 1.774 (n=1,821) → 1.910 (n=1,167) +7.67% +8.05% eligible
Minor GC pause p95 (ms) 2.110 (n=1,907) → 2.350 (n=1,148) +11.37% 3.822 (n=1,821) → 5.534 (n=1,167) +44.79% +28.08% context: v5.1 collection-count/total-GC exception
Minor GC pause p99 (ms) 3.006 (n=1,907) → 3.054 (n=1,148) +1.60% 17.278 (n=1,821) → 24.318 (n=1,167) +40.75% +21.17% eligible
Main CPU (ms) 59,246.019 → 41,414.995 -30.10% 63,389.546 → 45,259.283 -28.60% -29.35% eligible
Process CPU (ms) 84,093.250 → 59,935.959 -28.73% 88,018.192 → 65,664.624 -25.40% -27.06% eligible
Subscribe p95 (ms) 32.588 (n=256) → 21.830 (n=256) -33.01% 43.910 (n=256) → 28.677 (n=256) -34.69% -33.85% eligible
Notify RPC p95 (ms) 16.746 (n=1,000) → 15.137 (n=1,000) -9.61% 129.248 (n=1,000) → 90.243 (n=1,000) -30.18% -19.89% eligible
Notify RPC p99 (ms) 26.647 (n=1,000) → 19.119 (n=1,000) -28.25% 241.558 (n=1,000) → 187.838 (n=1,000) -22.24% -25.24% eligible
Event-loop p99 (ms) 89.719 (n=2,875) → 57.016 (n=3,887) -36.45% 160.694 (n=2,287) → 116.261 (n=3,293) -27.65% -32.05% eligible
Scheduling p95 (ms) 0.539 (n=1,000) → 0.525 (n=1,000) -2.73% 964.557 (n=1,000) → 244.886 (n=1,000) -74.61% -38.67% eligible
Scheduling p99 (ms) 0.648 (n=1,000) → 0.598 (n=1,000) -7.63% 1,388.421 (n=1,000) → 658.456 (n=1,000) -52.58% -30.10% eligible
Subscribe p99 (ms; context only) 70.455 (n=256) → 40.265 (n=256) -42.85% 59.528 (n=256) → 49.263 (n=256) -17.24% -30.05% context: n<1000
Major GC (ms; collections; context only) 358.412 (n=20) → 211.699 (n=13) -40.93% 451.868 (n=20) → 381.851 (n=14) -15.50% -28.21% context: major GC n<50
Major GC pause p95 (ms; context only) 23.678 (n=20) → 17.918 (n=13) -24.33% 47.358 (n=20) → 74.750 (n=14) +57.84% +16.76% context: major GC n<50
Major GC pause p99 (ms; context only) 24.830 (n=20) → 19.070 (n=13) -23.20% 76.286 (n=20) → 97.790 (n=14) +28.19% +2.50% context: major GC n<50

All four native barriers on every side report exactly one scope and zero pending work; baseline/candidate initial/final snapshots match. Source labels, owner hashes, CPU affinity, sample counts, and successful non-interrupted outcomes were verified directly against the captured results.

Lead decision: PASS under v5.1. Minor-GC p95 is context under the updated rule; all other measured cells remain visible as part of the lead-approved result.

Capture durations (baseline/candidate ms): pair 1: 99971.611/99949.745; pair 2: 99962.803/99945.160.

One tab

Metric Pair 1 baseline → candidate Δ1 Pair 2 baseline → candidate Δ2 Mean paired Δ Eligibility
Total sampled allocation (GB) 8.933 → 7.788 -12.83% 8.915 → 7.826 -12.22% -12.52% eligible
Allocation / notification (MB) 4.467 → 3.894 -12.83% 4.457 → 3.913 -12.22% -12.52% eligible
Allocation / notification / tab (MB) 4.467 → 3.894 -12.83% 4.457 → 3.913 -12.22% -12.52% eligible
Family allocation (GB) 7.700 → 6.553 -14.90% 7.668 → 6.575 -14.26% -14.58% eligible
Family allocation / notification / tab (MB) 3.850 → 3.276 -14.90% 3.834 → 3.287 -14.26% -14.58% eligible
Promotion (GB) 0.288 → 0.285 -1.25% 0.318 → 0.282 -11.20% -6.22% eligible
Total GC (ms; collections) 601.086 (n=348) → 538.473 (n=266) -10.42% 738.981 (n=356) → 565.363 (n=260) -23.49% -16.96% eligible
Minor GC (ms; collections) 501.460 (n=334) → 433.447 (n=252) -13.56% 624.261 (n=344) → 491.463 (n=252) -21.27% -17.42% eligible
Total GC pause mean (ms) 1.727 (n=348) → 2.024 (n=266) +17.20% 2.076 (n=356) → 2.174 (n=260) +4.75% +10.98% eligible
Total GC pause p50 (ms) 1.454 (n=348) → 1.670 (n=266) +14.86% 1.462 (n=356) → 1.678 (n=260) +14.77% +14.81% eligible
Total GC pause p95 (ms) 2.158 (n=348) → 2.510 (n=266) +16.31% 3.822 (n=356) → 3.774 (n=260) -1.26% +7.53% eligible
Total GC pause p99 (ms) 11.710 (n=348) → 13.310 (n=266) +13.66% 15.614 (n=356) → 12.350 (n=260) -20.90% -3.62% context: n<1000
Minor GC pause mean (ms) 1.501 (n=334) → 1.720 (n=252) +14.56% 1.815 (n=344) → 1.950 (n=252) +7.47% +11.02% eligible
Minor GC pause p50 (ms) 1.438 (n=334) → 1.662 (n=252) +15.58% 1.446 (n=344) → 1.678 (n=252) +16.04% +15.81% eligible
Minor GC pause p95 (ms) 1.998 (n=334) → 2.286 (n=252) +14.41% 3.198 (n=344) → 3.054 (n=252) -4.50% +4.96% context: v5.1 collection-count/total-GC exception
Minor GC pause p99 (ms) 2.542 (n=334) → 2.686 (n=252) +5.66% 4.606 (n=344) → 5.470 (n=252) +18.76% +12.21% context: n<1000
Main CPU (ms) 16,214.170 → 15,413.229 -4.94% 16,768.300 → 15,375.108 -8.31% -6.62% eligible
Process CPU (ms) 28,370.080 → 27,692.445 -2.39% 29,364.573 → 27,037.575 -7.92% -5.16% eligible
Subscribe p95 (ms) 13.074 (n=256) → 9.731 (n=256) -25.57% 16.659 (n=256) → 12.407 (n=256) -25.52% -25.55% eligible
Notify RPC p95 (ms) 16.643 (n=1,000) → 16.293 (n=1,000) -2.10% 21.024 (n=1,000) → 20.795 (n=1,000) -1.09% -1.60% eligible
Notify RPC p99 (ms) 21.038 (n=1,000) → 21.152 (n=1,000) +0.54% 42.214 (n=1,000) → 36.593 (n=1,000) -13.31% -6.39% eligible
Event-loop p99 (ms) 28.115 (n=4,937) → 27.263 (n=4,940) -3.03% 29.917 (n=4,878) → 30.179 (n=4,891) +0.88% -1.08% eligible
Scheduling p95 (ms) 0.460 (n=1,000) → 0.636 (n=1,000) +38.43% 0.545 (n=1,000) → 0.708 (n=1,000) +29.87% +34.15% eligible
Scheduling p99 (ms) 0.571 (n=1,000) → 0.922 (n=1,000) +61.43% 982.338 (n=1,000) → 981.457 (n=1,000) -0.09% +30.67% eligible
Subscribe p99 (ms; context only) 17.204 (n=256) → 11.756 (n=256) -31.67% 51.493 (n=256) → 33.822 (n=256) -34.32% -32.99% context: n<1000
Major GC (ms; collections; context only) 88.807 (n=7) → 93.721 (n=7) +5.53% 103.833 (n=6) → 64.878 (n=4) -37.52% -15.99% context: major GC n<50
Major GC pause p95 (ms; context only) 18.302 (n=7) → 18.430 (n=7) +0.70% 25.982 (n=6) → 23.678 (n=4) -8.87% -4.08% context: major GC n<50
Major GC pause p99 (ms; context only) 18.302 (n=7) → 18.430 (n=7) +0.70% 25.982 (n=6) → 23.678 (n=4) -8.87% -4.08% context: major GC n<50

All four native barriers on every side report exactly one scope and zero pending work; baseline/candidate initial/final snapshots match. Source labels, owner hashes, CPU affinity, sample counts, and successful non-interrupted outcomes were verified directly against the captured results.

Lead decision: PASS under v5.1. Minor-GC p95 is context under the updated rule; all other measured cells remain visible as part of the lead-approved result.

Capture durations (baseline/candidate ms): pair 1: 99919.834/99916.670; pair 2: 99921.083/99921.522.

Incremental subscriber estimate

The mean 8-tab cost minus the mean 1-tab cost, divided by seven added tabs, gives the incremental allocation estimate. This is distinct from dividing the total eight-tab cost by eight.

Incremental allocation per notification per added tab: 3.424 → 1.974 MB (-42.35%). This cross-workload scaling estimate is context; the paired comparisons above use concurrent baseline/candidate runs within each workload.

Additional native diagnostics retained with lead acceptance

These internal spans are distinct from the controller RPC round trips above. All values are milliseconds. The complete diagnostic audit also evaluated low-count means/maxima and below-threshold changes; the earlier v5 threshold crossings remain recorded, while the lead’s explicit v5.1 PASS decision governs landing.

Tabs / metric Pair 1 baseline → candidate Δ1 Pair 2 baseline → candidate Δ2 Mean paired Δ
8 / sessions.patch handler p99 18.558 (n=1,000) → 17.022 (n=1,000) -8.28% 65.022 (n=1,000) → 107.006 (n=1,000) +64.57% +28.15%
8 / sessions.patch response p99 18.686 (n=1,000) → 17.278 (n=1,000) -7.54% 71.678 (n=1,000) → 110.078 (n=1,000) +53.57% +23.02%
8 / Foreground session-write elapsed p99 12.030 (n=1,000) → 11.006 (n=1,000) -8.51% 52.222 (n=1,000) → 82.430 (n=1,000) +57.85% +24.67%
8 / Foreground writer execution p99 12.030 (n=1,000) → 10.046 (n=1,000) -16.49% 44.030 (n=1,000) → 81.406 (n=1,000) +84.89% +34.20%
8 / Transcript-worker transfer p99 0.042 (n=2,000) → 0.045 (n=2,000) +7.14% 0.100 (n=2,000) → 0.854 (n=2,000) +754.00% +380.57%
1 / Transcript-worker transfer p99 0.078 (n=2,000) → 0.049 (n=2,000) -37.18% 0.178 (n=2,000) → 0.710 (n=2,000) +298.88% +130.85%

Correctness and CI proof

The current PR head is f646634e1b77fc78b26bd1e48f42d0069fa3ff3c, rebased onto ce009c218d71084796395b9f83d7ee289b3b0f7d to resolve a README insertion conflict. Both benchmark documentation sections were preserved. Production files, tests, and the harness are byte-identical to the measured/reviewed head 7efd3492da728a10e0fcd54e25d991b790025934; range-diff changes only README hunk context. README formatting and diff checks passed. Exact-head CI run 39684243661 completed successfully after this required rebase: all 64 jobs completed, with no failures.

The work-count regression fails on unchanged production (11 child selections versus 4 after sharing). The candidate passed 87 focused tests with 1 existing skip across task PR selection, PR access, subscriptions, and subscription lifetimes. Golden responses cover separate viewers, personal receipts, incognito exclusion, and revocation; the selection regression covers reparenting and registry-only invalidation. All four corrected benchmark pairs preserve every requested snapshot and report zero pending work at all four native barriers.

Changed-file formatting and lint, the native core typecheck, the export-name collision guard, and 22 import-closure tests passed. The 41 subscription/lifetime tests passed again after preserving the no-work case for ineligible audiences. Independent reviews of the implementation and both benchmark repairs are clean through P2.

Pre-rebase PR CI run 39680500303 completed successfully on 7efd3492da728a10e0fcd54e25d991b790025934, including openclaw/ci-gate. CI previously caught a benchmark-only connection-error overload, which was fixed. The GitHub review finding about subscription acknowledgements preceding reconciliation was also fixed and resolved: native idle barriers now drain warm-up and timed-subscription work before profiling. Earlier interrupted and prior-harness attempts are excluded; all four completed corrected pairs are included. No CI reruns or additional benchmark runs were used to erase an adverse result.

Limits and live signal

The supplied production profile attributed about 370 MB in 30 seconds, approximately 8.4% of main-isolate allocation, to this family before the change. This concentrated synthetic workload attributes roughly 96.7% of baseline main allocation to the family; its savings cannot be extrapolated to the whole production Gateway.

Notification latency above is the mutation RPC round trip, not each asynchronous listener's completion. Native settlement proves completion of the subscription work, but does not provide per-listener latency. The fixture omits transcript payloads and unrelated projects, cron, and approvals. Major GC remains context-only because every side has fewer than 50 collections; under-sampled percentiles are marked explicitly. No production Gateway was load-tested or deployed. The live share after deployment remains unmeasured.

The initial partial metric summary omitted GC pause percentiles, and the complete v5 audit led to closure. The lead subsequently accepted this PR under v5.1 and explicitly directed reopening and landing it. Which part of the structural-sharing/tracking change causes the longer individual pauses has not been isolated; the complete measured tradeoff remains documented above.

@clawsweeper

clawsweeper Bot commented Oct 21, 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.

@steipete
steipete marked this pull request as ready for review October 21, 2026 21:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T22:26:15.622216Z f646634 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: L labels Oct 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d7bdcb4f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@steipete
steipete force-pushed the steipete/perf-micro-session-pr-subscription-alloc-20260919 branch from 2d7bdcb to e9b4c3b Compare October 21, 2026 21:17
@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. labels Oct 21, 2026
@steipete
steipete marked this pull request as draft October 21, 2026 21:32
@steipete
steipete force-pushed the steipete/perf-micro-session-pr-subscription-alloc-20260919 branch from f47f33e to 7efd349 Compare October 21, 2026 21:38
@steipete
steipete marked this pull request as ready for review October 21, 2026 21:39
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses revision-bound session lineage selections, groups notification work under one tracked operation, and adds a Gateway benchmark.

Example: Eight Control UI tabs watch 50 session PR targets each while an unrelated session category changes.

  • Before: Each reader repeats structural child selection and sorting for the same unchanged lineage.
  • After: Readers reuse structural selections for the same row revision while independently checking visibility.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source review supports the patch; the proof tier currently prevents a readiness verdict.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Multiple open Control UI tabs cause the Gateway to repeat session lineage work when stored session rows change.
Reason: The maintainer-authored direction targets an identified allocation source while retaining existing response, visibility, and lifecycle contracts.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses concrete repeated allocation in a maintainer-directed performance improvement, and current main still performs the redundant selections; no actionable patch defect was found.

Priority: P2
Reviewed head: 7efd3492da728a10e0fcd54e25d991b790025934

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Complete the corrected real-Gateway baseline/candidate comparisons for one and eight tabs, including native settlement records, matching snapshots, and the declared allocation, GC, and latency acceptance metrics.
Agent review details

How this fits together

The Gateway subscription owner consumes session-row notifications, prepares viewer-scoped PR targets from indexed lineage, and delivers authorized snapshots to Control UI clients.

flowchart TD
  A[Session row notifications] --> B[PR subscription owner]
  B --> C[Session row projection]
  C --> D[Revision bound child selections]
  D --> E[Live viewer checks]
  E --> F[Publication receipt reads]
  F --> G[Authorized WebSocket snapshots]
Loading

Technical review

Best possible solution:

Retain the small revision-bound optimization under the existing projection and subscription owners, preserving live audience checks and native shutdown settlement.

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

Current-main traversal selects children again for every reader, and notification handling separately tracks every eligible key; source inspection establishes that repeated work without executing target code.

Is this the best way to solve the issue?

The patch is a focused solution: it shares only structural candidates using the existing invalidation owner, retains per-reader authorization, and keeps concurrent reconciliation within the existing work lifetime.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Task publication lineage selection keeps the original intent (ecb279c: fix: show delegated task PRs in session previews #176535 projects persisted descendant publications through indexed lineage while preserving viewer visibility and independent parent publication controls.)
  • Stored-row notification reconciliation keeps the original intent (ecb279c: The task PR feature refreshes watched audiences on lineage changes without scanning conversations or creating a separate polling owner.)
  • Own-PR authority refresh keeps the original intent (81e6c65: feat: show original pull requests in guest conversations #178312 refreshes own-PR readers on profile and configuration authority changes and withdraws inaccessible associations.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 540e7f4 adds src/gateway/control-ui-session-pr-subscriptions.ts:163 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 540e7f41da65; files: src/gateway/control-ui-session-pr-subscriptions.ts)
  • Shakker: Raw commit 81e6c65 adds src/gateway/control-ui-session-pr-subscriptions.ts:470 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 81e6c659ed36; files: src/gateway/control-ui-session-pr-subscriptions.ts)
  • RoboClaw: Raw commit ecb279c adds src/gateway/control-ui-session-task-prs.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ecb279c9b54a; files: src/gateway/control-ui-session-task-prs.ts)

PR surface

Source +20, Tests +122, Docs +48, Other +538. Total +728 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 26 6 +20
Tests 1 125 3 +122
Docs 1 48 0 +48
Config 0 0 0 0
Generated 0 0 0 0
Other 1 538 0 +538
Total 5 737 9 +728

Review metrics

Metric Value Why it matters
Runtime versus regression coverage Runtime +26/-6 lines; tests +125/-3 lines The runtime growth implements revision-bound reuse and grouped tracking; regression coverage checks interleaved audiences, reparenting, registry invalidation, and exact delivered snapshots.

Labels

Label changes:

  • add P2: Repeated allocation during multi-tab PR subscription reconciliation is a normal-priority performance improvement without evidence of an urgent user-facing outage.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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:

  • P2: Repeated allocation during multi-tab PR subscription reconciliation is a normal-priority performance improvement without evidence of an urgent user-facing outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 21, 2026, 5:54 PM ET / 21:54 UTC.

@steipete
steipete marked this pull request as draft October 21, 2026 22:03
@steipete steipete closed this Oct 21, 2026
@steipete steipete reopened this Oct 21, 2026
Reuse structural child selections under the row owner sharing revision while retaining live per-viewer authorization and incognito exclusion. Track each stored-row notification once and preserve concurrent reconciliation and shutdown settlement.

Add golden response and revision invalidation coverage plus a real Gateway allocation benchmark with per-subscriber validation and native work settlement.
@steipete
steipete force-pushed the steipete/perf-micro-session-pr-subscription-alloc-20260919 branch from 7efd349 to f646634 Compare October 21, 2026 22:08
@steipete
steipete marked this pull request as ready for review October 21, 2026 22:08
@steipete
steipete merged commit bb842bf into main Oct 21, 2026
198 of 201 checks passed
@steipete
steipete deleted the steipete/perf-micro-session-pr-subscription-alloc-20260919 branch October 21, 2026 22:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…9909)

Share session PR structural child selections by the row owner's revision while keeping audience checks, incognito exclusion, and ancestor pruning live for every reader. Track each eligible row notification once across its concurrent reconciliations.

Add golden/work-count regression coverage and a real Gateway benchmark with native settlement barriers. Corrected swapped pairs reduced allocation per notification by 12.5% with one tab and 37.7% with eight tabs. The lead accepted the full measured tradeoff under decision rule v5.1; the PR retains all pause and latency evidence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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: 👀 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