Skip to content

PR-CI: Split Build and Analyze into independent LOC-based batched matrices - #59444

Merged
m-nash merged 10 commits into
mainfrom
feature/split-build-analyze-loc
May 26, 2026
Merged

PR-CI: Split Build and Analyze into independent LOC-based batched matrices#59444
m-nash merged 10 commits into
mainfrom
feature/split-build-analyze-loc

Conversation

@m-nash

@m-nash m-nash commented May 26, 2026

Copy link
Copy Markdown
Member

Fixes #59443

Splits PR-CI Build and Analyze matrix generation into two independent LOC-weighted passes:

  • Build matrix targets ~1.2M LOC/batch (few big batches)
  • Analyze matrix 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:

  • Build matrix-gen publishes BuildPackagesArtifact (consumed by Build jobs)
  • Analyze matrix-gen publishes 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 artifact
  • eng/pipelines/templates/steps/pr-matrix-presteps.yml - new EnableLocWeighting / LocTarget / PublishArtifact params; LOC weighting at end
  • eng/pipelines/templates/jobs/batched-build.yml (new)
  • eng/pipelines/templates/jobs/batched-analyze.yml (new) - threads ArtifactName through to analyze.yml
  • eng/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

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>

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 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.

Comment thread eng/pipelines/templates/jobs/ci.yml
Comment thread eng/pipelines/templates/steps/pr-matrix-presteps.yml Outdated
Comment thread eng/pipelines/templates/steps/pr-matrix-presteps.yml Outdated
Comment thread eng/scripts/Apply-WeightedBatching.ps1
Comment thread eng/scripts/Get-PackageLocWeights.ps1
m-nash and others added 2 commits May 26, 2026 10:16
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>
Comment thread eng/scripts/Get-PackageLocWeights.ps1
m-nash and others added 2 commits May 26, 2026 12:44
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

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

Comment thread eng/scripts/Get-PackageLocWeights.ps1 Outdated
Comment thread eng/scripts/Apply-WeightedBatching.ps1 Outdated
Comment thread eng/pipelines/templates/steps/pr-matrix-presteps.yml Outdated
Comment thread eng/pipelines/templates/jobs/ci.yml
m-nash and others added 3 commits May 26, 2026 12:59
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>

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread eng/scripts/Apply-WeightedBatching.ps1
Comment thread eng/scripts/Apply-WeightedBatching.ps1 Outdated
m-nash and others added 2 commits May 26, 2026 13:26
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread eng/scripts/Apply-WeightedBatching.ps1
@m-nash
m-nash requested a review from Copilot May 26, 2026 20:48

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@m-nash
m-nash merged commit 4564b9f into main May 26, 2026
29 checks passed
@m-nash
m-nash deleted the feature/split-build-analyze-loc branch May 26, 2026 21:17
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>
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.

PR-CI: Split Build and Analyze matrix generation to use independent LOC-based batching

5 participants