Skip to content

Trim unused CoreCLR native components from dotnet-linker-tests build - #131666

Draft
sbomer wants to merge 2 commits into
dotnet:mainfrom
sbomer:runtime-linker-test-perf
Draft

Trim unused CoreCLR native components from dotnet-linker-tests build#131666
sbomer wants to merge 2 commits into
dotnet:mainfrom
sbomer:runtime-linker-test-perf

Conversation

@sbomer

@sbomer sbomer commented Jul 31, 2026

Copy link
Copy Markdown
Member

The Runtime_Release jobs in the dotnet-linker-tests pipeline build the clr subset. That expands to clr.native, which performs a full CoreCLR native build — including several components the trimming and NativeAOT tests never use:

  • alljits — six cross-target alt-JITs (clrjit_universal_arm64_x64, clrjit_win_x86_x64, clrjit_universal_wasm_x64, etc.)
  • spmi — SuperPMI and its three shims

Together these are 703 of 2837 ninja targets (~25%) of the CoreCLR native build.

This narrows the subset list to just the components the tests actually need. src/coreclr/components.cmake shows the runtime component already depends on jit, iltools, debug and hosts, so clr.runtime covers everything required to run the tests, and clr.tools + clr.nativeaotlibs + clr.nativeaotruntime cover ILCompiler and the NativeAOT test apps. Only ILCompiler.ReadyToRun.Tests needs alljits, and it builds them itself on demand.

Two further subsets pulled in by clr are also dropped:

  • clr.packages only produces the ILAsm/ILDAsm/TestHost/Sdk.IL nupkgs, referenced solely by eng/Publishing.props for official-build publishing. (Packing them takes ~2.5s, so this is a cleanliness change, not a perf one.)
  • clr.crossarchtools is redundant here — _BuildCrossComponents is already set whenever ClrRuntimeBuildSubsets is non-empty for CoreCLR, and the cross-tool build is gated on _BuildAnyCrossArch, which is false for native windows-x64/linux-x64. Verified no cross-arch build directory is produced either way.

Measurements

CI runs the native build at ninja -j 4, so measurements were taken locally at the same parallelism:

ninja targets native build @ -j4
Before (clr) 2837 4m03s
After 2134 3m05s
Delta −703 (−24.8%) −58s (−24%)

Applied to the current CI native phases (15.6m on windows-x64, 11.0m on linux-x64), this should take roughly 3.5–4 min off the critical-path windows-x64 job, which currently runs ~62m within a ~75m build. linux-x64 saves ~2.6m but stays off the critical path. The browser-wasm job is unaffected (it builds mono, not clr).

The −24% is likely conservative for Windows, which drops a larger share of targets (780/2646 = 29.5%) since Linux keeps clrjit_unix_x64_x64 as part of the base jit component.

Validation

From a clean tree with the narrowed subsets:

  • Build succeeds
  • Trimming tests: 88 tests pass
  • NativeAOT test apps: 57 tests pass
  • Artifacts verified: only the host libclrjit.so remains, superpmi is gone, and libcoreclr.so, ilc, crossgen2, ilasm/ildasm, DAC/mscordbi and the aotsdk are all still present

Note

This content was created with assistance from AI.

The Runtime_Release jobs in the dotnet-linker-tests pipeline built the
`clr` subset, which expands to `clr.native` and therefore performs a full
CoreCLR native build. That includes several components the trimming and
NativeAOT tests never use, most notably the `alljits` component (six
cross-target alt-JITs) and `spmi` (SuperPMI and its shims).

Narrow the subset list to just the components the tests need. This drops
703 of 2837 ninja targets (~25%) from the CoreCLR native build. Measured
locally at `ninja -j 4`, matching the parallelism CI uses, the native
build goes from 4m03s to 3m05s (-24%).

Also drop two subsets that were pulled in by `clr` but are not needed:

* `clr.packages` only produces the ILAsm, ILDAsm, TestHost and Sdk.IL
  nupkgs, which are consumed solely by official-build publishing.
* `clr.crossarchtools` is redundant here: `_BuildCrossComponents` is
  already set whenever `ClrRuntimeBuildSubsets` is non-empty for CoreCLR,
  and the cross-tool build is gated on `_BuildAnyCrossArch`, which is
  false for native windows-x64 and linux-x64.

Validated from a clean tree with the narrowed subsets: the trimming tests
(88) and the NativeAOT test apps (57) all pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ce99ab84-7dd0-4307-8dbe-47d695b514de
Assisted-by: Copilot:claude-opus-5
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

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.

Pull request overview

Updates the runtime-linker-tests Azure Pipelines definition to build a narrower set of CoreCLR subsets for the Runtime_Release jobs, aiming to avoid building unused native components during trimming and NativeAOT test runs.

Changes:

  • Replaces -s clr+... with an explicit subset list centered on clr.runtime plus NativeAOT/tooling subsets.
  • Adds inline pipeline comments documenting why alljits and spmi are intentionally excluded.
Show a summary per file
File Description
eng/pipelines/runtime-linker-tests.yml Switches the CoreCLR build from clr to an explicit subset list intended to avoid building unused native components for linker/NativeAOT tests.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread eng/pipelines/runtime-linker-tests.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 19:17

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.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants