Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): PR watches wake 14× sooner and stop waiting on unrelated reads (935 ms → 65 ms median) #30288

ClosedYuruzuu(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/30288/headopened View on GitHub

Showing 9 changed files with 169 additions and 42 deletions (loading 7).

x
0 of 9 viewed, 9 left
59 additions and 42 deletionsapps/server/src/orchestration-v2/PullRequestWatchReactor.tsModified
View file
@@ -24,6 +24,7 @@
import * as Option from "effect/Option";
import * as Schedule from "effect/Schedule";
import * as Schema from "effect/Schema";
+import * as Semaphore from "effect/Semaphore";
import type * as Scope from "effect/Scope";
​
import {
@@ -43,6 +44,9 @@
/** Checks take minutes; faster sweeps waste the account's shared host quota. */
const SWEEP_MINUTES = 2;
const READ_FAILURE_LIMIT = 8;
+/** Group reads and thread tails in flight at once, inside the host's own request limit. */
+const GROUP_READS = 4;
+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. */
@@ -335,39 +339,48 @@
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;