Skip to content

Commit 64759ec

Browse files
only21milclaude
andcommitted
fix(server): PR sync reads batch again on a busy server
The sweep ran 25 groups at a time to match the 25-PR summary batch. Each read reaches the batch resolver only after its cache check, which a busy server spreads over hundreds of milliseconds, so batches split. Every slot then refilled on its own, and later reads went out about one PR per request. Run 100 groups at once so a sweep's reads still meet in a batch; the cap keeps hosts that read each PR separately bounded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 54c5f25 commit 64759ec

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,45 @@ describe("PullRequestSyncReactor", () => {
11011101
),
11021102
);
11031103

1104+
it.effect("has every due read of a sweep wider than one summary batch in flight at once", () =>
1105+
Effect.scoped(
1106+
Effect.gen(function* () {
1107+
yield* TestClock.setTime(Date.parse(NOW));
1108+
const numbers = Array.from({ length: 30 }, (_, index) => index + 1);
1109+
const inFlight = yield* Ref.make({ active: 0, peak: 0 });
1110+
const fixture = yield* makeHarness({
1111+
snapshot: makeSnapshot(
1112+
numbers.map((number) =>
1113+
makeThread(`thread-${number}`, { pullRequests: [makeLink(number)] }),
1114+
),
1115+
),
1116+
summary: (input) =>
1117+
Ref.update(inFlight, ({ active, peak }) => ({
1118+
active: active + 1,
1119+
peak: Math.max(peak, active + 1),
1120+
})).pipe(
1121+
Effect.andThen(Effect.sleep("1 second")),
1122+
Effect.andThen(
1123+
Ref.update(inFlight, (state) => ({ ...state, active: state.active - 1 })),
1124+
),
1125+
Effect.as(makeSummary(input)),
1126+
),
1127+
});
1128+
yield* Effect.gen(function* () {
1129+
const reactor = yield* PullRequestSyncReactor.PullRequestSyncReactor;
1130+
yield* reactor.start();
1131+
yield* Deferred.succeed(fixture.activation, undefined);
1132+
yield* TestClock.adjust("1 second");
1133+
// A narrower sweep reads the rest in a second wave.
1134+
yield* TestClock.adjust("1 second");
1135+
yield* reactor.drain;
1136+
assert.strictEqual((yield* Ref.get(inFlight)).peak, numbers.length);
1137+
assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, numbers.length);
1138+
}).pipe(Effect.provide(fixture.layer));
1139+
}),
1140+
),
1141+
);
1142+
11041143
it.effect("skips the stack read for a pull request the summary places in no stack", () =>
11051144
Effect.scoped(
11061145
Effect.gen(function* () {

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,9 @@ export const make = Effect.gen(function* () {
588588
),
589589
);
590590
},
591-
// Match summary batch width so GitHub reads coalesce into one request.
592-
{ concurrency: 25, discard: true },
591+
// Wider than one summary batch, so reads that finish their cache checks at different times
592+
// still share batches; the cap bounds hosts that read each pull request on its own.
593+
{ concurrency: 100, discard: true },
593594
);
594595
for (const [reason, { count, key }] of skips) {
595596
yield* Effect.logWarning("pull request sync skipped", { count, key, reason });

0 commit comments

Comments
 (0)