Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): a slow host no longer delays other watched PRs' wakes (935 ms → 65 ms median) #30291

MergedYuruzuu(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/30291/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 98 additions and 14 deletions.

x
0 of 2 viewed, 2 left
21 additions and 14 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,8 @@
/** Checks take minutes; faster sweeps waste the account's shared host quota. */
const SWEEP_MINUTES = 2;
const READ_FAILURE_LIMIT = 8;
+/** Group reads in flight at once, inside the host's own request limit. */
+const GROUP_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. */
@@ -626,22 +629,26 @@
{ discard: true },
- const fingerprints = yield* Effect.forEach(groups, fingerprintOf, {
- concurrency: "unbounded",
- });
+ // Every fingerprint is asked for at once so the host can batch them, and each group reads
+ // as soon as its own answer lands rather than waiting on the slowest host.
+ const reads = yield* Semaphore.make(GROUP_READS);
yield* Effect.forEach(