Skip to content

[performance] Build Android native assets on Linux - #4818

Closed
mattleibow wants to merge 1 commit into
mainfrom
mattleibow-move-android-native-ci-linux
Closed

mattleibow wants to merge 1 commit into
mainfrom
mattleibow-move-android-native-ci-linux

Conversation

@mattleibow

@mattleibow mattleibow commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Build the four shipping Android native ABIs in parallel on Linux using a dedicated thin Azure Linux Android container instead of provisioning Windows hosts.

The image uses Microsoft's prepared dotnet-buildtools/prereqs Azure Linux 3.0 Android image pinned by immutable manifest digest. It validates the included NDK as r27c (27.2.12479018), installs .NET SDK 10.0.108 from the official archive after verifying its published SHA-512, and confirms Ninja is available. The startup log records the NDK path, Ninja version, and container CPU count.

Windows and macOS Android jobs are removed per the final host-coverage decision. The four Linux artifacts become the canonical inputs to native merge. The existing Cake path still performs the same GN/NDK builds, feature configuration, debug-symbol extraction, stripping, GNU debug links, and 16 KiB LOAD-alignment checks.

Performance

Uncached public definition-345 runs:

ABI Windows baseline 1556384 Linux container 1559377
x86 20m07s 14m57s
x64 20m47s 15m59s
arm 20m58s 14m35s
arm64 21m08s 15m11s
Total agent time 83m00s 60m43s
Critical Android job 21m08s 15m59s

This saves 22m17s / 26.8% of Android agent time and 5m09s / 24.4% on the Android critical path. The Linux jobs spent 1m54s-2m08s building the thin image and 11m13s-11m29s in the source bootstrapper. Native Linux stage duration was 26m15s; build queue wait was 6m25s.

Related issues

N/A.

Required skia PR

None.

Areas affected

  • Managed API (binding/)
  • Native / C API (externals/skia/src/c, include/c)
  • Generated P/Invoke bindings
  • Native dependency or Skia update
  • Views & integrations
  • Rendering output / visual behavior
  • Performance
  • Tests
  • Build, packaging, or CI
  • Documentation or samples

Changes

None — CI-only; no public API, ABI, shipped Android ABI, package content, security scan, or observable runtime behavior changes.

Testing

Uncached public definition-345 build 1559377 validated merge commit e047804f60d6c23673c501b38c256fb5eed39cad end to end:

  • Android x86, x64, arm, and arm64 source jobs succeeded in 14m57s, 15m59s, 14m35s, and 15m11s.
  • Native Windows, macOS, Linux, WASM, and Tizen source stages succeeded.
  • Full native, Linux, and WASM merge jobs succeeded in 17m23s, 7m47s, and 4m29s.
  • Native merge explicitly downloaded and moved all four native_android_*_linux artifacts; native, native_linux, and native_wasm artifacts published successfully.
  • Every Linux and Windows-baseline ABI artifact contains exactly libSkiaSharp.so, libSkiaSharp.so.dbg, libHarfBuzzSharp.so, and libHarfBuzzSharp.so.dbg.
  • ELF class/machine matches x86, x86-64, ARM EABI5, and AArch64 respectively.
  • Candidate and Windows baseline dynamic-symbol name sets match exactly for both libraries on every ABI: SkiaSharp 3520/3506/3521/3511 symbols and HarfBuzzSharp 5813/5806/5868/5816 symbols.
  • DT_NEEDED sets match exactly for all eight library comparisons.
  • Every candidate and baseline LOAD segment is 16 KiB aligned, and every stripped .so contains its GNU debug link.
  • Expected host/build-path-dependent binary and debug bytes differ, while loader requirements and shipping interfaces are unchanged.
  • Auto-injected Component Detection remained present on each Android job; no scanning or artifact-publication templates were bypassed.
  • Azure Pipelines preview compiled exactly four Android source jobs on buildAgentLinuxNative, with no Windows/macOS Android source jobs.

The complete run succeeded before automation resumed, so downstream stages were not canceled in time; this does not affect the native timing or artifact evidence above.

Checklist

  • Tests added or updated (not applicable: CI-only host change; validated with uncached source builds, native merges, ELF comparison, and the full public pipeline)
  • Changes above lists all public API and behavioral changes (or "None.")
  • New/changed public API? N/A
  • Native change? N/A; no C API/submodule change or companion mono/skia PR required

Move all four Android ABI builds into a pinned Azure Linux Android container and make those artifacts the canonical native merge inputs. Remove the redundant Windows and macOS Android jobs while preserving the existing source build, symbol extraction, and alignment validation paths.

Co-authored-by: Copilot App <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

📦 Try the packages from this PR

Warning

Do not run these scripts without first reviewing the code in this PR.

Step 1 — Download the packages

bash / macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4818

PowerShell / Windows:

iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4818"

Step 2 — Add the local NuGet source

dotnet nuget add source ~/.skiasharp/hives/pr-4818/packages --name skiasharp-pr-4818
More options
Option Description
--successful-only / -SuccessfulOnly Only use successful builds
--force / -Force Overwrite previously downloaded packages
--list / -List List available artifacts without downloading
--build-id ID / -BuildId ID Download from a specific build

Or download manually from Azure Pipelines — look for the nuget artifact on the build for this PR.

Remove the source when you're done:

dotnet nuget remove source skiasharp-pr-4818

@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation for this PR has been deployed and is available at:

🔗 View Staging Site
🔗 View Staging Docs
🔗 View Staging Gallery (Blazor)
🔗 View Staging Gallery (Uno Platform)
🔗 View Staging SkiaFiddle

This preview will be updated automatically when you push new commits to this PR.


This comment is automatically updated by the documentation staging workflow.

@github-actions

Copy link
Copy Markdown
Contributor

📊 SkiaSharp benchmarks — PR #4818

⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS

Informational only — this never blocks the PR. 🟢 faster / less allocation · 🔴 slower / more allocation; moves under 5% are hidden as noise.

⏱️ Times are raw BenchmarkDotNet means, and the ⭐ PR and baseline legs run on separate CI runners, so microbenchmarks can swing run-to-run — treat small time deltas as noise. Allocations are deterministic and the reliable signal. The interactive perf-dashboard (linked below) applies smoothing for the trend view.

Highlights

⏱️ Time — 🔴 40 slower · 🟢 30 faster

  • 🟢 ColorMathBenchmark.ToColor(Colors: 4096) · Linux · 14.99 µs → 7.62 µs (-49%)
  • 🔴 RuntimeEffectShaderBenchmark.DrawFrame · Linux · 2.85 ms → 4.15 ms (+46%)
  • 🔴 RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) · Windows · 96.45 µs → 136.55 µs (+42%)
  • 🟢 ColorMathBenchmark.PreMultiply(Colors: 4096) · Linux · 12.87 µs → 7.67 µs (-40%)
  • 🟢 ColorMathBenchmark.UnPreMultiply(Colors: 4096) · Linux · 11.44 µs → 6.95 µs (-39%)
  • …and 65 more (see details below)

📦 Allocations — 🔴 1 more alloc · 🟢 0 less alloc

  • 🔴 RuntimeEffectShaderBenchmark.DrawFrame · Linux · 683 B → 733 B (+7%)
Full per-OS benchmark deltas

Linux

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
ColorMathBenchmark.ToColor(Colors: 4096) 14.99 µs 7.62 µs 🟢 -49%
RuntimeEffectShaderBenchmark.DrawFrame 2.85 ms 4.15 ms 🔴 +46%
ColorMathBenchmark.PreMultiply(Colors: 4096) 12.87 µs 7.67 µs 🟢 -40%
ColorMathBenchmark.UnPreMultiply(Colors: 4096) 11.44 µs 6.95 µs 🟢 -39%
ColorParseBenchmark.Parse(Iterations: 1000) 74.14 µs 47.40 µs 🟢 -36%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 71.97 µs 48.62 µs 🟢 -32%
MatrixMapPointsBenchmark.MapPoint(Points: 256) 4.51 µs 3.05 µs 🟢 -32%
MatrixOpsBenchmark.Invert(Count: 4096) 130.80 µs 89.60 µs 🟢 -32%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 2048) 2.92 ms 2.01 ms 🟢 -31%
LargeImageScaleBenchmark.UpscaleOpaque(Size: 1024) 757.90 µs 534.21 µs 🟢 -30%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 257.65 µs 182.49 µs 🟢 -29%
MatrixOpsBenchmark.Concat(Count: 4096) 218.29 µs 155.79 µs 🟢 -29%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 960.46 µs 706.46 µs 🟢 -26%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.33 ms 982.51 µs 🟢 -26%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 254.11 µs 189.05 µs 🟢 -26%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 18.07 ms 22.65 ms 🔴 +25%
PathBoundsBenchmark.TightBounds(Points: 64) 977.7 ns 730.6 ns 🟢 -25%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 13.72 µs 10.29 µs 🟢 -25%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 351.94 µs 264.71 µs 🟢 -25%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 216.94 µs 164.99 µs 🟢 -24%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 3.94 ms 4.87 ms 🔴 +24%
PathBoundsBenchmark.TightBounds(Points: 1024) 10.15 µs 7.86 µs 🟢 -23%
LargeImageScaleBenchmark.UpscaleCrossfade(Size: 2048) 7.96 ms 6.18 ms 🟢 -22%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 100.53 µs 78.55 µs 🟢 -22%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 174.32 µs 136.34 µs 🟢 -22%
…and 8 more

📦 Allocations (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
RuntimeEffectShaderBenchmark.DrawFrame 683 B 733 B 🔴 +7%

Windows

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 96.45 µs 136.55 µs 🔴 +42%
ColorMathBenchmark.ToColor(Colors: 4096) 11.93 µs 16.22 µs 🔴 +36%
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 238.66 µs 312.90 µs 🔴 +31%
PathBoundsBenchmark.TightBounds(Points: 1024) 16.70 µs 21.02 µs 🔴 +26%
PathBoundsBenchmark.TightBounds(Points: 64) 1.61 µs 1.98 µs 🔴 +23%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 153.16 µs 178.99 µs 🔴 +17%
MatrixMapPointsBenchmark.MapRadius(Points: 256) 9.81 µs 11.25 µs 🔴 +15%
ColorParseBenchmark.Parse(Iterations: 1000) 77.81 µs 86.86 µs 🔴 +12%
CanvasDrawBenchmark.Draw(Shapes: 512) 20.57 ms 22.95 ms 🔴 +12%
MatrixMapPointsBenchmark.MapRect(Points: 256) 8.53 µs 9.50 µs 🔴 +11%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 128.91 µs 142.34 µs 🔴 +10%
CanvasDrawBenchmark.Draw(Shapes: 64) 2.65 ms 2.88 ms 🔴 +9%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 137.55 µs 149.32 µs 🔴 +9%
ColorMathBenchmark.PreMultiply(Colors: 4096) 14.74 µs 15.82 µs 🔴 +7%
MatrixOpsBenchmark.Concat(Count: 4096) 256.01 µs 273.15 µs 🔴 +7%
MatrixMapPointsBenchmark.MapVector(Points: 256) 8.88 µs 9.46 µs 🔴 +7%
MatrixMapPointsBenchmark.MapPoints(Points: 256) 182.7 ns 194.5 ns 🔴 +6%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 256) 969.18 µs 1.03 ms 🔴 +6%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 256) 1.34 ms 1.41 ms 🔴 +5%

macOS

⏱️ Time (vs 🌙 nightly 4.152.0-nightly.10)

Benchmark baseline this PR Δ
RasterImageLifecycleBenchmark.CreateRasterImage(Count: 256) 141.56 µs 183.65 µs 🔴 +30%
RasterImageLifecycleBenchmark.CreateDataWithReleaseProc(Count: 256) 66.42 µs 84.05 µs 🔴 +27%
MatrixMapPointsBenchmark.MapRect(Points: 4096) 49.43 µs 60.90 µs 🔴 +23%
MatrixOpsBenchmark.Invert(Count: 4096) 65.06 µs 77.50 µs 🔴 +19%
RuntimeEffectShaderBenchmark.DrawFrame 507.38 µs 584.79 µs 🔴 +15%
MatrixMapPointsBenchmark.MapRadius(Points: 4096) 97.96 µs 112.31 µs 🔴 +15%
PathBoundsBenchmark.TightBounds(Points: 64) 850.3 ns 967.7 ns 🔴 +14%
MatrixMapPointsBenchmark.MapPoint(Points: 4096) 18.14 µs 20.56 µs 🔴 +13%
BitmapDrawBenchmark.DrawScaledTiles(Tiles: 64) 195.71 µs 221.70 µs 🔴 +13%
SceneRenderBenchmark.RenderFrame(Complexity: 1) 1.18 ms 1.33 ms 🔴 +13%
MatrixMapPointsBenchmark.MapRect(Points: 256) 3.05 µs 3.42 µs 🔴 +12%
MatrixOpsBenchmark.Concat(Count: 4096) 111.66 µs 124.86 µs 🔴 +12%
SceneRenderBenchmark.RenderFrame(Complexity: 4) 5.40 ms 6.04 ms 🔴 +12%
BitmapDrawBenchmark.DrawUnscaledTiles(Tiles: 64) 148.63 µs 165.67 µs 🔴 +11%
MatrixMapPointsBenchmark.MapPoints(Points: 4096) 1.52 µs 1.67 µs 🔴 +10%
MatrixMapPointsBenchmark.MapVector(Points: 4096) 39.10 µs 43.01 µs 🔴 +10%
ColorParseBenchmark.Parse(Iterations: 1000) 63.10 µs 68.10 µs 🔴 +8%
PathBoundsBenchmark.TightBounds(Points: 1024) 8.07 µs 8.49 µs 🔴 +5%

📈 Full interactive perf-dashboard & run details →

@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

📦 Artifact size report

Packages from this PR (build 1559377) vs the latest nightly baseline 4.152.0-nightly.17 (observed 2026-08-19).

Total .nupkg size: 569.8 MB → 569.0 MB (−876.7 KB, -0.2%)

Packages

⚠️ marks growth over 500.0 KB or 2%. Changes under 50.0 KB are treated as noise.

Package baseline this PR Δ Δ%
SkiaSharp.NativeAssets.WinUI 109.1 MB 108.5 MB 🟢 −703.8 KB -0.6%
SkiaSharp.NativeAssets.Android 18.1 MB 17.9 MB 🟢 −257.2 KB -1.4%
SkiaSharp.NativeAssets.WebAssembly 69.7 MB 69.7 MB 🔴 +63.2 KB +0.1%

+37 package(s) unchanged (< 50.0 KB).

Per-file changes

SkiaSharp.NativeAssets.Android

File Size
🧬 android-x86 (runtimes/android-x86/native/libSkiaSharp.so) 11.8 MB → 11.0 MB (🟢 −802.2 KB)

SkiaSharp.NativeAssets.WinUI

File Size
runtimes/win-x64/native/libGLESv2.pdb 66.6 MB → 66.5 MB (🟢 −96.0 KB)
runtimes/win-arm64/native/libGLESv2.pdb 64.5 MB → 64.4 MB (🟢 −80.0 KB)
runtimes/win-x86/native/libGLESv2.pdb 67.2 MB → 67.2 MB (🟢 −32.0 KB)

Informational only — this never blocks the PR. Native binaries are labelled by os/arch.

@mattleibow mattleibow changed the title [CI] Build Android native assets on Linux [performance] Build Android native assets on Linux Aug 19, 2026
mattleibow pushed a commit that referenced this pull request Aug 19, 2026
Build all four shipping Android ABIs in the pinned Linux container, remove the Windows and macOS duplicates, and consume the Linux artifacts in native merge.\n\nCo-authored-by: Copilot App <[email protected]>\nCopilot-Session: aaededd0-4f67-43d2-9c48-94ae5d66f885
@mattleibow

Copy link
Copy Markdown
Contributor Author

Combined into #4815 so the native setup, Linux Docker Android migration, and package build reductions can be reviewed and merged as one performance change.

@mattleibow mattleibow closed this Aug 19, 2026
mattleibow added a commit that referenced this pull request Aug 20, 2026
[performance] Build Android on Linux and reduce CI overhead (#4815)

Context: #4816
Context: #4818
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1557164
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1559377
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1559994
Context: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1560012
Context: https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=15017102
Context: https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=15030082
Context: https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=15032120
Context: https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=15032942

Move Android native production to four Linux-container jobs, make native
bootstrap setup match the work each job performs, and stop special-package
creation from rebuilding managed outputs. The final cache-disabled public run
completed in 3h30m15s instead of 6h17m44s for cold main; raw agent usage fell
from 3,087.2 to 1,562.4 minutes. Main receives additional policy-injected work,
so those are end-to-end operational figures; the direct task and topology
measurements below are the causal evidence.

The final public run succeeded end to end. DevDiv native and package/signing
runs also succeeded. Its test run passed managed builds, samples, and every test
job except a macOS tests-netcore job canceled at 180 minutes without a product
or test error. Exact-main DevDiv and the automatic public PR run reproduced the
same timeout, while the cache-disabled final run passed macOS tests, so the hang
was accepted as pre-existing and non-blocking.

~~ Native bootstrap and checkout ~~

Container-native jobs installed Python, Ninja, and .NET on the host even though
the toolchain and Cake invocation run inside the image. Native source jobs also
initialized every submodule, while merge-only jobs fetched source they never
used and configured build variables a second time on cache misses.

Skip host Ninja and .NET for Docker-native jobs, retain Python whenever direct
execution or cache-key computation needs it, and preserve every direct
Windows/macOS prerequisite. Source jobs now initialize only Skia and
depot_tools; merge jobs initialize no submodules; build variables are configured
once. The new controls default to the old managed-job behavior.

Across the paired runs, full recursive submodule checkouts fell from 65 to zero,
replaced by 56 targeted native checkouts. Python selection fell from 88 to 38,
Ninja installation from 61 to 15, and .NET installation from 85 to 39, while the
119 required artifact downloads were preserved.

~~ Android native production ~~

The four Android ABIs were built on Windows and duplicated on macOS even though
native merge consumed only the Windows artifacts. Enable the existing Android
Cake targets on Linux, build x86, x64, arm, and arm64 in four parallel Docker
jobs, remove both host matrices, and make the Linux artifacts canonical merge
inputs.

The image tracks Microsoft's Azure Linux Android prerequisite tag, verifies
NDK r27c (27.2.12479018) and Ninja, and installs .NET SDK 10.0.108 with
the repository's standard dotnet-install script because the prerequisite image
does not contain the SDK. Startup diagnostics record the NDK path, CPU count,
and Ninja version. The moving base tag is not part of the output-cache key, so
a remote tag update is consumed only after a cache miss, cache-disabled run, or
tracked input change; it is deliberately not pinned by digest.

This replaces eight host jobs with four Linux jobs. In the paired cold runs,
Android agent usage fell from 429.9 to 61.6 minutes and the critical job from
1h14m10s to 15m34s. Across all four ABIs, both native libraries retained the
four-file .so/.dbg inventory, matching ELF machines, exported dynamic symbols,
DT_NEEDED sets, GNU debug links, and 0x4000 LOAD alignment.

~~ Special-package work ~~

nuget-special creates internal wrapper packages from existing native, normal
NuGet, and symbol outputs, but its root target depended on libs and rebuilt the
managed graph. Its separate job also installed Node, Android SDK/JDK, workloads,
and every submodule even though none participates in wrapper creation.

Remove the libs dependency while keeping normal and special packaging as
separate, ordered jobs. Normal packaging keeps Node for TypeScript-backed
projects and checks out only the API-docs submodule. Special packaging consumes
the published normal/native artifacts, checks out no submodules, and skips Node,
Android, and workload provisioning while retaining the .NET SDK, tool restore,
and Visual Studio selection. Output rearrangement runs only on cache misses so
restored artifacts keep their published layout.

The package stage fell from 2h21m00s to 43m36s, with the special job
falling from 1h08m07s to 12m51s. All six package artifacts remained, their sizes
matched cold main within 1%, package scanning passed, and DevDiv signing
completed.

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants