You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rate-limit pacing runs inside each of the 5 concurrent request slots, so requests go out up to 5× faster than paced #341
MakeGitHubRequestAsync (BuildMonitor/Providers/GitHub.cs ~L689-L708) first takes a RequestSemaphore slot, then waits GetRateLimitWaitTime() with Task.Delay. MakeAzureDevOpsRequestAsync (BuildMonitor/Providers/AzureDevOps.cs ~L403-L411) does the same.
The semaphore allows 5 holders (BuildProvider.cs ~L191-L196). Up to 5 requests therefore wait out the same delay at the same time and are sent together.
The delay is meant to be the gap between requests:
BaseRequestDelay is documented as the "Base delay between requests".
CalculateAdaptivePacing spreads the remaining budget evenly over the window, at timeUntilReset / usableBudget * 1.1 per request.
With all 5 slots busy, the real rate is about 5 / delay instead of 1 / delay.
Repro (scratch MSTest with an in-memory TokenStorage, as in GitHubRequestOutcomeTests)
GitHubprovider=new();varsw=Stopwatch.StartNew();awaitTask.WhenAll(Enumerable.Range(0,10).Select(i =>provider.MakeGitHubRequestAsync($"r{i}",()=>Task.CompletedTask)));// elapsed ≈ 1075 ms; with a 500 ms gap between requests, 10 requests should take ≥ ~4.5 s
Failure scenario
An org has ~80 repositories with 3–4 workflows each, about 300 builds.
Low-priority polling (every 120 s) wants ~2.5 requests/s. The token allows 5,000 requests per hour.
With 4,500 requests left and 3,600 s to reset, pacing works out to ~0.9 s per request, which should hold the rate near 1.1/s.
Because 5 slots wait in parallel, ~5.5 requests/s actually go out.
The budget falls through the 15% and 5% gates within minutes, and polling degrades to High priority only.
Suggested fix
Pace with a single provider-wide "next request allowed at" timestamp, shared by all callers and protected by a lock or Interlocked.
Each request reserves max(now, next) and moves next forward by the paced delay.
Keep the semaphore only as a concurrency cap.
Don't hold a semaphore slot while waiting for a rate-limit reset, or make that one shared wait.
Acceptance criteria
N concurrent MakeGitHubRequestAsync calls with no-op actions take at least (N-1) × BaseRequestDelay.
The same holds for adaptive pacing with an injected budget.
The Azure DevOps path behaves the same way.
This is not #331 (per-token budgets) or #333 (stale budget after reset). It happens with a single token and a correct budget.
Priority: High. Pacing is the app's main defence against running out of rate limit, and it is up to 5× too permissive. With a moderately large org, the budget falls through the 15% and 5% gates within minutes, and polling degrades to High-priority builds only. This affects a single token with a correct budget.
Area:BuildMonitor/Providers: MakeGitHubRequestAsync (GitHub.cs), MakeAzureDevOpsRequestAsync (AzureDevOps.cs) and the semaphore in BuildProvider.cs
Next step: Replace the per-slot delay with one provider-wide "next request allowed at" reservation, and keep the semaphore purely as a concurrency cap. Add a timing test that checks N concurrent calls take at least (N−1) × delay, on both providers.
Activity
matt-edmondson commentedon Oct 6, 2026
Triage
BuildMonitor/Providers:MakeGitHubRequestAsync(GitHub.cs),MakeAzureDevOpsRequestAsync(AzureDevOps.cs) and the semaphore inBuildProvider.csGenerated by Claude Code