⚡ Bolt: [performance improvement] Optimize SessionTimelineChart tool rendering complexity#276
Conversation
Replaced the nested `Array.filter` O(N*M) loop inside the usageTimeline mapping with an O(N+M) two-pointer algorithm. This eliminates redundant traversals and significantly speeds up rendering for sessions with large amounts of tools and usage events.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What
SessionTimelineChart컴포넌트 내의toolCalls데이터를usageTimeline버킷에 매핑하는 알고리즘을O(N*M)의 중첩 루프(nested filter)에서, 타임스탬프 기반 정렬을 활용한O(N+M)투 포인터(two-pointer) 접근 방식으로 최적화했습니다.🎯 Why
기존의 방식은 각
usageTimeline항목마다 전체toolCalls배열을 반복 탐색하는 비효율적인 필터링(Array.prototype.filter)을 사용했습니다. 이는 도구 호출이 많거나 타임라인이 긴 대규모 세션을 렌더링할 때 심각한 병목 현상을 초래하여 메인 스레드를 블로킹하고 UI 렌더링을 지연시켰습니다.📊 Impact
O(N*M)에서 배열 정렬 오버헤드를 포함하더라도O(N log N + M log M) + O(N+M)수준으로 최적화되어, 대규모 배열 환경에서 탐색 오버헤드가 극적으로 감소합니다.🔬 Measurement
pnpm --filter @argos/web run test src/components/dashboard/session-timeline-chart.test.tsx를 실행하여 로직이 손상되지 않았음을 검증했습니다. 큰 세션 데이터로 대시보드를 로딩할 때 렌더링 병목 현상이 완화되었음을 확인할 수 있습니다.PR created automatically by Jules for task 2327614962837510269 started by @seonghobae