Skip to content

perf(ui): reduce sidebar allocations during live session updates - #179134

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-ui-sidebar-presentation-revisions-20260919
Oct 21, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-ui-sidebar-presentation-revisions-20260919

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Control UI sidebar allocated a full presentation JSON string on every admitted update, including updates that left the screen unchanged.

User Impact

Busy sessions incur less sidebar allocation work while retaining the same notification suppression and visible updates. No configuration or migration is required.

Why This Change Was Made

The existing projection memos now expose visible revisions. They replace their snapshots when sources change, but only advance the revision when the visible result changes. The publication gate consumes those revisions and shared metadata instead of serializing the whole presentation and copying every row. Keeping the latest snapshot also avoids retaining obsolete hidden children after an equivalent replacement.

Plugin navigation retains its public mutation contract: host.ui.invalidate() advances an internal plugin revision, and navigation is fingerprinted once per plugin publication. Gateway hello retains its handshake identity; its presentation snapshot changes with the capability publication.

Evidence

Acceptance, written before implementation: run the committed renderer workload separately with sidebar live churn and session event churn; substantially reduce sampled allocated bytes/event while publication/render counts stay unchanged or lower and user-facing latency does not regress by more than 20%. Five concurrent matched baseline/candidate pairs per scenario swap their two 16-CPU halves. Compare paired differences; report median and p95. Allocation samples include objects collected by minor and major GC. Cold readiness and the warm live window are separate.

All ten allocation pairs completed successfully. The owner-level reduction is about one-third; whole-renderer savings are smaller but consistent in every pair. Values below are sampled allocated bytes/event, including collected objects. Each scenario has five concurrent pairs; p95 uses nearest rank (the maximum at n=5). Paired deltas are candidate minus baseline within each pair, not differences between the two marginal medians.

Workload / allocation scope Baseline median / p95 Candidate median / p95 Paired median delta
Sidebar live churn / whole renderer 4,822,243 / 4,907,591 4,663,961 / 4,725,682 -180,103 (-3.68%)
Sidebar live churn / publication gate stack 378,325 / 396,462 252,495 / 256,071 -122,593 (-32.68%)
Session event churn / whole renderer 5,586,552 / 5,639,093 5,247,162 / 5,326,119 -339,391 (-6.08%)
Session event churn / publication gate stack 1,060,910 / 1,063,963 706,446 / 726,815 -342,362 (-32.70%)

Sidebar gate bytes/admission fell from 1,125,968 / 1,179,947 median/p95 to 751,474 / 762,116. Session-event gate bytes/admission equal bytes/event because every event reached the gate. Whole-renderer paired reductions ranged from 1.79–4.96% for sidebar churn and 3.89–7.43% for session events.

Workload Events/run Gate admissions, baseline → candidate Publications and each invalidate/prepare/commit count, baseline → candidate
Sidebar live churn 125 42 → 42 28 → 28
Session event churn 240 240 → 240 10 → 10

These counts are exact in every pair. The session workload still suppresses 230 of 240 admitted events. Final synthetic sidebar state and layout match in both scenarios.

Timing: allocation-profiled paired median ScriptDuration changes were +1.72% / +1.01%, and TaskDuration +3.36% / +3.93%, for sidebar/session churn respectively. Persisted-snapshot reload readiness, measured before allocation sampling, changed by paired medians -3.47% / +4.04%. One sidebar pair increased p95 event-delivery lateness by 10.1 ms and long-task blocking by 17 ms. Two additional swapped, non-allocation sidebar pairs retained all counts and had zero long tasks on both sides. Their delivery-lateness p95 fell in both pairs (median 37.20 → 36.95 ms); ScriptDuration changed by paired median +1.87% and TaskDuration +3.00%. The sustained p95/long-task signal did not reproduce, although one maximum-delivery outlier remained +10.5 ms. These two diagnostic pairs do not establish a general latency distribution or per-event DOM settlement.

The exclusive measurement lock covered all pairs, with baseline and candidate running concurrently on separate 16-CPU halves, swapped each pair. Recorded CPU busy averages across the selected 32 CPUs ranged from 2.86–38.46% over live windows; this includes the benchmark and outside work and is context, not an exclusion rule.

Measurement identity: baseline source ef6d500b534062f352aa6d7ceef01c97d907c511; candidate is that same source plus the final lane production change. This is a controlled source comparison, not a complete build of the later rebased PR head. The comparator/projection remained byte-identical through rebase; exact-head PR CI validates the integrated change. Bundle SHA256: baseline 090c4e15c60614d90b4ec30cc3831e17e46e26e93f42f63557e912b442982ebe, candidate 5dde253e2c5059ab3e5651b9239095473b28c072cae329872d730431ac0aaeb8 (digest of sorted relative paths and file-content hashes).

Allocation/render acceptance passes: a substantial gate allocation reduction, consistent whole-renderer reduction, and no extra publications or renders. Per-event time to settled/painted DOM was not instrumented, so the original additional >20% user-facing latency guard remains unproven. Event-delivery lateness and aggregate CPU are proxies, not settlement latency; the fixed drain window is not used as a response-time metric.

Focused validation: 142 tests passed across eleven focused UI/browser files covering projection, memoization, plugin runtime, chat replacement fixtures, presence, catalog events, session events, narration retries, row/facepile rendering, plugin Pages identity, and serialized browser-probe restoration. After the final revision cutover, the two projection files passed again (34 tests). pnpm tsgo:ui, changed-file formatting, and changed-file lint passed. Exact-head CI run 39557024421 passed on b21130c0c87bf2647b48293926fe5abc2d0823a5, including openclaw/ci-gate; all 57 PR checks passed. No Testbox lease or local build/dev server was used.

Focused proof commands
node scripts/run-vitest.mjs ui/src/components/app-sidebar.projection-memo.test.ts ui/src/components/app-sidebar-session-projection.test.ts ui/src/plugins/control-ui-runtime.test.ts ui/src/pages/chat/components/chat-message-group.solid.test.tsx --maxWorkers=1
node scripts/run-vitest.mjs ui/src/components/app-sidebar-online.test.ts ui/src/components/app-sidebar.catalog-events.test.ts ui/src/components/session-data-controller-events.test.ts --maxWorkers=1
node scripts/run-vitest.mjs ui/src/components/app-sidebar-session-narration-retry.test.ts ui/src/components/app-sidebar-session-row-render.test.tsx --maxWorkers=1
node scripts/run-vitest.mjs ui/src/components/app-sidebar-pages-identity.test.ts --maxWorkers=1
node scripts/run-vitest.mjs ui/src/components/app-sidebar.projection-memo.test.ts ui/src/test-helpers/control-ui-cold-load-probes.browser.test.ts --maxWorkers=1
pnpm tsgo:ui

The committed workload is node --import ./scripts/tsx.mjs scripts/bench-control-ui-cold-load.ts --runs 1 --allocations --untraced --live-events --fixture-now-ms 1792569600000 --live-start-at-ms <shared-epoch-ms>, with --sidebar-live-churn and --session-event-churn in separate runs, separate --bundle-dir/--output paths and isolated loopback ports. Diagnostic pairs omit --allocations. This exercises the production renderer bundle with synthetic transport; it does not establish real Gateway transport performance or native/other-isolate allocations. The optional real-transport cross-check was not run.

Production UI delta: +125 lines (189 added, 64 removed). The retained growth preserves semantic suppression across equivalent replacements and the mutable plugin boundary while reusing the existing memo owner. Benchmark instrumentation adds 73 lines; tests add 70 lines. No new source module, dependency, schema, configuration option, or fallback path.

Initial CI caught two fixtures mutating readonly rows, a plugin registry fixture that did not advance its revision, a browser-probe fixture missing the publication-gate method, and two object-index type assertions. The fixtures now follow their owner contracts, the assertions are removed, and the affected tests passed locally with their original behavior assertions preserved. The plugin-removal failure was reproduced locally before its repair.

Independent Codex review: scoped clean at P0–P2 on the complete implementation and fixture repair, and the final comparator/probe repair. All reviews returned no actionable findings.

Before and after the same synthetic sidebar live-event workload (baseline, then candidate). The final visible sidebar state and layout are preserved.

Before: baseline after synthetic sidebar live churn

After: candidate after synthetic sidebar live churn

@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 in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 21, 2026 06:19
@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-21T06:46:38.244963Z b21130c 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 app: web-ui App: web-ui scripts Repository scripts size: M labels Oct 21, 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 21, 2026
…zation

Preserve visible-state suppression through source-owned projection memos and explicit plugin publication revisions. Remove per-frame row copies and full-presentation JSON allocation. Extend the renderer benchmark with collected-object allocation sampling and publication/render counters.
@steipete
steipete force-pushed the steipete/perf-micro-ui-sidebar-presentation-revisions-20260919 branch from 54ecad4 to b21130c Compare October 21, 2026 06:41
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The repaired head is b21130c0c87bf2647b48293926fe5abc2d0823a5. Exact-head CI is green, the independent reviews are clean, and the PR body now contains the final ten-pair allocation results, two timing diagnostics, source identities, limitations, focused proof, and inspected synthetic before/after screenshots. Publication-gate allocations fell about 32.7% in both workloads with identical publication/render counts; whole-renderer allocations fell by paired medians of 3.7% and 6.1%.

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 8a207cc into main Oct 21, 2026
122 checks passed
@steipete
steipete deleted the steipete/perf-micro-ui-sidebar-presentation-revisions-20260919 branch October 21, 2026 07:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
…nclaw#179134)

* perf(ui): publish sidebar presentation revisions without full serialization

Preserve visible-state suppression through source-owned projection memos and explicit plugin publication revisions. Remove per-frame row copies and full-presentation JSON allocation. Extend the renderer benchmark with collected-object allocation sampling and publication/render counters.

* test(ui): publish sidebar fixture snapshots through their owners

* fix(ui): keep sidebar comparisons and probe fixtures type safe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant