⚡ Bolt: [performance improvement] Reduce memory allocation in daily rollup loops#225
⚡ Bolt: [performance improvement] Reduce memory allocation in daily rollup loops#225seonghobae wants to merge 3 commits into
Conversation
- Initialize Sets/Maps outside nested loops and convert to Arrays once - Swap Object.entries with Object.keys to prevent intermediate array allocations
|
👋 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
일일 롤업 데이터(daily-rollup)를 집계하는
getDailyRollupsForProjects와aggregateSummary함수의 고부하 중첩 루프 내에서 불필요한 배열 생성 및 가비지 컬렉션(GC)을 최소화했습니다.🎯 Why
기존 코드는 매 루프마다$O(N \times M)$ 메모리 할당 패턴은 Vercel Serverless나 노드 환경에서 심각한 GC 오버헤드를 발생시킬 수 있습니다.
Set,Map구조를Array.from()으로 변환하거나Object.entries()를 호출하여 임시 튜플 배열([key, value])을 반복 생성했습니다. 롤업 데이터는 처리해야 할 행이 많은 'Hot Path'이므로, 이러한📊 Impact
activeUsersByDate,userStatsByDate)를 한 번만 초기화하고 루프가 모두 종료된 후 1회만Array로 변환하여Object.entries()대신Object.keys()를 사용하여 임시 배열 할당 비용을 없앴습니다.🔬 Measurement
@argos/web패키지의 기존vitest스위트를 통과하는지 확인하여 비즈니스 로직(집계 수치)에 변화가 없음을 검증했습니다.pnpm lint통과를 확인했습니다.PR created automatically by Jules for task 15401557976408608796 started by @seonghobae