Skip to content

perf(flow-chat): incremental segment streaming reuse in explore group (OpCase-Explore-02) - #3798

Open
Raing5Days wants to merge 2 commits into
openBitFun:mainfrom
Raing5Days:perf/explore-group-streaming
Open

Raing5Days wants to merge 2 commits into
openBitFun:mainfrom
Raing5Days:perf/explore-group-streaming

Conversation

@Raing5Days

@Raing5Days Raing5Days commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Optimize explore-group and tool collection segment rendering during active streaming ingress (FlowGroupRenderer and buildFlowGroupRenderSegments), preserving closed segment identities and height estimates on append.

  • Introduce an optional previous segment slice in buildFlowGroupRenderSegments to reuse the longest unchanged prefix of closed segments verbatim, eliminating full $O(N)$ re-slicing and height re-estimation across streaming chunk arrivals.
  • In-place reconcile the trailing active segment object so its identity survives across token/stdout chunk flushes, updating only its member array and height estimate.
  • Connect FlowGroupRenderer's renderSegments memo through a ref tracking prevSegmentsRef, preventing downstream segment maps and virtualized DOM wrappers from needlessly re-rendering for settled historical tool runs.
  • Add regression coverage in flowGroupRenderSegments.test.ts verifying that closed segment references are preserved across item appends.

Type and Areas

Performance / refactoring. Web UI FlowChat collection grouping & rendering (src/web-ui/src/flow_chat/components/modern/flowGroupRenderSegments.ts and src/web-ui/src/flow_chat/components/modern/FlowGroupRenderer.tsx). No wire protocol, persisted schema, or user-facing copy changes.

Motivation / Impact

When an exploration group runs numerous tools (e.g. 30–50+ commands or file reads) while streaming live stdout/tokens at the tail:

  • Previously, every token chunk triggered a full-collection scan from index 0, re-running estimateFlowGroupItemsHeight across dozens of completed tools and allocating new segment objects.
  • This triggered cascading re-renders in downstream segment mappers even though ~80% of earlier tool rows had already settled.

With incremental prefix reuse:

  • Streaming chunk ingress latency across 48 tools and 20 chunks dropped significantly:
    • P95 Latency: ~0.28 ms (budget ≤ 1.0 ms).
    • Max Single Frame Latency: ~2.64 ms (budget ≤ 3.5 ms).
    • Average Streaming Chunk Latency: ~0.30 ms (down from >1.2 ms).
    • Segment Reference Reuse Ratio: 95% across active streaming flushes (budget ≥ 70%).

Verification

  • node scripts/run-vitest.mjs run --maxWorkers=50% "src/flow_chat/components/modern/flowGroupRenderSegments.test.ts" — 2 passed (100%).
  • node scripts/run-vitest.mjs run --maxWorkers=50% "src/flow_chat/components/modern/FlowGroupLifecycle.test.tsx" --environment jsdom — 18 passed (100%).
  • node .perf-harness/perf-agent-runner.mjs --case OpCase-Explore-02 — passed: true, reuseRatio: 0.95, p95: 0.28ms.
  • git diff --check — clean, no whitespace or formatting defects.

Checklist

  • Focused changes; no scratch files, secrets, or unrelated generated artifacts.
  • Relevant verification and test results are recorded above.
  • Preserves thinking continuation, capsule grouping boundaries, and existing height estimation contracts.

@Raing5Days Raing5Days changed the title perf(flow-chat): preserve closed segment identities during streaming ingress perf(flow-chat): incremental segment streaming reuse in explore group (OpCase-Explore-02) Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant