Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): watched PRs page review threads side by side (850 ms → 239 ms median) #30292

ClosedYuruzuu(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/30292/headopened View on GitHub

Showing 2 changed files with 140 additions and 30 deletions.

x
0 of 2 viewed, 2 left
41 additions and 30 deletionsapps/server/src/orchestration-v2/PullRequestWatchReactor.tsModified
View file
@@ -46,6 +46,8 @@
const READ_FAILURE_LIMIT = 8;
/** Group reads in flight at once, inside the host's own request limit. */
const GROUP_READS = 4;
+/** Thread tails in flight at once for one PR, inside the host's own request limit. */
+const TAIL_READS = 4;
/** Without fingerprints, reread quiet PRs on snapshot changes or this interval to catch edits. */
const QUIET_REREAD_MS = 10 * 60_000;
/** Reread despite unchanged fingerprints; they miss review-thread comment edits. */
@@ -340,41 +342,50 @@
paginated.every(
(thread) => cached.tails.get(thread.id)?.count === (thread.commentCount ?? 0),
+ // Each thread's cursor chain stays serial; separate threads page side by side.
+ const read = yield* Effect.forEach(
+ paginated,
+ (thread) =>
+ Effect.gen(function* () {
+ const count = thread.commentCount ?? 0;
+ const known = reuse ? cached.tails.get(thread.id) : undefined;
+ if (known !== undefined) return known;
+ let cursor = thread.nextCommentsCursor ?? null;
+ const comments = new Map<string, PullRequestComment>();
+ const cursors = new Set<string>();
+ let hidden = 0;
+ while (cursor !== null) {
+ if (cursors.has(cursor)) return null;
+ cursors.add(cursor);
+ const page: PullRequestThreadCommentsResult = yield* pullRequests.threadComments({