Repository navigation
[build] Make local no-op SDK builds incremental - #13774
Draft
simonrozsival wants to merge 5 commits into
Draft
simonrozsival wants to merge 5 commits into
simonrozsival wants to merge 5 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Give BuildExtraApiLevels real file inputs and track its output set so no-op solution builds can skip extra API-level builds while detecting changed profiles, changed settings, and missing pack outputs. Co-authored-by: Copilot App <[email protected]>
Generate native runtime lists only for the existing API-level packs and track managed lists independently. Restore missing extra-API analyzers and incomplete workload packs, and combine workload restore and installation. Co-authored-by: Copilot App <[email protected]>
7 tasks
Upgrade SourceLink so worktrees whose branch refs are packed retain the correct revision and do not trigger a solution-wide rebuild when source metadata changes. Exclude its compile and runtime assets to avoid conflicting with the System.IO.Hashing version used by Android build tasks. 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.
Stacked on #13430. Context: dotnet/sourcelink#1290, dotnet/roslyn#86006.
With the
dotnet build Microsoft.Android.slnxentry point, a build with no source changes still took ~19 s locally, and every C# or Java edit paid that cost before doing useful work. Incorrect inputs and outputs, unconditional file writes, and local workload work contributed to repeated builds:WorkloadManifest.json/.targetstimestamps when their contents have not changed, so they no longer invalidate workload installation on every build.WorkloadDependencies.projfor the local workload; packing the shipped manifest still generatesdata/WorkloadDependencies.json.module-info.classoutput, exclude the templates project'sbin/andobj/from template inputs, and touch the copiedjava-source-utils.jarso these targets can become up to date.BuildExtraApiLevelsfile-based inputs and a stamp output, with state for relevant input settings and generated files. Missing files and changed API-specific profiles still trigger recovery; lists and asset caches produced by later workload setup are excluded.Worktree revision accuracy
SourceLink 8 could report
Repository has no commitin a Git worktree when the branch ref was packed in Git's common directory. A succeeding build could loseSourceRevisionId, changingAssemblyInformationalVersionand causing solution-wide recompilation without any source edit. UpgradeMicrosoft.SourceLink.GitHubto 10.0.301, which resolves the packed-ref fixture correctly. Exclude its transitive compile and runtime assets so itsSystem.IO.Hashing10.0.10 dependency does not conflict with the repository's direct 12.0 dependency; its build tasks retain their own required assemblies.Performance
Apple M5 Max (18 cores, 64 GB), macOS 26.7.3, .NET SDK
12.0.100-alpha.1.26551.101viadotnetup.Earlier full-build comparison
Each scenario ran
dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:falsein two worktrees: before = #13430 headd0aa1bfd5a, after = this branch ata9806c076d, before the extra-API and later changes. Runs were sequential and interleaved before/after. The shared host's one-minute load ranged from 5 to 25; differences below ~10% for builds longer than a minute are within noise. “Edit” appends a comment; “revert” restores it and is itself a source change.git clean -xdf)Xamarin.Android.Build.Tasksedit (MonoAndroidHelper.cs)MonoPackageManager.java)src/native/clr/host/host.cc)Mono.Androidedit (JNIEnv.cs)¹ Single clean runs at load ~14 do not establish a reliable difference. The second build still costs ~135 s because the first does not converge; that is a separate issue. ² Load rose from 14 to 25 during the after-edit run; single samples do not establish the cause. Compiling
Mono.Android.dlland dependent packs remains expensive.Runtime lists and workload installation
Three interleaved targeted
CreateLocalRuntimeListsruns took 33.45, 32.21 and 33.35 seconds before (median 33.35 s) and 14.84, 14.82 and 14.65 seconds after limiting native lists to existing packs (median 14.82 s). Child builds fell from 21 to nine. These precede the managed-list invalidation fix and are not full-solution timings.Three interleaved full-solution no-op pairs compared separate workload restore and install processes with the combined process: medians 16.03 s (15.98–16.26) and 14.45 s (14.18–16.21), respectively;
InstallWorkloadPackstarget medians were 2.998 and 1.703 seconds. Host load fell from ~40 to 18, confounding the wall-time comparison. Pack resolution and the combined restore/install process still run on no-op builds, but extraction/copy targets skip when current.Later full-build samples
The same Debug solution command, with warm caches, gave these unpaired samples; they are not a controlled comparison with the earlier revisions:
e1583cf69f(three runs)JNIEnv.csedit / revert aftere1583cf69fe1583cf69f(three runs)e1583cf69fe1583cf69fJNIEnv.csedit beforee1583cf69fbin/Release691e8c6582(three runs)Binding edits/reverts rebuilt all three API-level assemblies. The
e1583cf69fno-ops started at load 6–7 and its edit/revert at load 9–15. Load rose from ~26 to over 80 during the pre-commit binding edit, so 396.07 s is not a reliable comparison; the matching revert succeeded but the computer slept for 12,399 s. Native edit/revert each ran six native compilation commands. The Release run used warm caches and potentially existing intermediates; it is not a clean comparison.After the SourceLink commit changed HEAD, the first Debug solution build took 317.80 s and made 128
Csccalls after the revision changed. The following three no-ops invoked noCsctasks. Load rose from ~34 to 65 during the first build and was ~51–65 during the no-ops, so those timings are not comparable to the quieter earlier runs. C# and C++ edits were not remeasured at final HEAD under this load. The pre-commit 12.50 s median is unpaired and does not establish an ordinary no-op speedup from SourceLink.The SourceLink failure was a pathological transition rather than a normal no-op baseline: a 100.08 s build was followed without source changes by a 147.30 s build with 128
Csccalls, then 19.78 and 12.51 s builds. The slow follow-up changed the assembly informational version from1.0.0+<HEAD>to1.0.0.Per-target times from earlier no-op binlogs:
_GenerateXAWorkloadContentInstallManifestAndDependenciesBuildClasses+BuildJarBuildExtraApiLevels6cc11e7e5f)The sub-second no-op and sub-minute binding-edit goals remain unmet.
Preparestill starts three child builds (~4.7 s in the earlier no-op), workload setup and full solution traversal remain, and the binding edit rebuilds three API-level assemblies. The binding-edit binlog recorded three compiler calls totalling 60.9 s and 41.2 s insideBuildExtraApiLevels; these inclusive totals overlap and are not additive wall times.Isolated compiler-cache prototype (not shipped)
An owned compiler trace showed contention in Roslyn's control-flow-graph cache, also reported in dotnet/roslyn#86006. In a session-owned copy of the pinned SDK compiler, a diagnostic prototype replaced that cache's
ConcurrentDictionary.Count > 0check with!IsEmpty. The installed SDK was not modified and the prototype is not part of this change.Eight interleaved standalone
Mono.Android.csprojDebug builds used-m:1 -nr:false -p:UseSharedCompilation=false, identical compiler arguments and enabled analyzers, touching the unchangedJNIEnv.csbefore each to force compilation. Stock builds took 110.62, 93.37, 88.00, 66.26 s (median 90.69 s); prototype builds took 76.91, 62.08, 68.06, 59.47 s (median 65.07 s). MedianCsctask time was 68.09 → 51.53 s. Reference/implementation DLL, PDB and diagnostic-text hashes matched in all eight runs. The shared host's one-minute load varied from approximately 33 to 68; these are not full-solution timings and are not controlled enough to claim a precise general speedup. They support investigating the upstream fix, not shipping a patched compiler.Experiments not retained
Configuration.Override.propscould leave stale metadata. It was reverted. Before C# samples were 126.55/111.10/112.13 s and candidate samples 89.43/81.79/83.68 s, but the overall difference is confounded by host load and compilation variation.Prepareruns (6.42/6.16/5.39 s versus 5.86/5.37/5.35 s) and workload-tool--no-restore/static-graph variants showed no reliable gain.Validation
dotnetup dotnet pack build-tools/create-packs/Microsoft.NET.Sdk.Android.proj -c Debug -o /tmp/mpack: passed; the manifest package containsWorkloadDependencies.json,WorkloadManifest.jsonandWorkloadManifest.targets../dotnet-local.sh new android -o /tmp/benchapp/App1 && ./dotnet-local.sh build /tmp/benchapp/App1 -c Debug: passed and produced a signed APK. Changing and reverting a template andWorkloadManifest.in.jsonrepacked the templates and updated/restored the installed manifest.dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:false -v:diag: two no-op runs passed in 16.86/17.16 s with zero warnings/errors and skippedBuildExtraApiLevels. Touching the 37.1 profile reran it (four RS0025 warnings, no errors); deleting a generated 37.1Java.Interop.dllrestored it, and the following no-op skipped the target.e1583cf69f, three no-ops passed without warnings;JNIEnv.csedit/revert builds each passed with 10 warnings and rebuilt all three API assemblies.dotnetup dotnet build build-tools/workload-tools/workload-tools.csproj -c Debug -m:4 -nr:falseanddotnetup dotnet build build-tools/create-packs/Microsoft.Android.Sdk.proj -c Debug -m:4 -nr:false -t:InstallManifestAndDependencies: passed; generated dependency-project content and timestamp stayed unchanged.-t:CreateLocalRuntimeListspassed no-op, per-API managed-input change, missing managed/native-list recovery, and a subsequent no-op; all nine lists matched their previous contents and were registered inFileWrites. With-t:CreateLocalFrameworkLists, a deleted 37.1 analyzer was restored byte-for-byte and the next invocation skipped copying../dotnet-local.sh build "$app" -c Debug -p:TargetPlatformVersion=<37.0|37.1|37.2>: all three API-level CoreCLR smoke builds passed. Release API 37.1 and optimized Debug NativeAOT/arm64 smoke builds also produced signed APKs; the NativeAOT build reported_AndroidRuntime=NativeAOTand included the native app library.dotnetup dotnet build Microsoft.Android.slnx -c Debug -m:4 -nr:false -clp:PerformanceSummary "-bl:$logdir/sourcelink-final-head-full.binlog"at691e8c6582: passed, as did three subsequent no-ops; the no-ops invoked no C# compiler and SourceLink mapped the current HEAD.dotnetup dotnet build Microsoft.Android.slnx -c Release -m:4 -nr:false -warnaserror:MSB3277 "-bl:$logdir/sourcelink-fixed-release-full.binlog"passed before the final commit, as did targeted NativeAOT and Android SDK builds with the same warning-as-error setting.dotnetup dotnet test tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj -c Debug -m:4 -nr:false "-bl:$logdir/sourcelink-final-basetasks-tests.binlog": 167 passed, 4 skipped at final HEAD.dotnetup dotnet test tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj -c Debug -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=10.0 --no-build --environment "HOME=$testhome": 450 passed, 7 skipped with$testhomeset to an isolated directory. The first attempt encountered an unrelated host JDK discovery conflict.