Enable /graph in CI builds, dev builds, and PR builds#53607
Conversation
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/efc7cf71-2ee4-4f93-b888-494874161c1e Co-authored-by: marcpopMSFT <[email protected]>
|
@copilot can this be added to a directory.build.rsp file in the root of the repo instead? |
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/65f8b05b-ea0c-44e6-bab9-ac3a5153942e Co-authored-by: baronfel <[email protected]>
Done in ec698e7. Reverted the per-script additions and added a |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Enables MSBuild static graph mode across builds by introducing a repo-level response file intended to add /graph to MSBuild invocations.
Changes:
- Add
Directory.Build.rspat the repo root containing/graphto enable static graph builds by default.
|
/azp run dotnet-sdk-public-ci |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
|
@baronfel it doesn't appear that Directory.Build.rsp is loaded when we build with build.cmd. I'm not clear if that's true of cibuild.cmd either. I confirmed it loads when using dotnet build. As such, I'm thinking we may need to go back to the prior fix for this. |
|
Agree - though I want to log an issue and make copilot figure out why that is, because it break my mental model quite badly. |
|
@copilot The .rsp file doesn't get loaded when I build locally using build.cmd. Let's go back to the prior solution you had for this. |
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/b3734628-23be-4f0f-b006-e0bd2022cae6 Co-authored-by: marcpopMSFT <[email protected]>
|
@baronfel confirmed this works for local build now. It isn't used in the PR build but I assume we're ok with that since /graph mostly helps with incremental builds. Holler if you think we should try to ensure /graph is used for PR and CI builds as well. |
Summary
Enables MSBuild's static graph build mode (
/graph) for all build types to speed up builds.Changes
eng/build.sh— adds/graphfor developer builds on Linux/macOSeng/build.ps1— adds/graphfor developer builds on Windowseng/pipelines/templates/jobs/sdk-build.yml— adds/graphto both the Windows (eng/common/build.ps1) and Linux (eng/common/build.sh) build steps used in CI and PR pipelinesWhy
/graph?MSBuild's static graph (
/graph) mode pre-evaluates the project dependency graph before building, which allows for better scheduling and parallelism across projects. This speeds up builds, particularly in repos with many projects like the SDK.MSBuild
/graphBuild Performance AnalysisSummary
Enabling MSBuild's
/graphflag on the dotnet/sdk repo cuts no-op incremental build time by ~52% (8.5 min → 4.1 min wall-clock). Graph build pre-computes the project dependency graph statically, eliminating redundant recursive traversal of project references that dominates incremental build cost.Test Setup
build.cmd /bl(baseline) vsbuild.cmd /bl /graphscripts/BinlogAnalyzer/)Results
Wall-Clock Time
/graph/graphTarget-Level Comparison (Cumulative Time)
/graph/graphResolveProjectReferencesMsCoverageReferencedPathMapsDispatchToInnerBuildsGetCopyToOutputDirectoryItems_GetProjectReferenceTargetFrameworkPropertiesTask-Level Comparison (Cumulative Time)
/graph/graphMSBuild(recursive invocations)Csc(compilation)CopyKey Observations
/graphhalved wall-clock time. The biggest gain comes from eliminating redundant project reference traversal. In standard mode, MSBuild recursively invokesResolveProjectReferenceson every project and its transitive dependencies. Graph build pre-computes the full dependency graph, building projects in topological order without redundant re-evaluation.MsCoverageReferencedPathMapsdropped from 187 min to 3 min cumulative. This code coverage instrumentation target was being invoked deeply in the recursive project graph traversal. With graph build, it no longer runs redundantly across transitive references.Zero compilations on no-op with
/graph. TheCsctask didn't even appear in the top 20 task list — graph build correctly determined every project was up-to-date. Without/graph, there were still 692 Csc invocations (10.9 min cumulative), suggesting the standard mode was triggering unnecessary recompilations due to timestamp changes from the recursive traversal itself.The build succeeded cleanly with
/graph— zero errors, zero warnings. The pre-existingdotnet.Testscompilation error (RunFileTestBasenot found) that occurs without/graphdid not reproduce, likely due to different build ordering.Lower parallelism ratio is expected. The parallelism ratio dropped from 71x to 20x because there is dramatically less redundant work being scheduled across cores. The 71x ratio in the non-graph build reflects wasted parallel work (the same project references being evaluated simultaneously on multiple threads).