Skip to content

perf(activity): avoid repeated live preview allocations - #185969

Merged
steipete merged 3 commits into
mainfrom
solid2/w-perf-activity-live
Oct 27, 2026
Merged

steipete merged 3 commits into
mainfrom
solid2/w-perf-activity-live

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large bursts of tool output stall Activity Live, especially with multilingual text. Profiling identifies repeated per-code-point preview copies as the largest named product hotspot in the 2,800-event workload.

User Impact

Activity Live handles large bursts of tool output with less main-thread work while preserving every retained preview and disclosure. There are no configuration changes.

Why This Change Was Made

Reuse the already-owned preview when all its retained text is equal. For changed text, materialize only the bounded preview with a JSON string round trip. Keep exact UTF-16 content (including lone surrogates), immutable snapshots, the 100-row cap, event order, existing keyed rows, filters, and disclosure behavior. structuredClone is intentionally not used: an isolated 64 × 512 KiB sliced-string probe retained 33.6 MB with it versus 141 KB with the JSON copy; the existing regression also verifies large payload release.

The benchmark now stages its multi-megabyte Playwright argument before timing, then sends the identical 2,800 Gateway events inside the measured interval. The original Unicode 4× trace's 2.04 s task included substantial automation argument decoding; staging reduced the unchanged-base task to 601 ms. Base and head comparisons use the same corrected workload. No product events are deferred, dropped, or coalesced.

Evidence

Acceptance: twenty serial interleaved base/head pairs plus an unchanged-base control at 4×, and ten pairs per engine at 1×; median regression ≤5% and p95 not worse, with CPU and structural counts on a noisy host. Goal is a <200 ms task at 4×; a clean measured win can land below that goal. Synthetic production renderer only, not provider or network latency.

Check Result
Plain, 4×, 20 pairs: script CPU median / p95 343.26 / 368.62 → 224.42 / 277.50 ms (-34.6% median)
Plain: longest task median / p95 397.5 / 424.0 → 269.5 / 330.0 ms
Changed, 4×, 20 pairs: script CPU median / p95 340.49 / 420.88 → 239.29 / 277.14 ms (-29.7% median)
Changed: longest task median / p95 386.5 / 485.0 → 290.5 / 335.0 ms
Unicode, 4×, 20 pairs: script CPU median / p95 421.51 / 511.17 → 258.43 / 282.42 ms (-38.7% median)
Unicode: longest task median / p95 496.5 / 604.0 → 332.0 / 378.0 ms
Chromium plain, 1×, 10 pairs: wall median / p95 128.49 / 157.39 → 111.85 / 142.17 ms (-13.0% median)
WebKit plain, 1×, 10 pairs: wall median / p95 216.12 / 266.48 → 165.55 / 180.70 ms (-23.4% median)
Chromium changed, 1×, 10 pairs: wall median / p95 140.75 / 145.67 → 124.24 / 143.88 ms (-11.7% median)
WebKit changed, 1×, 20 pairs: wall median / p95 220.94 / 249.14 → 165.38 / 194.37 ms (-25.1% median)
Chromium unicode, 1×, 10 pairs: wall median / p95 278.47 / 325.10 → 245.39 / 307.57 ms (-11.9% median)
WebKit unicode, 1×, 10 pairs: wall median / p95 446.63 / 478.25 → 345.23 / 451.88 ms (-22.7% median)
Row creation / retained cap 100 / 100 on both
UTF-16, changed last code unit, immutable snapshot, 32 MiB payload release 7 focused tests passed
pnpm tsgo:ui, targeted lint/format, production Knip Passed
Suppression allowlist correction Exact failed test file: 14 tests passed
Production build + strict base/head performance check Passed
Startup JS gzip 90,246 → 90,235 B (−11 B; build variance)
Startup CSS 1 request, 32,745 B gzip on both

The 180 Chromium 4× observations all passed. The unchanged A/A controls show tail noise on this shared host (load 26–40 in the first run), so the decision uses twenty pairs of thread CPU plus stable structural counts. CPU and task median/p95 improve in every workload. All 210 cross-engine observations passed (ten pairs per cell, twenty for WebKit changed content after a tail outlier); median and p95 wall time improved in every cell. Six separate WebKit trace observations and six focused search/update/expanded-scroll observations also passed. WebKit Timeline script elapsed time fell from 285 to 196 ms for the Unicode action in the diagnostic trace; trace overhead is not mixed into the wall-time comparison. WebKit CPUProfiler utilization was not used as action CPU. Current WebKit/Chromium wall ratios remain about 1.4–1.5×, above the 1.3× goal. The harness has no supported WebKit 4× throttle. The numeric <200 ms target is not yet reached; remaining work is event delivery/parsing and layout, not preview preparation.

Independent review: local Codex autoreview of the complete local diff against a3fee920435, P0–P2, scoped-clean. The reviewer assessed the supplied diff; unchanged source and execution were outside that review. A later comment documents the lint exception; no runtime change followed review. CI caught its missing explicit allowlist entry; the two-line correction passed all 14 tests in test/scripts/lint-suppressions.test.ts and a second scoped-clean P0–P2 autoreview. Author simplification retained one existing owner and removed no public contracts.

LOC: production 225 → 234 (+9), Activity tests 144 → 142 (−2), suppression allowlist +2 lines, benchmark 630 → 657 (+27). Net test-line growth is zero; the test-line ratchet passes without changing its ceiling. No Solid rendering/lifecycle mechanisms added, no startup imports or dependencies changed. The existing entity-keyed renderer already creates exactly the capped 100 rows, so this fix does not add a virtualizer or another reconciliation layer.

Visual proof

Inspected synthetic production captures, same plain first-render state; only clock/duration differ. The expanded Unicode captures below also preserve the complete multilingual preview. No real user data or credentials.

Before: Activity Live with 100 synthetic tools

After: same Activity Live state and retained rows

Before: expanded Unicode preview

After: exact Unicode preview retained
CI follow-up: UI job 122241589073 (run 40518880238) hit one-second polling failures in Chat Goal entry and provider-removal warning feedback (1257/1223 ms). Both exact cases pass on merge base a3fee920435 and head e75f5cf428d; the latest completed scheduled main UI shards also pass. This does not qualify as inherited-failure evidence. One targeted job rerun was requested as a diagnosed timing flake, then superseded by the required test-line-budget correction; the original failures remain an unresolved test-timing limitation, not a claimed code fix.

Test-line CI correction: removed newly added cases already covered by the existing production Unicode/changed-output workloads, plus two redundant assertions. The retained first-row and tail-equality assertions still prove the complete 100-row result, and child exit status still rejects every failed retention probe. The final seven Activity tests and the test-line ratchet pass; a third scoped P0–P2 review found no actionable issue. Production code and the recorded timings are unchanged.

Final-head CI: run 40522699972 completed successfully on 9916aa9cc13 (56 successful checks, no pending or failed checks). Earlier UI polling failures remain documented above; they are not being used as inherited-failure evidence.

@clawsweeper

clawsweeper Bot commented Oct 27, 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 app: web-ui App: web-ui scripts Repository scripts labels Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T14:38:11.770788Z 9916aa9 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.

@steipete
steipete enabled auto-merge (squash) October 27, 2026 14:20
@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 27, 2026
@steipete
steipete disabled auto-merge October 27, 2026 14:35
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses unchanged Activity previews, copies changed previews more cheaply, and excludes automation argument decoding from benchmark timing.

Example: Activity Live receives 2,800 multilingual tool events across 20 sessions.

  • Before: Every output update materializes another preview through a per-code-point array.
  • After: Equal previews reuse retained text, while changed previews receive a bounded JSON string copy and the newest 100 rows remain visible.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, coherent optimization with inspected browser evidence and reported interleaved measurements; evidence remains scoped to synthetic renderer workloads.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; inspected browser captures show preserved Activity rows and multilingual disclosures, while supplied Chromium/WebKit measurements exercise the production renderer with synthetic Gateway events.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large tool-output bursts make Activity Live stall, especially with multilingual output.
Reason: The maintainer-authored direction delivers reported cross-engine improvements through a small owner-local change while preserving the existing display contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a focused Activity Live performance improvement while preserving preview ownership and content, with no actionable defect found; required CI remains pending.

Priority: P2
Reviewed head: 9916aa9cc137dd35a9fd99126b6da2a3fb4850cc

Before merge

None.

Findings

None.

Agent review details

How this fits together

The browser-local Activity owner consumes subscribed tool and answer-candidate events and produces bounded immutable entries for the Control UI renderer.

flowchart LR
  A[Subscribed Gateway events] --> B[Live Activity owner]
  B --> C[Parse activity event]
  C --> D[Prepare bounded preview]
  D --> E[Newest 100 entries]
  E --> F[Activity Live renderer]
Loading

Technical review

Best possible solution:

Retain the optimization in the existing preview owner and complete the normal exact-head CI gates.

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

Current-main source shows the repeated preview allocation directly, and the supplied benchmark reports exercise it at volume; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change removes unnecessary copies at the existing owner, preserves exact bounded text and snapshot behavior, and adds no parallel production mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Owned bounded preview copying keeps the original intent (98ebcc4: Prevent a short retained Activity preview from keeping a large discarded tool result alive.)
  • Activity Live benchmark workload keeps the original intent (5bb1c40: Exercise realistic live-event volume, exact previews, retention, and disclosure behavior through the production renderer.)
  • Existing regression assertions keeps the original intent (b229935: Consolidate low-value test repetition while retaining distinct behavioral coverage; remaining exit-status and full-tail assertions cover the two removed assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 98ebcc4 adds ui/src/pages/activity/tool-activity.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 98ebcc460f71; files: ui/src/pages/activity/tool-activity.ts)
  • Val Alexander: Raw commit 3dd0e8e adds ui/src/ui/activity-model.ts:120 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 3dd0e8ed6a7c; files: ui/src/ui/activity-model.ts)

PR surface

Source +9, Tests 0, Other +27. Total +36 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 13 4 +9
Tests 2 2 2 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 42 15 +27
Total 4 57 21 +36

Labels

Label changes:

  • add P2: Reduces browser main-thread work during large Activity Live bursts without changing configuration or public contracts.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Reduces browser main-thread work during large Activity Live bursts without changing configuration or public contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 27, 2026, 10:51 AM ET / 14:51 UTC.

@steipete
steipete merged commit 5f3b3eb into main Oct 27, 2026
133 of 134 checks passed
@steipete
steipete deleted the solid2/w-perf-activity-live branch October 27, 2026 15:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with prior CI and scoped validation.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
)

* perf(activity): avoid repeated live preview allocations

* test(activity): register bounded preview copy exception

* test(activity): keep preview proof within the line budget
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 P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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