⚡ Bolt: 배열 콜백 및 Map 캐싱을 for 루프와 Int32Array로 대체하여 성능 개선 - #626
Conversation
…Array in computeTaskMetrics Optimizes computeTaskMetrics in app.js by stripping out the JS callback overhead and garbage collection from Array.prototype.reduce and forEach. Replaces the slow Map hash-lookup for caching durationDays with a fast Int32Array indexed by the task array position.
|
👋 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. |
|
Warning Review limit reachedNext included review available in 5 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replaces Int32Array with Float64Array in computeTaskMetrics to ensure duration arithmetic does not suffer from silent truncation if values ever become fractional or NaN. Fixes the previous type coercion logic flaw.
| const durationCache = new Float64Array(tasksLen); | ||
| let totalDays = 0; | ||
|
|
||
| for (let i = 0; i < tasksLen; i++) { | ||
| const task = state.tasks[i]; | ||
| const duration = calculateDurationDays(task.plannedStartDate, task.plannedEndDate); | ||
| durationCache.set(task.id, duration); | ||
| return sum + duration; | ||
| }, 0); | ||
| durationCache[i] = duration; | ||
| totalDays += duration; | ||
| } | ||
|
|
||
| const baseDate = state.baseDate; | ||
| const byTask = new Map(); | ||
| let totalWeightedPlannedRatio = 0; | ||
| let totalWeightedActualRatio = 0; | ||
|
|
||
| state.tasks.forEach((task) => { | ||
| const durationDays = durationCache.get(task.id); | ||
| for (let i = 0; i < tasksLen; i++) { | ||
| const task = state.tasks[i]; | ||
| const durationDays = durationCache[i]; |
There was a problem hiding this comment.
📝 Info: Index-based cache changes duplicate-id behavior
The previous durationCache Map keyed on task.id; the new one keys on array index. For duplicate ids the old code shared one cached duration, the new code gives each task its own. Both loops iterate state.tasks in the same order, so unique-id behavior is unchanged.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Closing-path technical comparison against the current protected base and canonical performance lane:
#626 contains no unique buyer-visible or evidence-bearing delta worth carrying alongside #508, while keeping both open creates two writers for the same |
💡 무엇을
app.js의computeTaskMetrics함수 내에 있는Array.prototype.reduce와forEach를 표준for루프로 교체했습니다.durationDays)을 임시로 캐싱하기 위해 사용하던Map객체를 작업 인덱스 기반의Int32Array로 교체했습니다.🎯 왜
reduce,forEach)는 JS 엔진에서 반복마다 콜백 함수 할당 및 호출, 가비지 컬렉션(GC) 오버헤드를 발생시킵니다.Map.set(task.id, ...)및Map.get(task.id)는 내부적으로 해시 룩업을 수행하므로, O(N) 순회 시Int32Array인덱스 접근보다 훨씬 느립니다. 두 루프 모두 원본state.tasks배열을 동일한 순서로 순회하므로 인덱스를 활용하여 O(1) 메모리 오프셋 접근으로 캐시를 구현하는 것이 가장 효율적입니다.📊 영향
🔬 측정
npm run test:e2e를 실행하여 기존 진행률 계산, 경고 노출 기능 등 모든 지표 산출 결과가 100% 동일한지 확인했습니다.console.time()등을 통해 수천 개의 대규모 작업 트리 로드 및 수정 시computeTaskMetrics함수의 실행 시간이 밀리초(ms) 단위로 얼마나 감소했는지 측정할 수 있습니다.PR created automatically by Jules for task 8400071429562160809 started by @seonghobae