Skip to content

D-29: Dialogue — performance profiling + LRU cache tuning #279

@kirich1409

Description

@kirich1409

Description

Profile Dialogue under realistic load — large transcripts, rapid token streams, long tool outputs — and tune throttling / caching / virtualization to keep UI responsive.

Spec: Epic #250 §11 Risks rows 6-7.

Scope

Scenarios

  1. Rapid token stream — mock session producing 100 text_deltas/sec for 30s. Expected: UI stays responsive, FPS ≥ 30, main-thread CPU < 50%.
  2. Long transcript — 500+ messages accumulated. Scroll performance should stay smooth (LazyVStack + .id() stability).
  3. Large tool outputBash returning 1 MiB stdout. Expected: truncation works, no UI freeze; expand to full result opens quickly.
  4. Many tool calls — 50+ tool cards in one message. Expected: card rendering stays under a frame budget.
  5. Markdown re-render — 50KB single assistant message with mixed content; streaming mode.

Instrumentation

  • Use Instruments (Time Profiler, SwiftUI instrument, Memory).
  • Add signpost markers around:
    • Parser ingest per event.
    • Reducer action processing.
    • Markdown parse + render.
    • Scroll updates.

Tuning

  • MarkdownBlockCache LRU size — default 128, verify no eviction of hot blocks under normal load.
  • Throttle frequency — 30fps default; verify perceived smoothness.
  • IdentifiedArrayOf<AgentMessage> update cost — ensure no full-array copy on textDelta.
  • Scroll virtualization — LazyVStack stability via stable .id() per message.

Escalation

If metrics fail significantly — escalate to performance-expert agent with profiling artifacts.

Acceptance Criteria

  • All 5 scenarios profiled; results documented in swarm-report (or inline in PR description).
  • Meets targets:
    • FPS ≥ 30 during streaming.
    • Main-thread CPU < 50% in scenario 1.
    • Memory growth < 100MB in scenario 2 (500 messages).
    • No visible jank when expanding / collapsing tool cards.
  • Cache hit rate ≥ 80% in scenario 5.
  • Any regressions after tuning gated via tests (e.g., throttle frequency assertion).
  • Follow-up issues filed for non-blocking perf items.

Relationships

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions