Skip to content

perf(gateway): skip discarded sidebar send diagnostics - #184837

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-session-row-present-round3-20261026
Oct 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-session-row-present-round3-20261026

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Sidebar and dashboard session lists derive a per-row send-disabled diagnostic, then discard it through their wire-field allowlists. This repeats even when the presented row is otherwise reusable.

User Impact

Less allocation and CPU for warm session lists. Emitted fields and current visibility/sharing outcomes are preserved. Full and compact rows still show current send restrictions; mutation authorization is unchanged.

Why This Change Was Made

Skip the discarded diagnostic at the existing presentation owner. No cache, configuration, schema, or additional owner is introduced. Production delta: +4 lines (14 added, 10 removed); the mode branch preserves the full/compact diagnostic contract while avoiding its work for summary modes. Test delta: +57 lines. Simplification pass retained only that branch and its regression.

Evidence

Acceptance declared before candidate measurements: the existing owner workload with 1,000 persisted synthetic sessions, 100-row pages, 66 in-process recipients across two identities, and 3,000 measured reads per arm. Five alternating pairs for untraced timing and five separate sampled-allocation pairs; 15,000 reads / 1.5 million presented rows per side in each mode. A consistent allocation/CPU improvement with unchanged behavior qualifies; A/A controls are required before attributing any adverse tail/GC result.

Means across the five pairs:

Metric per 100-row read Base Candidate Change
Total sampled allocation 721288 B 669561 B -7.2%
Presentation-subtree allocation 456392 B 406643 B -10.9%
Viewer-subtree allocation 103410 B 57680 B -44.2%
Main-thread CPU (untraced) 0.5109 ms 0.4626 ms -9.5%
Owner latency p50 0.4656 ms 0.4278 ms -8.1%
Owner latency p95 0.6641 ms 0.5908 ms -11.0%
Owner latency p99 0.8213 ms 0.7388 ms -10.0%
Event-loop p99 1.6038 ms 1.5567 ms -2.9%
Total GC time 0.0083 ms 0.0056 ms -33.1%

Owner latency has 3,000 samples per arm/pair; event-loop samples range from 1,269–1,928. These are local owner measurements, not WebSocket/server-handler or model-turn throughput. The lane's duplicate-work fast path applies: no whole-Gateway stress campaign or production load was run. RSS/retained heap and promotion were not measured; this adds no retained state. No adverse conclusion is drawn from short GC/tail windows, and no A/A rejection gate was invoked.

Untraced per-pair context and reproducible workload
Pair CPU ms/read base → candidate GC total ms base → candidate GC max ms base → candidate GC collections base → candidate Host load base → candidate
1 0.6361 → 0.5245 47.92 → 19.62 5.439 → 0.483 267 → 66 19.96 → 19.08
2 0.5074 → 0.4871 25.17 → 17.25 6.226 → 0.404 76 → 67 18.12 → 19.08
3 0.4899 → 0.4543 18.17 → 16.24 0.438 → 0.282 71 → 67 18.12 → 19.71
4 0.4652 → 0.4349 16.44 → 15.47 0.334 → 0.287 71 → 67 19.25 → 19.71
5 0.4560 → 0.4121 16.94 → 14.77 0.375 → 0.292 71 → 67 19.25 → 19.25

Per-kind GC totals across timing pairs: base: minor 552 collections / 112.38 ms; major 2 / 11.67 ms; fix: minor 334 collections / 83.35 ms; major 0 / 0.00 ms. Major counts are below the 50-collection gate; no separate major-GC claim. CPU fell in every timing pair, and allocation fell in every allocation pair. Base timing CPU ranged 0.4560–0.6361 ms/read; candidate 0.4121–0.5245 ms/read. The initial diagnostic profile is not included in the comparison. Two local controller errors interrupted one allocation pair and an initial timing attempt; incomplete pairs were not counted and were replaced. No completed pair or pause was trimmed.

Both revisions used the same owner substitution mechanism in the existing committed harness, to avoid comparing different TypeScript transforms:

node --expose-gc --import ./scripts/tsx.mjs scripts/perf/sidebar-presentation-measure.ts \
  --owner-file <base-or-candidate-session-row-presentation.ts> \
  --state-dir <fresh-state-directory> --output <result.json> \
  --sessions 1000 --clients 66 --operations 3000 --repeats 5 \
  --barrier-dir <fresh-barrier-directory> --side <base-or-fix>

Release barriers after both processes finish preparation, alternating AB/BA. Allocation runs additionally use --no-turbo-inlining --allocations and include objects collected by minor/major GC. The replacement fifth allocation pair used fresh fixtures and one repeat. Node v26.12.1 on macOS. The script checks stable expanded rows for each recipient after every measured window.

The new regression fails on base c00af62f03e6ab9929234a998693f53341a4e126: two unwanted diagnostic authorizations for the first two-row sidebar read. It passes with the fix, interleaves sidebar/compact/dashboard/full modes and owner/guest viewers, preserves detailed send restrictions, excludes drafts from guest reads, and proves role revocation still hides rows.

  • Focused Node run: src/gateway/session-row-presentation.test.ts and src/gateway/session-row-event-parity.test.ts, 11 tests passed; 61.51 s wrapper wall time including compilation (new regression 1.827 s). The default Bun runner crashed at startup with SIGTRAP; the supported OPENCLAW_VITEST_RUNTIME=node route passed. No Bun workaround was added.
  • Changed-file oxfmt, oxlint and git diff --check passed. Broad proof: CI run 40367542700 passed on exact head 20b93d9c0285ab43c68b52600a68372d97de02b6, including production/test typechecks, lint, selected tests, builds, and boundary checks. The post-rebase event-parity rerun also passed (49.13 s wrapper wall time).
  • Independent subagent review (autoreview route unavailable): clean at P0/P1/P2. Autoreview refused because its requested provider did not match the operator configuration; the authorized fresh-context fallback reviewed the diff and relevant sharing, publication, list, and row-field contracts. No provider configuration was changed. GitHub Codex review and ClawSweeper also completed on the exact head with no findings; ClawSweeper records the same owner-only proof limitation described above.

The pre-push rebase preserved the measured production owner byte-for-byte. Ready for maintainer review; intentionally not self-merged.

@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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T17:21:11.816553Z 20b93d9 PR opened
ℹ️ 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 size: S labels Oct 26, 2026
@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. P2 Normal backlog priority with limited blast radius. 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 Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR skips send-disabled diagnostics that sidebar and dashboard session rows already discard.

Example: A sidebar request returns 100 session rows.

  • Before: Each row computes a send-disabled diagnostic that is removed before serialization.
  • After: The same rows are returned without computing those diagnostics; compact and full rows retain them.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A small, useful patch with sound owner-level evidence and no identified defect; validation supports a narrower claim than a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored PR; supplied evidence covers the changed presentation owner through paired in-process measurements and a reported passing regression.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Repeated sidebar and dashboard refreshes spend CPU and allocation constructing diagnostics their responses omit.
Reason: The maintainer-authored direction removes demonstrated waste with a small change, preserves emitted fields, and introduces no configuration, persistence, or competing owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR makes a focused, owner-directed performance improvement absent from current main, with no actionable correctness or security findings.

Priority: P2
Reviewed head: 20b93d9c0285ab43c68b52600a68372d97de02b6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied benchmark and regression exercise the production list owner in process, without a shipped Gateway request over a real transport.
Agent review details

How this fits together

The Gateway session presenter combines resident session facts with current recipient policy and emits mode-specific rows for lists and events.

flowchart LR
  A[Session list request] --> B[Resident session projection]
  B --> C[Current visibility filtering]
  C --> D[Recipient row presentation]
  D --> E[Mode field allowlist]
  E --> F[Serialized session rows]
Loading

Technical review

Best possible solution:

Keep the mode check in the existing presenter while preserving current disclosure checks and detailed-row send restrictions.

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

Current main computes the diagnostic before applying summary-mode allowlists that remove it; the PR also reports an intended baseline regression failure, but this review ran no target code.

Is this the best way to solve the issue?

The patch removes unnecessary work at its existing owner, explicitly clears reused diagnostic state for summary modes, and preserves the original detailed-mode expression without adding machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Detailed session send restrictions keeps the original intent (3463f4b: Expose current send restrictions so composition can be disabled before a rejected send.)
  • Reusable recipient presentation facts keeps the original intent (a2b630f: Reuse one synchronous presenter's scratch object while overwriting every field and retaining scalar copies.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a2b630f adds src/gateway/session-row-presentation.ts:341 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a2b630fb35ab; files: src/gateway/session-row-presentation.ts)

PR surface

Source +4, Tests +57. Total +61 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 14 10 +4
Tests 1 57 0 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 71 10 +61

Labels

Label changes:

  • add P2: This reduces repeated work in warm session lists without changing user-visible contracts or addressing an urgent outage.
  • 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:

  • P2: This reduces repeated work in warm session lists without changing user-visible contracts or addressing an urgent outage.
  • 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.

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 26, 2026, 1:34 PM ET / 17:34 UTC.

@steipete
steipete merged commit 04cd326 into main Oct 26, 2026
134 of 135 checks passed
@steipete
steipete deleted the steipete/perf-session-row-present-round3-20261026 branch October 26, 2026 17:51
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
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: 🦐 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