Skip to content

Startup: telemetry initialization on the main thread adds about 22 ms on Windows #28373

Open

Description

Summary of the new feature / enhancement

ConsoleHost calls ApplicationInsightsTelemetry.SendPSCoreStartupTelemetry before it runs the command. The static constructor of ApplicationInsightsTelemetry first calls WindowsDataCollectionSetting.CanCollectDiagnostics (added in #27328), which initializes WinRT and activates Windows.System.Profile.PlatformDiagnosticsAndUsageDataSettings, and then creates the Application Insights client. All of this runs on the main thread before the user's command.

With POWERSHELL_TELEMETRY_OPTOUT=1, pwsh -NoProfile -NonInteractive -Command exit (7.6.9 x64, i9-10900K, 30 interleaved runs, median of paired differences with 95% confidence interval):

difference with opt-out
Windows 11 26100 -22.3 ms (14.0 to 28.9)
Ubuntu 26.04 on the same machine (WSL2) 0.0 ms (-5.6 to 8.2)

The WinRT query alone, in a small C program, costs 13 ms and loads 13 extra DLLs.

Proposed technical implementation details (optional)

Move the telemetry initialization, including the Windows setting check, off the start-up path, for example into the task that sends the start-up event, so CanSendTelemetry is resolved in the background. The opt-out stays the same because the environment variable is checked first.

Activity

  1. added
    WG-Enginecore PowerShell engine, interpreter, and runtime
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    WG-NeedsReviewNeeds a review by the labeled Working Group
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions