Skip to content

Spend less of a CI job installing Swift - #4

Merged
d-date merged 3 commits into
mainfrom
perf
Oct 22, 2026
Merged

d-date merged 3 commits into
mainfrom
perf

Conversation

@d-date

@d-date d-date commented Oct 22, 2026

Copy link
Copy Markdown
Member

Stacked on #3 (same files).

Why

Measured on main (run 39647073752), inside the action:

where the time went
Linux, cache hit restore 7–22 s, apt-get 9–12 s (mostly apt-get update), GPG ~3 s, tar -xzf 18–25 s — a cache hit was no faster than a download
Windows download 23 s, installer 70 s
macOS download 33 s, installer ~33 s

What

  • Linux
    • The packages needed only to run the toolchain (libcurl4-openssl-dev, uuid-dev, …) are installed in the background while the archive is fetched, verified and extracted, and waited for before the step ends; curl and gnupg2 are still installed first because they do the fetching and verifying.
    • apt-get install is tried against the image's package lists first and apt-get update runs only if that fails.
    • The archive is extracted with pigz when the runner has it.
  • macOS and Windows: the .pkg and the installer are cached (cache: true, as on Linux). The verification model does not change: a cached copy is copied to a private directory and its signature checked there on every run, only bytes that just passed are written to the cache, and a cached copy that fails fails the job. source reports cache.
  • Windows: new windows-minimal: true leaves out OptionsInstallDBG, OptionsInstallPy, OptionsInstallIDE and OptionsInstallAndroidPlatform. Default false, so nothing changes for existing users.
  • CI: an installer-cache-hit job (macOS, Windows) after install; the windows-noasserts job also uses windows-minimal.

Checked locally: shellcheck (as CI runs it), actionlint 1.7.12, PowerShell parse. The timings come from this PR's CI run.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Linux failure paths can leave background package installation running after the action exits, potentially causing lock conflicts in subsequent steps.

1 open issue
What changed in this PR

Reduces Swift setup time by overlapping Linux dependency installation with toolchain preparation and caching verified installers on macOS and Windows.

Changes:

  • Installs Linux runtime dependencies in the background, refreshes package lists only after failure, and uses pigz when available.
  • Caches macOS and Windows installers while re-verifying signatures on every run.
  • Adds an opt-in minimal Windows installation and installer cache-hit CI coverage.
File Description
README.md Documents caching, Linux optimizations, and minimal Windows installs.
install-windows.ps1 Adds verified installer reuse and minimal-install options.
install-macos.sh Adds verified package reuse and cache source reporting.
install-linux.sh Overlaps dependency installation and optimizes extraction.
action.yml Defines the new input and wires installer caching.
.github/​workflows/​ci.yml Tests installer cache hits and minimal Windows installs.

Review effort: Balanced

Comment thread install-linux.sh
fi

scratch="$(mktemp -d "${RUNNER_TEMP:-/tmp}/setup-swift.XXXXXX")"
trap 'rm -r -f "$scratch"' EXIT
Measured on main (run 39647073752): a Linux cache hit took as long as a
download, because 9-12 s went to apt-get (most of it the list refresh) and
18-25 s to extracting the archive; Windows spent 23 s downloading and 70 s
in the installer, macOS 33 s downloading.

- Linux: the packages needed only to run the toolchain install in the
  background while the archive is fetched, verified and extracted, from the
  image's package lists first; curl and gnupg2 still come first. The archive
  is extracted with pigz when the runner has it.
- macOS and Windows: the .pkg and the installer are cached. A cached copy is
  copied to a private directory and verified there on every run, and only
  bytes that just passed go into the cache; the source output says cache.
- Windows: windows-minimal leaves out the debugger, its Python, the IDE
  support and the Android platform.
…ache them

Measured on this PR's run: restoring them from the Actions cache took
22-35 s, against 23-33 s downloading them from swift.org, and on Windows the
copy and Authenticode check of the restored installer added 28 s more.
Left out on its own, each feature was measured on 6.4.1: without the IDE
feature swift.exe fails with ERROR_SXS_CANT_GEN_ACTCTX (14001), and without
the debugger, its Python or the Android platform hello world still builds.
Those three cut the installer from 71-83 s to about 57 s.
@d-date
d-date changed the base branch from windows-toolchain-variant to main October 22, 2026 02:12
@d-date d-date closed this Oct 22, 2026
@d-date d-date reopened this Oct 22, 2026
@d-date
d-date merged commit 114003a into main Oct 22, 2026
30 checks passed
@d-date
d-date deleted the perf branch October 22, 2026 05:33
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.

2 participants