Skip to content

⚡ Bolt: 배열 최댓값 계산 시 reduce 및 useMemo 적용하여 성능 최적화 - #793

Open
seonghobae wants to merge 2 commits into
developmentalfrom
jules-11611458650646585268-c5b6833c
Open

seonghobae wants to merge 2 commits into
developmentalfrom
jules-11611458650646585268-c5b6833c

Conversation

@seonghobae

@seonghobae seonghobae commented Oct 11, 2026 •

Copy link
Copy Markdown

💡 What
React 컴포넌트(DelegationInsight, MembersPage, TopUsersList) 내 배열 최댓값 계산 로직에서 Math.max(...array)를 .reduce() 방식으로 변경하고, useMemo를 적용하여 렌더링 최적화를 수행했습니다.

🎯 Why
배열 크기가 클 경우 Math.max(...array) 방식은 콜 스택 초과(Maximum call stack size exceeded) 에러를 발생시킬 위험이 있습니다. 또한, 매 렌더링마다 배열 전체를 순회하며 최댓값을 구하는 계산은 컴포넌트의 성능 저하를 초래할 수 있으므로 메모이제이션이 필요합니다.

📊 Impact

  • 대용량 데이터 렌더링 시 콜 스택 오버플로우를 원천적으로 방지합니다.
  • useMemo를 통해 배열이 변경될 때만 최댓값을 다시 계산하므로 불필요한 연산을 줄이고 렌더링 성능이 향상됩니다.

🔬 Measurement
pnpm test -- --coverage 명령어를 통해 테스트 코드를 실행하여 정상 작동 여부와 커버리지를 확인합니다. 기능의 변경 없이 성능 이점이 적용되었는지 확인할 수 있습니다.


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


Devin Review

@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 Oct 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21aff85c-6cc8-481f-baf5-14bf3fd4916c

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa9201 and 6746bbb.


📒 Files selected for processing (4)
  • .jules/bolt.md
  • packages/web/src/app/dashboard/[orgSlug]/settings/members/page.tsx
  • packages/web/src/components/dashboard/reports/delegation-insight.tsx
  • packages/web/src/components/dashboard/top-users-list.tsx

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 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 2 potential issues.

Devin Review

Comment thread .jules/bolt.md
Comment on lines +1 to +3
## 2025-02-19 - 배열 최댓값 계산 시 Math.max와 스프레드 연산자 사용으로 인한 성능 및 콜 스택 이슈 해결
**Learning:** React 컴포넌트(`DelegationInsight`, `MembersPage`, `TopUsersList` 등)에서 리스트 렌더링 시 배열의 최댓값을 구하기 위해 `Math.max(...array)`를 사용하면 배열 크기가 클 때 'Maximum call stack size exceeded' 에러가 발생할 수 있습니다. 또한 매 렌더링 주기마다 무거운 동기적 계산을 반복하여 성능 저하를 초래합니다.
**Action:** 항상 `Math.max(...array)` 대신 `.reduce((max, item) => Math.max(max, item), 0)`를 사용하여 모든 크기의 데이터셋을 안전하게 처리해야 합니다. React 컴포넌트에서 이러한 파생 값을 계산할 때는 `useMemo`로 감싸 데이터가 변경될 때만 재계산되도록 하여 불필요한 렌더링을 방지해야 합니다.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Earlier optimization guidance disappears

The new lesson replaces the existing Date.parse guidance rather than adding to it. Reviewers lose the prior optimization rationale.

Devin Review


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

Comment on lines +17 to +20
const maxCount = useMemo(
() => insight.topAgents.reduce((max, a) => Math.max(max, a.callCount), 1),
[insight.topAgents],
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔍 Bounded lists weaken the performance case

The weekly agent list holds at most ten entries; overview users holds five. Neither spread-based maximum reaches argument limits, and memoization adds bookkeeping for these small reductions.

Devin Review


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

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