Skip to content

Perf: Throttle parallel typechecks in Find All References #20127

Description

@xperiandri

Problem

Project.FindFSharpReferencesAsync launches one CancellableTask per document in the project simultaneously via CancellableTask.whenAll, which can spawn an unbounded number of parallel typechecks at once when a project has many documents. This causes CPU spikes and background churn during Find All References / Rename.

Fix

Add CancellableTask.whenAllThrottled maxDegreeOfParallelism, which uses a SemaphoreSlim to cap the number of concurrently running tasks while preserving cancellation semantics. Apply it in Project.FindFSharpReferencesAsync (in WorkspaceExtensions.fs), capping concurrency to max 1 Environment.ProcessorCount.

Files

  • vsintegration/src/FSharp.Editor/Common/CancellableTasks.fs
  • vsintegration/src/FSharp.Editor/LanguageService/WorkspaceExtensions.fs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions