Skip to content

Speed up PR review thread loading - #144

Merged
pandemicsyn merged 2 commits into
mainfrom
agent/review-thread-performance
Jul 18, 2026
Merged

pandemicsyn merged 2 commits into
mainfrom
agent/review-thread-performance

Conversation

@pandemicsyn

Copy link
Copy Markdown
Owner

Summary

  • make the real-PR benchmark reject accidental Vite development runs and record aborted requests plus thread request/render timing
  • use a lean review-surface GraphQL query while preserving the full-fidelity Flue action
  • add a conservative 15-second, 16-entry in-memory cache with token-scoped keys, mutation invalidation, race protection, and caller cancellation
  • update the retained performance plan and HTML static-review report without removing prior findings or measurements
  • add a patch changeset

Why

The production review surface spent only about 11 ms rendering threads after the response, while the uncached GitHub GraphQL request took roughly 0.9–1.1 seconds and transferred 381 KB. The remaining bottleneck was the request path rather than React, TanStack Query, or Pierre.

Measured result

Real registered target: Kilo-Org/kilocode#12204, 1,019 files and 47 review threads.

  • warm thread visibility: 1,724 ms → 459 ms median
  • thread response: 381,244 B → 58,240 B (84.7% smaller)
  • total API transfer: 742,850 B → 400,821 B
  • warm backend thread read: 6.8 ms median
  • post-response React rendering: 6.5 ms median
  • final trace: 530 ms LCP, 0.00 CLS, zero aborted/failed API requests

The initial uncached GitHub read remains about 655 ms, the tree median remains 642 ms, and both stay explicit follow-ups.

Cache safety

The cache is process-local only, capped at 16 entries, expires after 15 seconds, and uses a token fingerprint in its key. Successful review submissions, replies, and resolve/unresolve actions invalidate the target. A mutation racing an in-flight read prevents the stale result from being cached. In-flight calls are not shared, so one caller's cancellation cannot cancel another caller's work.

Validation

  • npm run verify — lint, layers, database checks, types, 560 unit tests, 33 git tests, 129 integration tests, dashboard/docs builds, package validation, pack smoke, formatting
  • final npm run check after cancellation-semantics hardening — 561 unit tests
  • production npm run bench:pr-review against the immutable PR revision
  • Chrome DevTools production trace and accessibility-tree smoke check

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47a0dd6f5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/modules/pr-events/service.ts Outdated
threadId,
body: parsed.output.text,
});
invalidatePullRequestReviewSurfaceThreadCache({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Invalidate review-thread cache before fallible refresh

When replyToPullRequestReviewThread is used, the helper posts the GitHub reply and then performs a separate fetchPullRequestReviewThread; if that follow-up read times out or is rate-limited after the reply succeeds, execution never reaches this new invalidation. In that scenario a warm /prs/review-threads cache can keep returning the pre-reply thread list for the 15s TTL (the resolve/unresolve helpers have the same pattern), so invalidate in a finally or immediately after the GitHub mutation is known to have run.

Useful? React with 👍 / 👎.

@pandemicsyn
pandemicsyn merged commit 5479b58 into main Jul 18, 2026
5 checks passed
@pandemicsyn
pandemicsyn deleted the agent/review-thread-performance branch July 18, 2026 13:35
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