Repository navigation
perf(activity): avoid repeated live preview allocations - #185969
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests 0, Other +27. Total +36 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 10:51 AM ET / 14:51 UTC. |
|
Merged via explicitly authorized admin squash with prior CI and scoped validation.
|
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.
structuredCloneis 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.
pnpm tsgo:ui, targeted lint/format, production KnipThe 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 intest/scripts/lint-suppressions.test.tsand 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.
CI follow-up: UI job
122241589073(run40518880238) hit one-second polling failures in Chat Goal entry and provider-removal warning feedback (1257/1223 ms). Both exact cases pass on merge basea3fee920435and heade75f5cf428d; 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.