Skip to content

⚡ Bolt: PR 스케줄러의 N+1 API 호출 병렬화로 성능 개선 - #214

Merged
opencode-agent[bot] merged 1 commit into
mainfrom
perf/parallelize-api-calls-10202448684912064396
Jun 30, 2026
Merged

opencode-agent[bot] merged 1 commit into
mainfrom
perf/parallelize-api-calls-10202448684912064396

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

이 PR은 PR Review Merge Scheduler 스크립트(scripts/ci/pr_review_merge_scheduler.py) 내에 존재하는 여러 N+1 GitHub API 호출 병목 현상을 해결하여 스크립트 실행 속도를 크게 개선합니다.

💡 내용

다음 세 가지 작업에 대해 concurrent.futures.ThreadPoolExecutor를 사용하여 병렬 처리를 도입했습니다.

  1. GraphQL API를 사용할 수 없을 때 REST API로 각 PR 상태를 가져오는 fetch_open_prs_rest 함수.
  2. 여러 개의 만료된 리뷰 쓰레드를 일괄적으로 해결하는 resolve_outdated_review_threads 함수.
  3. 동일한 PR에 대해 기존에 실행 중이던 오래된 OpenCode workflow 실행들을 취소하는 cancel_stale_opencode_runs 함수.

API 호출 대상이 하나이거나 없는 경우에는 불필요한 Thread 풀 생성 오버헤드를 방지하기 위해 직렬로(fast-path) 처리하도록 분기를 추가했습니다.

🎯 이유

기존 코드에서는 반복문을 돌며 gh api 명령을 통해 GitHub API를 순차적으로 하나씩 호출했습니다. 처리해야 할 PR이나 리뷰 쓰레드가 많아질수록 API 응답 지연이 선형적으로 누적되어 CI 스크립트 실행 시간이 불필요하게 길어지는 성능 병목(N+1 query problem)이 발생했습니다.

📊 영향

  • 여러 개의 리소스를 처리할 때 소요되는 시간이 O(N)에서 O(1) 수준으로 감소합니다. 최대 REST_MERGEABLE_STATE_WORKERS 개수만큼의 API 호출이 동시에 이루어집니다.
  • CI/CD 파이프라인의 전체 실행 시간이 획기적으로 줄어들 것으로 예상됩니다.

🔬 측정

  1. pytest tests/test_pr_review_merge_scheduler.py 명령을 통해 새로 추가한 동시성 처리 모의(Mock) 테스트가 성공하는지 확인합니다.
  2. python3 -m coverage run -m pytest tests/ && python3 -m coverage report -m 명령을 실행해 테스트 커버리지가 100%로 유지되는지 확인합니다.

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

scripts/ci/pr_review_merge_scheduler.py에 있는 N+1 GitHub API 호출 병목을 해소하기 위해 ThreadPoolExecutor를 사용하도록 리팩토링했습니다.
- `fetch_open_prs_rest`: REST API로 여러 PR 정보를 가져올 때 병렬 처리.
- `resolve_outdated_review_threads`: 이전 리뷰 쓰레드를 여러 개 닫을 때 병렬 처리.
- `cancel_stale_opencode_runs`: 기존에 실행 중인 여러 OpenCode CI 실행을 취소할 때 병렬 처리.

단일 항목의 경우에는 스레드 풀 생성 오버헤드를 피하기 위해 기존과 동일한 동기 처리 방식(fast-path)을 유지합니다.
@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.

@opencode-agent

opencode-agent Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: d5892715f784e3499e3f9608bc1cb8ddeef8569f
  • Workflow run: 28437604788
  • Workflow attempt: 1
  • Gate result: APPROVE (approval step)

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including .jules/bolt.md, scripts/ci/pr_review_merge_scheduler.py, tests/test_pr_review_merge_scheduler.py.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence reports supported repository test suites passed.
Docstring coverage: coverage execution evidence reports configured repository docstring gates passed or docstring coverage was advisory.
DAG: Change Flow DAG maps .jules/bolt.md through bounded evidence, review risk, and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, and current-head workflow evidence were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions and compatibility surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: changed files did not identify a user-facing UI surface; bounded evidence was reviewed for UX impact.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: No blockers found in the PR changes
  • Head SHA: d5892715f784e3499e3f9608bc1cb8ddeef8569f
  • Workflow run: 28437604788
  • Workflow attempt: 1

Change Flow DAG

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file: bolt.md"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file: bolt.md"]
  R1 --> V1["required checks"]
  Evidence --> S2["CI script: pr_review_merge_scheduler.py"]
  S2 --> I2["review and security gate shell path"]
  I2 --> R2["Review risk: CI script: pr_review_merge_scheduler.py"]
  R2 --> V2["bash -n plus Strix self-test"]
  Evidence --> S3["Test: test_pr_review_merge_scheduler.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_pr_review_merge_scheduler.py"]
  R3 --> V3["targeted test run"]
Loading

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

OpenCode reviewed the current-head bounded evidence and found no blocking issues.

Findings

No blocking findings.

Summary

Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including .jules/bolt.md, scripts/ci/pr_review_merge_scheduler.py, tests/test_pr_review_merge_scheduler.py.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence reports supported repository test suites passed.
Docstring coverage: coverage execution evidence reports configured repository docstring gates passed or docstring coverage was advisory.
DAG: Change Flow DAG maps .jules/bolt.md through bounded evidence, review risk, and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, and current-head workflow evidence were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions and compatibility surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: changed files did not identify a user-facing UI surface; bounded evidence was reviewed for UX impact.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.

  • Result: APPROVE
  • Reason: No blockers found in the PR changes
  • Head SHA: d5892715f784e3499e3f9608bc1cb8ddeef8569f
  • Workflow run: 28437604788
  • Workflow attempt: 1

Change Flow DAG

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file: bolt.md"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file: bolt.md"]
  R1 --> V1["required checks"]
  Evidence --> S2["CI script: pr_review_merge_scheduler.py"]
  S2 --> I2["review and security gate shell path"]
  I2 --> R2["Review risk: CI script: pr_review_merge_scheduler.py"]
  R2 --> V2["bash -n plus Strix self-test"]
  Evidence --> S3["Test: test_pr_review_merge_scheduler.py"]
  S3 --> I3["regression suite"]
  I3 --> R3["Review risk: Test: test_pr_review_merge_scheduler.py"]
  R3 --> V3["targeted test run"]
Loading

@opencode-agent
opencode-agent Bot enabled auto-merge (squash) June 30, 2026 10:37
@opencode-agent
opencode-agent Bot merged commit d104a35 into main Jun 30, 2026
6 checks passed
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