PR-CI: Split Build and Analyze into independent LOC-based batched matrices - #59444
Merged
Conversation
Replaces single batched-build-analyze matrix with two parallel matrix-gens, each tuned independently: - Build: LocTargetSeconds=1,200,000 (larger batches, fewer jobs, lower fixed-overhead) - Analyze: LocTargetSeconds=300,000 (smaller batches, more parallelism) Adds pr-matrix-presteps.yml params LocTargetSeconds (default 474000) and PublishArtifact (default true) so each matrix-gen can configure LOC target independently and only the first publishes BuildPackagesArtifact (avoiding duplicate-artifact collision). Adds Get-PackageLocWeights.ps1 (LOC counter) and Apply-WeightedBatching.ps1 (LPT bin-packing) which together drive the LOC-weighted bin-packing. Removes the now-unused batched-build-analyze.yml. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
m-nash
requested review from
Ben Broderick Phillips (benbp),
Patrick Hallisey (hallipr) and
Wes Haggard (weshaggard)
as code owners
May 26, 2026 16:30
JoshLove-msft
approved these changes
May 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the PR-CI pipeline to generate separate Build and Analyze job matrices using LOC-weighted batching, so Build runs in fewer/larger batches and Analyze runs in more/smaller batches—aiming to reduce wall-clock skew between the two stages.
Changes:
- Split PR matrix generation into two independent passes: Build (~1.2M LOC target) and Analyze (~300k LOC target).
- Added PowerShell scripts to compute per-package LOC and apply weighted LPT bin-packing to consolidate PackageInfo files into balanced batches.
- Introduced dedicated job templates for batched Build vs batched Analyze.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| eng/pipelines/templates/jobs/ci.yml | Runs two independent PR matrix generations (Build + Analyze) and wires them to separate batched job templates. |
| eng/pipelines/templates/steps/pr-matrix-presteps.yml | Adds optional LOC-weighting + optional artifact publishing during PR matrix pre-generation. |
| eng/pipelines/templates/jobs/batched-build.yml | Build-only batched job template (Analyze removed). |
| eng/pipelines/templates/jobs/batched-analyze.yml | New Analyze-only batched job template (Linux pool). |
| eng/scripts/Get-PackageLocWeights.ps1 | New script to compute per-package C# LOC weights from src/**/*.cs. |
| eng/scripts/Apply-WeightedBatching.ps1 | New script to apply weighted LPT batching and consolidate PackageInfo files per batch. |
Eliminates the artifact-download race between the parallel build and analyze matrix-gen stages. Build matrix-gen continues to publish BuildPackagesArtifact for build jobs; analyze matrix-gen now publishes its own AnalyzePackageInfoArtifact for analyze jobs. Both matrix-gens remain fully parallel - no wall-clock cost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The parameter values are LOC counts, not seconds. The 'Seconds' suffix was a misleading carryover from when the script was time-based. Renames the YAML param, the script param, internal variables, docstrings, and the display/log messages so future readers don't misconfigure them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jesse Squire (jsquire)
approved these changes
May 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ben Broderick Phillips (benbp)
approved these changes
May 26, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jesse Squire (jsquire)
approved these changes
May 26, 2026
mcgallan
pushed a commit
to mcgallan/azure-sdk-for-net
that referenced
this pull request
Jun 11, 2026
…rices (Azure#59444) * Split Build/Analyze into independent LOC-weighted matrices Replaces single batched-build-analyze matrix with two parallel matrix-gens, each tuned independently: - Build: LocTargetSeconds=1,200,000 (larger batches, fewer jobs, lower fixed-overhead) - Analyze: LocTargetSeconds=300,000 (smaller batches, more parallelism) Adds pr-matrix-presteps.yml params LocTargetSeconds (default 474000) and PublishArtifact (default true) so each matrix-gen can configure LOC target independently and only the first publishes BuildPackagesArtifact (avoiding duplicate-artifact collision). Adds Get-PackageLocWeights.ps1 (LOC counter) and Apply-WeightedBatching.ps1 (LPT bin-packing) which together drive the LOC-weighted bin-packing. Removes the now-unused batched-build-analyze.yml. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Use separate AnalyzePackageInfoArtifact for analyze stage Eliminates the artifact-download race between the parallel build and analyze matrix-gen stages. Build matrix-gen continues to publish BuildPackagesArtifact for build jobs; analyze matrix-gen now publishes its own AnalyzePackageInfoArtifact for analyze jobs. Both matrix-gens remain fully parallel - no wall-clock cost. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Rename LocTargetSeconds -> LocTarget (and -TargetSeconds -> -Target) The parameter values are LOC counts, not seconds. The 'Seconds' suffix was a misleading carryover from when the script was time-based. Renames the YAML param, the script param, internal variables, docstrings, and the display/log messages so future readers don't misconfigure them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove time-unit suffixes from LOC weight log lines Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Resolve DirectoryPath against RepoRoot in Get-PackageLocWeights Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify LOC weights key is ArtifactName Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify Target is a goal not a hard cap Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Rename EnableBuildWeighting -> EnableLocWeighting Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Make Apply-WeightedBatching synopsis job/unit agnostic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Align WeightsFile help text with ArtifactName key Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #59443
Splits PR-CI Build and Analyze matrix generation into two independent LOC-weighted passes:
Buildmatrix targets ~1.2M LOC/batch (few big batches)Analyzematrix targets ~300k LOC/batch (more, smaller batches)This collapses the Build/Analyze wall-clock spread from 21-31 min down to <=7 min across 20/50/100-pkg PRs, with Analyze wall-clock down 23-50% and total agent-minutes roughly flat (-10% / -6% at 50/100 pkg).
See #59443 for full rationale, measurement methodology, and the comparison vs. simply shrinking batch size uniformly.
Artifact publishing
To keep the two matrix-gens fully independent (no ordering dependency), each pass publishes its own artifact:
BuildPackagesArtifact(consumed by Build jobs)AnalyzePackageInfoArtifact(consumed by Analyze jobs)Both matrix-gens still run in parallel; analyze jobs no longer wait for Build to publish.
Files changed
eng/pipelines/templates/jobs/ci.yml- parallel Build and Analyze matrix-gens, each with its own publishing artifacteng/pipelines/templates/steps/pr-matrix-presteps.yml- newEnableLocWeighting/LocTarget/PublishArtifactparams; LOC weighting at endeng/pipelines/templates/jobs/batched-build.yml(new)eng/pipelines/templates/jobs/batched-analyze.yml(new) - threadsArtifactNamethrough to analyze.ymleng/pipelines/templates/steps/analyze.yml- parameterized download artifact name (default preserves prior behavior)eng/scripts/Get-PackageLocWeights.ps1(new)eng/scripts/Apply-WeightedBatching.ps1(new)Measurement PRs
main): [DO NOT MERGE] CI measurement: 20pkg - Set B #59401 / [DO NOT MERGE] CI measurement: 50pkg - Set B #59402 / [DO NOT MERGE] CI measurement: 100pkg - Set B #59403