Skip to content

perf: parallelise the three PR-data fetches in reviewPullRequest#36

Merged
avrabe merged 1 commit into
mainfrom
perf/parallel-pr-fetches
May 1, 2026
Merged

perf: parallelise the three PR-data fetches in reviewPullRequest#36
avrabe merged 1 commit into
mainfrom
perf/parallel-pr-fetches

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 30, 2026

Fixes Bug #19 from docs/agent-fleet/bugs.md (wave-1 Performance engineer).

The hot path of reviewPullRequest issued three strictly-sequential GitHub REST calls (PR meta, diff via mediaType, files list) before any work — ~600-1500 ms of wall-time waste. They're independent, so Promise.all halves it.

  • 806 tests pass
  • eslint clean

🤖 Generated with Claude Code

## Why
The hot path of `reviewPullRequest` (`src/ai-review.js:382-398`) issued three
strictly-sequential GitHub REST calls before any work began: PR metadata, the
diff via `mediaType: { format: 'diff' }`, and the files list. Each call costs
~200-500 ms of egress time on the netcup VPS; serially that's ~600-1500 ms
of wall-time waste on every review.

The three calls are independent — none depends on the other two's response —
so they parallelise trivially.

## What
`Promise.all([request, request, request])` wrapper in `reviewPullRequest`.
The downstream consumers (rivet oracle path, `buildReviewPrompt`,
`recordReview`) keep their `prData` / `diffResponse` / `filesResponse`
contract unchanged. octokit.request invocations are still dispatched in
source order (JS is single-threaded), so the existing
`mockResolvedValueOnce`-style test rigs work unchanged.

## Source
Wave-1 Performance engineer flagged this as Bug #19 in
`docs/agent-fleet/bugs.md`. Estimated savings: 0.5-1 s per review.

## Test plan
- [x] All 806 tests pass
- [x] eslint clean
- [ ] After deploy: PR-review wall-time drops by the GitHub-egress component;
      visible in `pr-review-timing` logs (when added per Performance agent's
      "one profile I'd run" recommendation).

## Risk & rollout
- Risk: low. Same data, same downstream consumers, just dispatched concurrently.
- Rollout: self-update on merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit 44687c8 into main May 1, 2026
5 checks passed
@avrabe avrabe deleted the perf/parallel-pr-fetches branch May 1, 2026 07:14
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