⚡ Bolt: [성능 개선] exportPrisma O(N*C*E) 중첩 루프를 O(N*C + E) 맵 조회로 최적화 - #847
⚡ Bolt: [성능 개선] exportPrisma O(N*C*E) 중첩 루프를 O(N*C + E) 맵 조회로 최적화#847seonghobae wants to merge 4 commits into
Conversation
|
👋 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 reached
Next review available in: 31 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughPrisma exporter가 외래 키 관계 정보를 필드 키 기반 ChangesPrisma 관계 조회 최적화
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.jules/bolt.md (1)
80-82: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win최적화 학습에 근거 자료를 추가하세요.
이 문서는 알고리즘 복잡도와 최적화 방법을 규정하지만 관련 학술 문헌의 전체 인용, 링크, 요약을 제공하지 않습니다. 성능 주장을 뒷받침하는 자료를 문서 또는 PR 설명에 추가하세요.
As per coding guidelines: “Substantive feature or process pull requests should be grounded in relevant academic literature, attaching permissible paper PDFs with full citations or otherwise providing citations, links, and summaries.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.jules/bolt.md around lines 80 - 82, Update the “Optimize O(N*C*E) Nested Loop in Prisma Exporter” section of .jules/bolt.md to include supporting academic references for the stated complexity analysis and identifier-based Map optimization, with full citations, links, and concise summaries; if permissible, attach the relevant paper PDFs as required by the coding guidelines.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/erd/prisma.ts`:
- Around line 62-63: Update the Prisma exporter around edgesProcessedByField in
frontend/src/erd/prisma.ts: pre-index each node’s columns so the Edge-level
columns.find lookup is removed and the implementation achieves O(N*C + E);
alternatively, document the actual O(N*C + E*C) complexity instead. Update
.jules/bolt.md lines 80-82 to claim O(N*C + E) only if the exporter is changed
to provide that guarantee; otherwise revise the documented complexity to match
the implementation.
- Around line 97-100: Update the relationship processing around
edgesProcessedByField so multiple edges sharing a source model and field are not
silently overwritten; either deduplicate them at field level or retain a per-key
collection and generate every relation consistently with
incomingRelationsByNode. Align the Prisma relation field normalization with FK
handling by applying the same src-/tgt- prefix removal used by sanitizeHandleId
before sanitizing edge.sourceHandle, ensuring identical columns resolve to the
same model and field.
---
Nitpick comments:
In @.jules/bolt.md:
- Around line 80-82: Update the “Optimize O(N*C*E) Nested Loop in Prisma
Exporter” section of .jules/bolt.md to include supporting academic references
for the stated complexity analysis and identifier-based Map optimization, with
full citations, links, and concise summaries; if permissible, attach the
relevant paper PDFs as required by the coding guidelines.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9543f59d-6089-412a-b09a-d6c595cf3f2c
⛔ Files ignored due to path filters (1)
frontend/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
.jules/bolt.mdfrontend/src/erd/prisma.ts
|
@coderabbitai review Please review exact head |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
expected='2f95b8ec68c672473b978fe559bdee4ae01f85e2'
actual="$(git rev-parse HEAD)"
printf 'HEAD=%s\nEXPECTED=%s\n' "$actual" "$expected"
git status --short
git show --no-ext-diff --format=fuller --stat "$expected"
git diff --no-ext-diff "$expected^" "$expected" -- frontend/src/erd/prisma.ts .jules/bolt.md
printf '\n--- Candidate Prisma files ---\n'
fd -t f -i 'prisma' frontend || true
printf '\n--- Exporter outline ---\n'
ast-grep outline frontend/src/erd/prisma.ts --items all --view expanded || true
printf '\n--- Related test definitions and calls ---\n'
rg -n -C 3 --glob '*.{test,spec}.{ts,tsx}' \
'(exportPrisma|Prisma)' frontend || trueLength of output: 20509 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Handle utility outline and implementation ---'
ast-grep outline frontend/src/erd/handleUtils.ts --items all --view expanded
cat -n frontend/src/erd/handleUtils.ts
printf '%s\n' '--- Prisma exporter ---'
sed -n '1,280p' frontend/src/erd/prisma.ts | cat -n
printf '%s\n' '--- Prisma tests ---'
sed -n '1,380p' frontend/src/erd/__tests__/prisma.test.ts | cat -n
printf '%s\n' '--- Parent exporter implementation ---'
git show '2f95b8ec68c672473b978fe559bdee4ae01f85e2^:frontend/src/erd/prisma.ts' | sed -n '1,280p' | cat -n
printf '%s\n' '--- Handle construction and edge creation sites ---'
rg -n -C 4 --type ts --type tsx \
'(sourceColumnHandleId|targetColumnHandleId|sourceHandle\s*:|targetHandle\s*:)' frontend/src
printf '%s\n' '--- Column-name validation or normalization ---'
rg -n -C 3 --type ts --type tsx \
'(column_name|sanitizeHandleId)' frontend/src/erd \
-g '!frontend/src/erd/prisma.ts' \
-g '!frontend/src/erd/__tests__/prisma.test.ts'Length of output: 30408 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Edge handle construction and assignments ---'
rg -n -C 4 \
-g '*.{ts,tsx}' \
'(sourceColumnHandleId|targetColumnHandleId|sourceHandle\s*:|targetHandle\s*:)' \
frontend/src
printf '%s\n' '--- ERD column-name producers and normalization ---'
rg -n -C 3 \
-g '*.{ts,tsx}' \
'(column_name|sanitizeHandleId)' \
frontend/src/erd \
-g '!frontend/src/erd/prisma.ts' \
-g '!frontend/src/erd/__tests__/prisma.test.ts'
printf '%s\n' '--- Changed Prisma tests ---'
git diff --no-ext-diff \
'2f95b8ec68c672473b978fe559bdee4ae01f85e2^' \
'2f95b8ec68c672473b978fe559bdee4ae01f85e2' \
-- frontend/src/erd/__tests__/prisma.test.ts CHANGELOG.md
printf '%s\n' '--- Existing PR review comments ---'
gh api \
'repos/ContextualWisdomLab/pg-erd-cloud/pulls/847/comments?per_page=100' \
--jq '.[] | {id, user: .user.login, path, line, body, commit_id}' || true
printf '%s\n' '--- Existing PR issue comments ---'
gh api \
'repos/ContextualWisdomLab/pg-erd-cloud/issues/847/comments?per_page=100' \
--jq '.[] | {id, user: .user.login, body, created_at}' || trueLength of output: 116573
I found no new actionable issues. The column index matches the canonical handle format from
|
|
Current exact head The current CI failure is separately in two known timing-sensitive |
Add missing test expectation awaits to `App.coverage.test.tsx` and fix unhandled promise rejection error caused by Node 26's strict asynchronous execution.
|
Closing as superseded by draft #700 at exact head |
Understood. The changes will not be merged here. |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
💡 무엇을 (What):
exportPrisma함수 내부에서 각 컬럼을 순회할 때마다 생성된 Edge를 찾는 중첩 루프(배열 순회) 로직을 제거하고, 대신 O(1) 해시 맵(edgesProcessedByField) 조회를 사용하도록 리팩터링했습니다.🎯 왜 (Why):$O(N \cdot C \cdot E)$ 의 시간 복잡도를 가졌습니다. 이로 인해 다이어그램 크기가 커질수록 Prisma 스키마 내보내기 성능이 심각하게 저하되는 병목 현상이 발생했습니다.
이전 방식은 노드(N), 컬럼(C), 그리고 엣지(E)의 갯수에 비례하여
📊 예상 영향 (Impact):$O(N \cdot C + E)$ 로 낮춰 대규모 데이터베이스 구조에서도 빠른 추출 성능을 기대할 수 있습니다.
Prisma 내보내기의 시간 복잡도를
🔬 검증 방법 (Measurement):
pnpm run test를 통해 리팩터링 후에도 기존 로직과 동일하게 작동하며 어떠한 부작용도 발생하지 않음을 검증했습니다.PR created automatically by Jules for task 372933566554818287 started by @seonghobae
Summary by CodeRabbit
성능 개선
문서
Exact-head remediation
Head
2f95b8ec68c672473b978fe559bdee4ae01f85e2closes both current review findings. Node columns are pre-indexed by canonical handle/name, outgoing relations are stored per source field without overwrite, and output lookup is O(N*C + E). Test-first evidence: canonical handles and two relations sharing one source field produced no relation objects before the fix; focused Prisma tests now pass 9/9. Full frontend rerun: 27 files / 198 tests passed; typecheck and production build passed.