Skip to content

⚡ Bolt: 배열 콜백 및 Map 캐싱을 for 루프와 Int32Array로 대체하여 성능 개선 - #626

Closed
seonghobae wants to merge 2 commits into
developfrom
bolt/optimize-compute-task-metrics-8400071429562160809
Closed

⚡ Bolt: 배열 콜백 및 Map 캐싱을 for 루프와 Int32Array로 대체하여 성능 개선#626
seonghobae wants to merge 2 commits into
developfrom
bolt/optimize-compute-task-metrics-8400071429562160809

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

💡 무엇을

  • app.jscomputeTaskMetrics 함수 내에 있는 Array.prototype.reduceforEach를 표준 for 루프로 교체했습니다.
  • 작업의 소요 기간(durationDays)을 임시로 캐싱하기 위해 사용하던 Map 객체를 작업 인덱스 기반의 Int32Array로 교체했습니다.

🎯 왜

  • 콜백 및 GC 오버헤드 제거: 고차 배열 메서드(reduce, forEach)는 JS 엔진에서 반복마다 콜백 함수 할당 및 호출, 가비지 컬렉션(GC) 오버헤드를 발생시킵니다.
  • 해시 룩업 비용 감소: Map.set(task.id, ...)Map.get(task.id)는 내부적으로 해시 룩업을 수행하므로, O(N) 순회 시 Int32Array 인덱스 접근보다 훨씬 느립니다. 두 루프 모두 원본 state.tasks 배열을 동일한 순서로 순회하므로 인덱스를 활용하여 O(1) 메모리 오프셋 접근으로 캐시를 구현하는 것이 가장 효율적입니다.

📊 영향

  • 렌더링 사이클마다 호출되는 핫 패스(Hot Path)인 지표 계산 로직에서 JS 엔진 오버헤드가 크게 줄어듭니다.
  • 작업 항목(Task) 개수가 수천 개 이상으로 늘어나도 반복문 실행 성능이 O(N) 환경에서 훨씬 안정적으로 유지됩니다. 메모리 할당 및 가비지 발생량이 줄어들고, 지연 시간(Latency)이 크게 감소할 것으로 예상됩니다.

🔬 측정

  • npm run test:e2e 를 실행하여 기존 진행률 계산, 경고 노출 기능 등 모든 지표 산출 결과가 100% 동일한지 확인했습니다.
  • 향후 브라우저의 Performance 탭이나 console.time() 등을 통해 수천 개의 대규모 작업 트리 로드 및 수정 시 computeTaskMetrics 함수의 실행 시간이 밀리초(ms) 단위로 얼마나 감소했는지 측정할 수 있습니다.

PR created automatically by Jules for task 8400071429562160809 started by @seonghobae


Devin Review

…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.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 5 minutes.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ed4b979f-83b9-49fb-a7f4-c2d142bb7a07

📥 Commits

Reviewing files that changed from the base of the PR and between 2c32887 and d014107.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • app.js

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devin-ai-integration[bot]

This comment was marked as resolved.

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.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread app.js
Comment on lines +1375 to +1392
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];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 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.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

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 computeTaskMetrics() production boundary. Treating #508 as the canonical owner preserves the production optimization plus the stronger evidence surface. I am therefore closing #626 as a proven duplicate/superseded lane; no review thread is being marked resolved merely by this closure.

@seonghobae seonghobae closed this Aug 28, 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