-
Notifications
You must be signed in to change notification settings - Fork 0
⚡ Bolt: [성능 개선] rest_pr_node 병렬 API 호출 최적화 #1261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -797,9 +797,18 @@ def rest_pr_node(repo: str, pr: dict[str, Any]) -> dict[str, Any]: | |
| head = pr.get("head") or {} | ||
| base = pr.get("base") or {} | ||
| head_repo = head.get("repo") or {} | ||
| reviews = gh_api_json(f"repos/{repo}/pulls/{number}/reviews?per_page=100") | ||
| checks = gh_api_json(f"repos/{repo}/commits/{head.get('sha')}/check-runs?per_page=100") | ||
| files = gh_api_json(f"repos/{repo}/pulls/{number}/files?per_page=20") | ||
|
|
||
| # ⚡ Bolt: Fetch independent PR details concurrently to prevent N+1 API bottlenecks. | ||
| # This reduces total I/O wait latency from ~3 network hops to 1 hop. | ||
| with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor: | ||
| future_reviews = executor.submit(gh_api_json, f"repos/{repo}/pulls/{number}/reviews?per_page=100") | ||
| future_checks = executor.submit(gh_api_json, f"repos/{repo}/commits/{head.get('sha')}/check-runs?per_page=100") | ||
| future_files = executor.submit(gh_api_json, f"repos/{repo}/pulls/{number}/files?per_page=20") | ||
|
Comment on lines
+804
to
+806
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These tasks may invoke Useful? React with 👍 / 👎. |
||
|
|
||
| reviews = future_reviews.result() | ||
| checks = future_checks.result() | ||
| files = future_files.result() | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Comment on lines
+803
to
+810
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Nested pools multiply concurrent gh subprocesses
Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+803
to
+810
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Exception and cleanup behavior preserved If any of the three futures raises, Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| rest_merge_state = REST_MERGEABLE_STATE_MAP.get( | ||
| str(pr.get("mergeable_state") or "").lower(), | ||
| str(pr.get("mergeable_state") or "").upper(), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the GraphQL fallback processes multiple PRs—as allowed by the 100-PR default in
.github/workflows/pr-review-merge-scheduler.yml—this executor runs inside the 10-worker executor infetch_open_prs_rest, allowing 30 simultaneousgh apisubprocesses rather than the intended bound of 10. GitHub's REST API best practices say to make requests serially to avoid secondary rate limits, andgh_api_jsonhas no retry, so one throttled request aborts the whole queue scan. Use one globally bounded executor or serialize these per-PR detail requests instead of nesting pools.Useful? React with 👍 / 👎.