Skip to content

perf(gateway): skip discarded session event entries - #184097

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-stream-session-broadcast-20260919
Oct 26, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-stream-session-broadcast-20260919

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Streaming session events allocate entry tuples for every envelope field, including fields immediately discarded because the client uses session field references or omits the message body.

User Impact

Lower allocation and CPU in session-event projection, with identical wire payloads and unchanged live recipient authorization, delivery histories, and negotiated capabilities.

Why This Change Was Made

This builds on #183877, which shares row field ordering per audience. Filter property names before constructing retained entries. This removes temporary tuples for omitted fields without introducing a cache or another delivery path. Object.fromEntries continues to preserve property order and own __proto__ data properties. Runtime production LOC is unchanged; the added script is a reproducible owner benchmark.

Evidence

Predeclared benchmark acceptance: identical payload digest with lower allocation and CPU. The committed scripts/perf/session-event-envelope-measure.ts exercises the real projector and delivery planner with 65 synthetic recipients, mixed capabilities, staggered delivery histories, and changing row fields. Presentation is mocked; this is owner-level evidence, not whole-Gateway or authorization measurement.

Base: a5bfe043a403c8af06eaf03a454070347182e96f. Five interleaved runs per revision and measurement mode; 200 warm-up events and 3,000 measured events per run. Node 26.12.1 on macOS. CPU comes from process.threadCpuUsage; allocations use a separate V8 sampling pass including collected objects. Hashing runs in a separate replay.

Metric per 3,000 events Base median (range) Candidate median (range) Change
Main-thread CPU 2,025.8 ms (2,016.1–2,068.5) 1,785.7 ms (1,732.6–1,818.2) −11.8%
Sampled allocation 6.754 GB (6.741–6.763) 4.703 GB (4.689–4.707) −30.4%

One-minute host load ranged 27.7–32.3 in timing passes and 27.6–32.0 in allocation passes. All twenty runs produced payload digest 29b096a2c33c7144c68e753b80a7c7ee19a26f1e938bcde0b5e2d5a73b19128d.

The existing audience regression fails on the base with four discarded-envelope enumerations and passes with zero after the change. It covers interleaved histories, legacy/delta/reference clients, and mid-broadcast revocation; it also checks own __proto__ data survives. Existing publication-authority snapshots cover exact wire strings, sharing changes, child visibility, and incognito exclusion.

Validation: 27 focused tests passed across the audience, publication-authority, eager-import-closure, and PR-wrapper-source-closure files. Gateway test execution was 1.6 s for the changed audience file and under 5 s for publication-authority; wrapper startup/compiler preparation dominates wall time. The final audience rerun passed in 39.3 s wall time. Changed-file formatting/lint and the export-collision guard passed. Initial CI found invalid benchmark fixture types; the fixture now uses explicit typed row values, a string lifecycle revision, and structured assistant-message preview. The script typecheck passes, the fixture repair received a clean independent review, and all benchmark numbers above were rerun with the corrected fixture. Independent subagent review: clean, no actionable P0–P2 findings (autoreview route unavailable because its provider selector did not match the operator configuration). No whole-Gateway latency, GC, or retained-memory improvement is claimed. The lane's explicit fast-path exception applies to this allocation-only rewrite; no long Gateway stress campaign was run.

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

@steipete
steipete marked this pull request as ready for review October 26, 2026 02:16
@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-26T02:33:13.448166Z 8b7b3a3 New commits
ℹ️ 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: M 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. labels Oct 26, 2026
@steipete
steipete force-pushed the steipete/perf-micro-stream-session-broadcast-20260919 branch from 8d40af0 to 8b7b3a3 Compare October 26, 2026 02:31
@steipete
steipete merged commit 1a905c7 into main Oct 26, 2026
124 of 125 checks passed
@steipete
steipete deleted the steipete/perf-micro-stream-session-broadcast-20260919 branch October 26, 2026 02:44
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
* perf(gateway): skip discarded session event entries

* fix(perf): use valid session row benchmark fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant