Skip to content

Register standalone MSBuild telemetry for NGEN - #15410

Merged
JanProvaznik merged 2 commits into
mainfrom
janprovaznik-speedometer-regression-investigation
Nov 4, 2026
Merged

JanProvaznik merged 2 commits into
mainfrom
janprovaznik-speedometer-regression-investigation

Conversation

@JanProvaznik

@JanProvaznik JanProvaznik commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Related issue(s):

DevDiv bug 3083415. This addresses a demonstrated NGEN coverage gap; it resolves ~half of the regression, the rest is real work by setting up telemetry and sending data correctly in the scenario.

Run Evidence

improves the regressed scenario
https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/799933

Context

Standalone .NET Framework MSBuild ships a private Microsoft.VisualStudio.Telemetry.dll, but its VS setup entry does not register that DLL for NGEN. Registration of the core MSBuild assemblies is insufficient because setup uses /NoDependencies. A native image for another telemetry build cannot cover this copy merely because both assemblies retain the same assembly version.

Fresh MSBuild processes consequently JIT substantial telemetry SDK code. Local CLR Binding/Fusion diagnostics confirm a signature mismatch followed by "No matching native image found" in the default load context, rather than a LoadFrom-context failure.

Changes Made

  • Register the private telemetry DLL for the standalone x86 and amd64 MSBuild executable application contexts, using the existing VS setup NGEN metadata and priority 2.
  • Document executable-specific binding, independent version identities, actual runtime image-use verification, and the limits of interpreting reduced JIT work as an end-to-end speedup.

Compatibility

VS setup metadata and documentation only. No product DLL bytes, telemetry consent, event collection, session lifecycle, shutdown budget, diagnostics, public APIs, or build semantics change. The CLR retains its normal native-image validation and IL/JIT fallback. No ChangeWave is needed for this performance-only registration correction.

Testing

  • .\build.cmd -msbuildEngine vs -c Release -v quiet -bl — passed, zero warnings and zero errors. The full generated Microsoft.Build.vsix contains the intended NGEN application contexts, All architecture, and priority 2. Its telemetry payload SHA-256 matches the installed DLL used for the runtime experiment.
  • Run-Elevated.cmd (local diagnostic harness, not part of this PR) — passed: actual installed x64 VS MSBuild, real C++/NMake imports, and the recorded invalid-configuration echo fallback; 15 fresh-process measurements in each of the before/registered/restored states. Separate PID-filtered Binding/Fusion and loader/JIT captures lost zero events. The observer and ETW controller were not used in timed builds.
  • python analyze_proof.py (local analysis harness, not part of this PR) — passed: deterministic raw-data accounting, all 75 fixture hashes unchanged, and successful telemetry save in every measured build. The experimental registration was removed, and an independent exact-file NGEN query confirmed restoration.
Local evidence Before Registered Restored
Matching telemetry native image loaded No Yes No
SDK JIT-start events, separate diagnostic run 1,013 45 1,064
Main-thread SDK JIT-start events 392 0 392
Mean process wall, 15 runs (ms) 1,068.1 1,061.0 1,283.9
Mean reported save interval (ms) 464.2 577.5 694.7
Mean process wall minus reported save interval (ms) 603.9 483.4 589.2

Fusion explicitly reports "Bind to native image succeeded" after registration, and the CLR ModuleLoad event confirms the matching native path. All 45 remaining SDK JIT events in that diagnostic are runtime-generated methods.

Performance caveat: the save-excluded component improves by 106–120 ms, but this is arithmetic subtraction, not an isolated startup measurement. Variable save/disposal waits obscure the total benefit: the initial before/after mean changes by only 7.1 ms, with uncertainty spanning zero. Ordered phases, warm filesystem caches, and the inherited elevated token limit extrapolation. This is not a remeasurement of the original cold VS scenario or proof of recovery of its 489-ms regression.

Runtime image acceptance was checked on x64 only. x86/ARM64 runtime validation, the full unit test suite, and a fresh complete VS insertion/perf-system run were not performed.

Dependencies and Follow-up

Use the upstream experimental branch exp/janprovaznik/telemetry-ngen for downstream VS insertion and the original cold perf-system scenario. Setup must process the new registration metadata before measuring. Keep shutdown-policy/data-retention changes separate; this PR does not introduce that tradeoff.

Register the private telemetry assembly in standalone x86 and x64 MSBuild application contexts so VS setup can generate matching native images. Document binding validation and end-to-end performance limitations.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow metadata change follows existing registration patterns, has reported x64 runtime validation, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Registers standalone .NET Framework MSBuild’s private telemetry assembly for NGEN, addressing a native-image coverage gap without changing build behavior or telemetry lifecycle.

Changes:

  • Adds x86 and amd64 executable application contexts with All architecture and priority 2.
  • Documents binding identity, runtime image-use verification, and why reduced JIT work alone does not prove an end-to-end speedup.
File Description
src/​Package/​MSBuild.VSSetup/​files.swr Adds telemetry NGEN registration metadata for standalone MSBuild.
documentation/​NETFramework-NGEN.md Explains telemetry registration requirements and validation caveats.

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 24/24 dimensions clean — no findings.

The setup metadata follows existing application-context NGEN patterns, and the documentation accurately scopes the demonstrated validation and performance caveats.

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • api.nuget.org
  • github.com
  • learn.microsoft.com
  • patchdiff.githubusercontent.com
  • raw.githubusercontent.com
  • www.bing.com
  • www.google.com

[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "api.nuget.org"
    - "github.com"
    - "learn.microsoft.com"
    - "patchdiff.githubusercontent.com"
    - "raw.githubusercontent.com"
    - "www.bing.com"
    - "www.google.com"

See Network Configuration for more information.

Generated by Expert Code Review (on open) for #15410 · copilot · gpt56 · 830.8 AIC · ⌖ 0.522 AIC · ⊞ 20.8K

Comment thread documentation/NETFramework-NGEN.md Resolved
Comment thread documentation/NETFramework-NGEN.md Resolved
@JanProvaznik

Copy link
Copy Markdown
Member Author

extracted from checked in docs rationale and principles for this change in telemetry ngen:

The private `Microsoft.VisualStudio.Telemetry.dll` shipped beside MSBuild must be registered for the
standalone `Bin\MSBuild.exe` and `Bin\amd64\MSBuild.exe` application contexts. Visual Studio setup
generates the native images using the dependency binding policy of each executable. Core MSBuild's
registration is not sufficient: setup uses `/NoDependencies`, and the telemetry copy used inside
devenv can be a different build from the private copy used by MSBuild.exe.

The VS product version, telemetry package/file version, and assembly version are independent.
Two telemetry builds can have the same assembly version while differing in module identity and
dependencies, so the presence of a native image for VS's copy does not establish coverage for
MSBuild's copy.

When validating registration, keep the DLL bytes and executable configuration fixed, verify that
the actual MSBuild process loads the matching telemetry native image, and compare the same build
before and after registration. Use native-image binding diagnostics to investigate rejected images;
do not infer successful use just from a setup registration or an image on disk.

CLR Binding/Fusion diagnostics can distinguish a signature mismatch followed by "No matching native
image found" from a successful native-image bind. Confirm the latter with the loader's native module
path. Runtime-generated serialization methods may still require JIT compilation even when the SDK's
native image is used. Measure both total process lifetime and the telemetry shutdown interval:
reduced JIT work alone does not establish an end-to-end latency improvement.

@JanProvaznik
JanProvaznik merged commit 490377e into main Nov 4, 2026
13 checks passed
@JanProvaznik
JanProvaznik deleted the janprovaznik-speedometer-regression-investigation branch November 4, 2026 12:35
@JanProvaznik

Copy link
Copy Markdown
Member Author

/backport to vs18.13

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Started backporting to vs18.13 (link to workflow run)

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.

4 participants