Skip to content

Emit telemetry when create-instance steps exceed 10s#40269

Open
shuaiyuanxx wants to merge 11 commits intomasterfrom
user/shawn/slow-operation-warning
Open

Emit telemetry when create-instance steps exceed 10s#40269
shuaiyuanxx wants to merge 11 commits intomasterfrom
user/shawn/slow-operation-warning

Conversation

@shuaiyuanxx
Copy link
Copy Markdown

@shuaiyuanxx shuaiyuanxx commented Apr 22, 2026

Summary of the Pull Request

Adds SlowOperationWatcher, an RAII guard that emits a SlowOperation telemetry event when a scoped step exceeds 10 s, so slow CreateInstance starts can be attributed to a specific phase (HCS op, kernel boot, init-daemon wait, plugin hook) instead of the opaque timeout bucket.

Fast path emits nothing. Slow path emits one SlowOperation event carrying name, thresholdMs, and the call site (file, function, line) captured via std::source_location.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description

src/windows/common/SlowOperationWatcher.{h,cpp} is a single-shot threadpool timer guard. wil::unique_threadpool_timer's destroyer cancels and drains on scope exit, so the callback cannot touch *this after destruction. Reset() disarms early for cases where the scope must outlive the watched call (e.g. to keep a ReceiveMessage buffer reference alive). Name is restricted to const char (&)[N] to enforce static storage.

12 call sites wrapped:

  • WslCoreVm.cpp: HcsCreateSystem, HcsStartSystem, WaitForMiniInitConnect, ReadGuestCapabilities, CreateNatNetwork, AttachDistroVhd, WaitForInitDaemonConnect
  • WslCoreInstance.cpp: WaitForCreateInstanceResult, WaitForDrvFsInit, WaitForInitConfigResponse
  • PluginManager.cpp: PluginOnVmStarted, PluginOnDistributionStarted

Call-site business logic is unchanged. No user-facing path.

Validation Steps Performed

Validated end-to-end against a Debug wslservice.exe with ETW capture:

  • Fast path: wsl --shutdown + wsl -d Ubuntu -e echo hello — all guarded sites exercised, zero SlowOperation events.
  • Slow path: injected Sleep(11000) inside WaitForMiniInitConnect — one SlowOperation{name="WaitForMiniInitConnect", thresholdMs=10000, file, function, line} event emitted.

Copilot AI review requested due to automatic review settings April 22, 2026 07:38
@shuaiyuanxx shuaiyuanxx changed the title Upload binaries when publishing symbols (#40208) Emit telemetry when create-instance steps exceed 10s Apr 22, 2026
@shuaiyuanxx shuaiyuanxx force-pushed the user/shawn/slow-operation-warning branch from 7c33062 to fd84d5e Compare April 22, 2026 07:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds slow-operation instrumentation across VM/instance startup paths and updates the build pipeline to retain and publish binaries alongside PDBs during symbol publication.

Changes:

  • Introduce WslSlowOperation (RAII + threadpool-timer) to emit telemetry/logs when scoped operations exceed a threshold.
  • Wrap several VM/instance startup and plugin hook calls with WslSlowOperation scopes to measure slow phases.
  • Update pipeline symbol publishing to also upload .exe/.dll binaries and avoid deleting test DLLs during staging.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/windows/service/exe/WslCoreVm.cpp Adds WslSlowOperation scopes around key VM startup and instance creation operations.
src/windows/service/exe/WslCoreInstance.cpp Narrows slow-operation timing specifically around blocking receives from init.
src/windows/service/exe/PluginManager.cpp Adds slow-operation timing around plugin hook invocations.
src/windows/common/precomp.h Exposes WslSlowOperation via the common precompiled header.
src/windows/common/WslSlowOperation.h New RAII helper declaration for slow-operation timing and telemetry.
src/windows/common/WslSlowOperation.cpp Implements timer-based slow threshold detection and start/end telemetry emission.
src/windows/common/CMakeLists.txt Adds the new WslSlowOperation files to the common build.
.pipelines/build-job.yml Keeps DLLs in bin/ and expands symbol publishing inputs to include .exe/.dll.

Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
@shuaiyuanxx shuaiyuanxx force-pushed the user/shawn/slow-operation-warning branch from fd84d5e to a132d71 Compare April 22, 2026 07:47
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 22, 2026 07:53
@shuaiyuanxx shuaiyuanxx force-pushed the user/shawn/slow-operation-warning branch from a132d71 to 76192d4 Compare April 22, 2026 07:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
shuaiyuanxx and others added 2 commits April 22, 2026 16:02
Matches the codebase convention (100+ uses of TraceLoggingValue elsewhere,
zero uses of TraceLoggingString before this PR). Functionally identical:
both resolve to the ANSI string field for a const char* argument.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Addresses review comment: avoid relying on transitive includes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shuaiyuanxx shuaiyuanxx marked this pull request as ready for review April 22, 2026 08:40
@shuaiyuanxx shuaiyuanxx requested a review from a team as a code owner April 22, 2026 08:40
Copilot AI review requested due to automatic review settings April 22, 2026 08:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread src/windows/service/exe/WslCoreInstance.cpp Outdated
Comment thread src/windows/service/exe/WslCoreInstance.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.h Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.cpp Outdated
Comment thread src/windows/common/WslSlowOperation.h Outdated
Comment thread src/windows/common/WslSlowOperation.h Outdated
Copilot AI review requested due to automatic review settings April 23, 2026 02:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src/windows/common/SlowOperationWatcher.h
Comment thread src/windows/common/SlowOperationWatcher.h Outdated
Comment thread src/windows/common/SlowOperationWatcher.cpp
Copilot AI review requested due to automatic review settings April 23, 2026 03:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread src/windows/common/SlowOperationWatcher.cpp Outdated
Comment thread src/windows/common/SlowOperationWatcher.cpp Outdated
Comment thread src/windows/common/SlowOperationWatcher.cpp Outdated
Comment thread src/windows/service/exe/WslCoreVm.cpp Outdated
Comment thread src/windows/service/exe/WslCoreVm.cpp Outdated
Comment thread src/windows/service/exe/WslCoreVm.cpp Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 01:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@shuaiyuanxx
Copy link
Copy Markdown
Author

Hi @OneBlue, Thanks for the thorough review! All of your suggestions have been addressed — PTAL when you have a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants