Skip to content

Add tracking of AOT size and a pipeline to summarize it - #54682

Merged
baronfel merged 6 commits into
dotnet:mainfrom
baronfel:add-sizoscope-diffs-to-builds
Jun 18, 2026
Merged

baronfel merged 6 commits into
dotnet:mainfrom
baronfel:add-sizoscope-diffs-to-builds

Conversation

@baronfel

@baronfel baronfel commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

Now that we're making an AOT artifact, we should be aware of the size impact of dependencies/optimizations/etc.

This PR helps us establish this awareness by

  • generating sizoscope analysis artifacts from the build
  • storing them as a build artifact
  • creating a workflow that can analyze those artifacts and report on the changes a specific PR introduced, while making the raw data available for further investigation

The GHA workflow is triggered manually or via /aot-size comments on a PR. I've also run zizmor on it already.

Copilot AI review requested due to automatic review settings June 10, 2026 16:05
@baronfel
baronfel requested a review from MiYanni as a code owner June 10, 2026 16:05
@baronfel
baronfel requested a review from a team June 10, 2026 16:06
@baronfel baronfel added the Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort label Jun 10, 2026

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

This PR adds end-to-end NativeAOT size tracking by generating size diagnostics during the dotnet-aot build, publishing them from Azure DevOps runs, and introducing a GitHub Actions workflow that can diff PR vs. baseline artifacts and post a summarized size-impact comment back to the PR.

Changes:

  • Enable generation of NativeAOT size diagnostics artifacts (.mstat and .dgml) for dotnet-aot.
  • Copy and publish those artifacts as pipeline artifacts from the SDK build job.
  • Add a GitHub Actions workflow that can be triggered via /aot-size (or workflow_dispatch) to download PR/baseline artifacts, run sizoscope-cli, and post/update a PR comment.

Reviewed changes

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

File Description
src/Cli/dotnet-aot/dotnet-aot.csproj Enables emission of .mstat and .dgml size-analysis outputs during NativeAOT compilation.
eng/pipelines/templates/jobs/sdk-build.yml Copies/publishes the generated size-analysis files as a pipeline artifact for downstream consumption.
.github/workflows/aot-size-analysis.yml Adds a slash-command/dispatch workflow to download artifacts from AzDO, diff them via sizoscope-cli, and comment results on the PR.

Comment thread .github/workflows/aot-size-analysis.yml Outdated
Comment thread .github/workflows/aot-size-analysis.yml
Comment thread .github/workflows/aot-size-analysis.yml
Comment thread .github/workflows/aot-size-analysis.yml
Use createForPullRequestReviewComment when the trigger is a
pull_request_review_comment, since createForIssueComment targets
a different API resource and would fail for review comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@nagilson nagilson left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love this idea, we should be smarter about these size differences. Thank you and sorry you waited a while for review.

One question I have about the broad approach is that I thought azdo or other tools had (relatively https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/perf-test/rsat/rsat-run) built-in integration for size or other regression tracking with a chart over time? I want to make sure we aren't re-inventing the wheel. I believe C# devkit is doing that, and if we could do that when we do the build itself (flagged depending upon a property or perhaps changes to the /aot/ folder) rather than here, that would save resources.

Edit: (I'm not going to block this by being nitpicky about the approach though, this is still of course net good)

Comment thread src/Cli/dotnet-aot/dotnet-aot.csproj
Comment thread .github/workflows/aot-size-analysis.yml Outdated
Comment thread .github/workflows/aot-size-analysis.yml
The analyze job runs sizoscope-cli with only contents:read permission,
then uploads the report as a workflow artifact. A separate comment job
downloads the artifact and posts to the PR with write permissions.

This ensures the analysis code (which processes external build artifacts)
never has write access to the repository.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baronfel
baronfel force-pushed the add-sizoscope-diffs-to-builds branch from 67b9a6a to 7972e5a Compare June 17, 2026 19:31
Server-side filtering by refs/pull/{N}/merge is more reliable than
fetching top-20 builds and filtering client-side by SHA, which could
miss the build if many other builds ran since.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .github/workflows/aot-size-analysis.yml Outdated
baronfel and others added 2 commits June 17, 2026 15:55
Explicitly blank GITHUB_TOKEN, GH_TOKEN, and Actions runtime tokens
in the analyze job so that sizoscope-cli and other tooling cannot
access or exfiltrate credentials.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baronfel
baronfel requested a review from nagilson June 18, 2026 01:41
@baronfel
baronfel merged commit d166998 into dotnet:main Jun 18, 2026
26 checks passed
@baronfel
baronfel deleted the add-sizoscope-diffs-to-builds branch June 18, 2026 16:07
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants