Skip to content

Commit 81e99bb

Browse files
committed
perf(server): raise the upstream status fetch interval to 60s
`automaticGitFetchInterval` only governs the timer-driven remote refresh in VcsStatusBroadcaster. On-demand status reads -- thread mounts via `getStatus`, explicit refreshes via `refreshStatus` -- reach `statusDetailsRemote` without options, so `refreshUpstream` defaults to true and they fetch through `statusRemoteRefreshCache`. That cache's TTL, not the setting, is what bounds fetch volume, and setting the interval to 0 does not touch it. The key is (gitCommonDir, remoteName), so every repository carries its own budget. At 15s a handful of open repositories was enough to trip Azure DevOps' per-repository rate limit while actively working -- twice the rate of the 30s background poll it was meant to replace. Raise it to 60s. The failure cooldown was documented as needing to exceed the success interval, so raising one in isolation would have inverted it and retried failing remotes more often than healthy ones. Derive it as 2x the interval instead of hardcoding, so that invariant cannot silently break again. The worktree backoff test hardcoded the old 30s/60s boundaries; retarget it to 120s/240s.
1 parent 1c26e96 commit 81e99bb

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,18 @@ it.effect("backs off failed upstream refreshes across linked worktrees", () =>
602602
yield* driver.statusDetailsRemote(worktreePath);
603603
assert.equal(yield* Ref.get(fetchAttempts), 1);
604604

605-
yield* TestClock.adjust("29 seconds");
605+
// The failure cooldown is derived as 2x the success interval, so the
606+
// first failure holds for 120s and the second for 240s. Hold just short
607+
// of each boundary so the backoff cannot be shortened without failing.
608+
yield* TestClock.adjust("119 seconds");
606609
yield* driver.statusDetailsRemote(worktreePath);
607610
assert.equal(yield* Ref.get(fetchAttempts), 1);
608611

609612
yield* TestClock.adjust("1 second");
610613
yield* driver.statusDetailsRemote(cwd);
611614
assert.equal(yield* Ref.get(fetchAttempts), 2);
612615

613-
yield* TestClock.adjust("59 seconds");
616+
yield* TestClock.adjust("239 seconds");
614617
yield* driver.statusDetailsRemote(worktreePath);
615618
assert.equal(yield* Ref.get(fetchAttempts), 2);
616619

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ const RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES = 59_000;
4747
const REVIEW_DIFF_PATCH_MAX_OUTPUT_BYTES = 120_000;
4848
const REVIEW_UNTRACKED_DIFF_MAX_OUTPUT_BYTES = 80_000;
4949
const WORKSPACE_FILES_MAX_OUTPUT_BYTES = 120_000;
50-
const STATUS_UPSTREAM_REFRESH_INTERVAL = Duration.seconds(15);
50+
// On-demand status reads (thread mounts, explicit refreshes) fetch the upstream
51+
// through this cache, so its TTL — not `automaticGitFetchInterval` — is what
52+
// bounds fetch volume once the background poll is disabled. Hosts that rate
53+
// limit per-repository (Azure DevOps in particular) were tripping their quota
54+
// at 15s across a handful of open repositories, since the key is per
55+
// (gitCommonDir, remoteName) and every repository gets its own budget.
56+
const STATUS_UPSTREAM_REFRESH_INTERVAL = Duration.seconds(60);
5157
// Background status fetches are network-bound, so the budget has to cover a
5258
// real round trip rather than a local git invocation. At 5s, remotes that
5359
// simply answer slowly (cold TCP, credential helper round trip, large ref
@@ -59,8 +65,12 @@ const STATUS_UPSTREAM_REFRESH_TIMEOUT = Duration.seconds(45);
5965
// is the *last* one worth hammering, and a cooldown below the success interval
6066
// would retry failing repositories more often than healthy ones — the opposite
6167
// of the backoff the name promises. The exponential escalation to the max below
62-
// supersedes the fork's earlier flat 60s cooldown.
63-
const STATUS_UPSTREAM_REFRESH_FAILURE_BASE_COOLDOWN = Duration.seconds(30);
68+
// supersedes the fork's earlier flat 60s cooldown. Derived from the success
69+
// interval rather than hardcoded so raising that cannot silently invert this.
70+
const STATUS_UPSTREAM_REFRESH_FAILURE_BASE_COOLDOWN = Duration.times(
71+
STATUS_UPSTREAM_REFRESH_INTERVAL,
72+
2,
73+
);
6474
const STATUS_UPSTREAM_REFRESH_FAILURE_MAX_COOLDOWN = Duration.minutes(15);
6575
const STATUS_UPSTREAM_REFRESH_CACHE_CAPACITY = 2_048;
6676
const REPOSITORY_PATHS_CACHE_CAPACITY = 2_048;

0 commit comments

Comments
 (0)