Repository navigation
[build] Hydrate bin/ and obj/ from a scheduled main build cache - #13613
Draft
simonrozsival wants to merge 2 commits into
Draft
simonrozsival wants to merge 2 commits into
simonrozsival wants to merge 2 commits into
Conversation
Experimental, macOS + Release only. `make prepare USE_MAIN_BUILD_CACHE=1` restores bin/ and obj/ from a snapshot published by the scheduled public main build, so the first build of a fresh checkout is an incremental build of the commits since that snapshot plus local changes. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
simonrozsival
added a commit
that referenced
this pull request
Nov 21, 2026
Context: #13613 A second, unchanged `make leeroy CONFIGURATION=Release` still redid work on every run: * The `GenerateWorkloadDependencies` target had no `Inputs`/`Outputs` and ran `dotnet run`, which re-evaluated, restored, and built `workload-dependencies.csproj` before regenerating `WorkloadDependencies.json` (~5-10 s per build). Build the generator with the `<MSBuild/>` task in the active configuration, run its DLL with `$(DotNetPreviewTool)`, and make the target incremental. The command-line arguments are written to a state file (`WriteOnlyWhenDifferent`) that is one of the target inputs, so property changes still regenerate. When the manifest feed is a remote URL, the state file is always rewritten, so the target always runs. `Microsoft.NET.Sdk.Android.proj` now forwards `$(DotNetPreviewTool)`. * `Xamarin.Android.Tools.Bytecode-Tests.targets` declared `classes/com/xamarin/module-info.class` as an output of the `BuildClasses` target, but `javac` writes module descriptors to the output root (`classes/module-info.class`). The missing output reran `javac` and the test project's C# compile on every build. * The `BuildExtraApiLevels` invocation in `BuildEverything.mk` restored `Microsoft.Android.slnx` again, although the preceding `leeroy` invocation just restored it. Pass `--no-restore`. * `eng/install-dotnet.sh` always ran `dotnet-install.sh`, which spends several seconds checking an SDK that is already installed. Exit early when `dotnet --list-sdks` already contains the exact pinned version. `DeleteExtractedWorkloadPacks` (from #13406) still deletes and reinstalls `Microsoft.Android.Sdk.Darwin` from the feed on every `ConfigureLocalWorkload` run. That is intentional, so it is not changed here. Validation on macOS arm64, Release, in a fresh worktree: * `make prepare CONFIGURATION=Release && make leeroy CONFIGURATION=Release`: succeeded. * A second `make leeroy CONFIGURATION=Release`: succeeded; `GenerateWorkloadDependencies` and `BuildClasses` were skipped as up to date. * `./dotnet-local.sh test tests/Xamarin.Android.Tools.Bytecode-Tests/Xamarin.Android.Tools.Bytecode-Tests.csproj -c Release`: 132 passed, 2 skipped. Co-authored-by: Copilot App <[email protected]>
This branch has not been deployed
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.
Draft for discussion; experimental, macOS + Release only. The last commit (
DO NOT MERGE) publishes the snapshot from PR builds so the download path can be tested against a real artifact; it will be dropped.A clean local Release build (
make prepare && make leeroy) takes ~280 s on an M-series Mac, and every new worktree, including each agent session, pays it. Most of that work was already done by the scheduled publicmainbuild.make prepare CONFIGURATION=Release USE_MAIN_BUILD_CACHE=1runsbuild-tools/scripts/main-build-cache.cs apply(a file-based C# app) beforeinstall-dotnet:mainbuild of pipeline 333 whose commit is an ancestor ofHEAD, and downloads itsazdo-main-build-cache-macos-<arch>-releaseartifact withazinto~/.azdo-main-build-cache/<repo>/…. A file lock ensures concurrent callers download it once; older entries are pruned.bin/andobj/into the checkout and writes the snapshot commit toobj/azdo-main-build-cache/commit.leeroythen builds only the commits since the snapshot and local changes incrementally.Making the restored outputs up to date
Copying outputs is not enough; without the following nearly everything rebuilds:
.editorconfigs, SourceLink maps, CMake/ninja trees undersrc/native/obj, and*.inputsfiles are relocated to the new checkout, with timestamps preserved.CoreCompileinputs by absolute path.obj/azdo-main-build-cache/MainBuildCache.targets(imported via$(CustomAfterMicrosoftCommonTargets)bymakeanddotnet-local.sh) recomputes the hash with paths mapped back to the snapshot's roots, and keeps the old fingerprint only when they match.$(XAVersionBranch),$(XAVersionHash),$(XAVersionCommitCount)and$(PackVersionCommitCount)to the snapshot's values. Otherwise a different branch name or commit count changes version files, the workload manifest and the pack versions, which rebuilds most of the SDK. Deletingobj/azdo-main-build-cachestops pinning.applyrefuses to run over existing outputs, withConfiguration.Override.props, or when build definitions changed or non-C# inputs were added since the snapshot; those cases need a clean build.Results
Apple Silicon Mac, Release,
prepare+leeroy:With a later local snapshot, a hydrated build had 0
CoreCompileruns inprepareand 3 inleeroy. The remaining time is mostly MSBuild evaluation, workload setup and the one-time compile of the file-based app (~34 s). Wall times on a shared, loaded host varied a lot, so treat these as indicative.Open questions
Validation
dotnet test tests/AzdoMainBuildCache-Tests: passed (34 tests).createa snapshot, hydrate a fresh worktree from it withMAIN_BUILD_CACHE_SNAPSHOT=…, thenmake leeroy CONFIGURATION=Release: succeeded, 0/3 recompiles as above.createreturns the four properties, and a hook with fake values overrides them, including the derived$(AndroidPackVersionLong).az; this draft's CI artifact is meant to test it for real.