Uh oh!
There was an error while loading. Please reload this page.
Perf: Throttle parallel typechecks in Find All References - #20128
Conversation
T-Gro
left a comment
There was a problem hiding this comment.
🤖 AI review (@expert-reviewer): no significant issues found. Please verify independently.
Reviewed the throttling implementation for correctness:
use semaphorecombined withreturn! Task.WhenAll(tasks)correctly awaits within theusescope, avoiding the commonSemaphoreSlimuse-after-dispose pitfall (this would be a bug withreturninstead ofreturn!).semaphore.WaitAsync(ct)is placed before thetry, soRelease()runs only when a permit was actually acquired — no risk of over-release, and cancelled waiters correctly skip the release.- The expensive
start ct taskruns only after acquiring a permit, so concurrency is genuinely capped. max 1 Environment.ProcessorCountguarantees a valid (>= 1) semaphore count.
Cancellation and exception-aggregation semantics match the existing whenAll. LGTM.
149109e to
c5582baCompare❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
c5582ba to
a86b21fCompareUh oh!
There was an error while loading. Please reload this page.
b63942a to
7268a33Comparea5ce19f to
fc6577eComparefc6577e to
1e8fb87Compare
T-Gro
left a comment
There was a problem hiding this comment.
One note on the throttling scope.
Uh oh!
There was an error while loading. Please reload this page.
Refactored the `whenAllThrottled` function to use an array of background tasks, ensuring each acquires/releases the semaphore properly. Explicitly disposes the semaphore after all tasks complete using a continuation on `Task.WhenAll`. Simplified the XML doc comment. This replaces the previous sequence expression and `use` binding with more robust disposal logic.
1e8fb87 to
f86e7b8CompareUh oh!
There was an error while loading. Please reload this page.
T-Gro
commented
Aug 21, 2026
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
Fixes#20127
Problem
Project.FindFSharpReferencesAsynclaunched oneCancellableTaskper document in the project simultaneously viaCancellableTask.whenAll, causing an unbounded number of parallel typechecks (one per document) at once during Find All References / Rename.Fix
CancellableTask.whenAllThrottled maxDegreeOfParallelisminCancellableTasks.fs, using aSemaphoreSlimto cap concurrency while preserving cancellation semantics.Project.FindFSharpReferencesAsync(WorkspaceExtensions.fs), capping concurrency tomax 1 Environment.ProcessorCount.