Skip to content

GHA/windows: reduce number MSYS2 package cache entries - #23155

Closed
vszakats wants to merge 22 commits into
curl:masterfrom
vszakats:gha-w-try-cacheopt
Closed

vszakats wants to merge 22 commits into
curl:masterfrom
vszakats:gha-w-try-cacheopt

Conversation

@vszakats

@vszakats vszakats commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Each install: combination results in a separate (and fairly large)
cache entry. There are ~12 of them before this commit, in the 100-200 MB
size range each. Reduce the number of cache entries by installing
commonly used packages for all jobs. But, each installed package comes
with a size overhead in the cache entry and a significant time to
install them, even if unused in an actual job (because the cache holds
the raw package tarballs, which still need to be installed in each job
run). Thus, keep the list of commonly used packages minimal, and install
the rest of the packages in an separate pacman step, without using the
cache. These packages include the build tools (autotools, cmake), and
extra, not commonly used packages that a job may need in addition.

This reduces the number of cache blobs to 4, one per MSYS2 environment,
while a slight, tolerable rise in install times.

Since some packages are now installed, but not intended to be used, we
need to make sure auto-detections don't pick them up. (existing configs
already complied with this.)

Also:

  • update logic that relied on the per-package install: list to decide
    which SSH backend is used. Use the config: line instead.
  • tried installing builds tools in the default install list. This turned
    out to cause much overhead in wasted size and install time.

All in all, this balancing act is painful and difficult to maintain, I
wish the MSYS2 Action would cache the installed directory, thus
avoiding the lengthy install step for installed/cached packages. This
would allow to install everything from cache with good performance,
still save bandwidth and server load for MSYS2, while simplifying
things. Pending upstream issue about such feature:
msys2/setup-msys2#575

Slight downside is that mutually exclusive packages cannot be installed,
namely libssh2 vs. libssh2-wincng. Not currently used. In the future
(once the WinCNG stabilizing fix reaches a release) the variants can be
spread across envs to cover both without adding new cache blobs:

-mingw-w64-${{ matrix.env }}-libssh2
+${{ matrix.env == 'ucrt-x86_64' && format('mingw-w64-{0}-libssh2-wincng', matrix.env) || format('mingw-w64-{0}-libssh2', matrix.env) }}

Follow-up to 66313cc #16629

@github-actions github-actions Bot added Windows Windows-specific CI Continuous Integration labels Sep 29, 2026
@vszakats vszakats changed the title GHA/windows: try optimizing caches GHA/windows: try optimizing MSYS2 caches Sep 29, 2026
@vszakats
vszakats marked this pull request as draft September 29, 2026 06:54
@vszakats
vszakats marked this pull request as ready for review September 29, 2026 07:01
@vszakats

Copy link
Copy Markdown
Member Author

@vszakats
vszakats marked this pull request as draft September 29, 2026 08:22
@vszakats

vszakats commented Sep 29, 2026 •

Copy link
Copy Markdown
Member Author

After looking at thousands of job logs I have to realise that I don't
understand how MSYS2 caches work. It's restoring a bunch
of stuff, with cache blobs depending on what's installed (?),
then goes on to install extra packages anyway.

Need to give a second attempt at this. After dropping the
wolfSSL workaround in #23154. (and one 32-bit job via #23161)

@vszakats
vszakats force-pushed the gha-w-try-cacheopt branch 3 times, most recently from 4833a4d to 55ca357 Compare September 29, 2026 13:34
@vszakats

vszakats commented Sep 29, 2026 •

Copy link
Copy Markdown
Member Author

What may be happening is that the cache holds the package
tarballs, which then need to be installed in an extra step, but
without the need to download them from the distro server.

Meaning it's saving bandwidth and server load, but not saving
time: installing packages still takes a significant amount
of time, and all is saved is pulling a single tarball instead of
several, and pulling from GH's own server, not MSYS2's.

I wonder if it'd be possible to cache the msys64 directory (without
its package cache) instead and restore it as-is. I'd expect this to take
a similar amount of cache space, while also saving the time
necessary to individually install packages. Extracting many files
from a single tarball can still take some time, but may still be
much faster than now.

It also means that each individual installed package have
a significant time cost, even when cached.

edit: related Issue: msys2/setup-msys2#575

@vszakats
vszakats force-pushed the gha-w-try-cacheopt branch 2 times, most recently from 786986e to ea73f56 Compare September 30, 2026 11:23
@vszakats

vszakats commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

FTR I find it surprising that installing autotools in MSYS2 is pulling in a long
list of historical tool versions:

installing autoconf2.73...
installing autoconf2.72...
installing autoconf2.71...
installing autoconf2.69...
installing autoconf2.13...
installing automake1.11...
installing automake1.12...
installing automake1.13...
installing automake1.14...
installing automake1.15...
installing automake1.16...
installing automake1.17...
installing automake1.18...

This inflates the total downladed/installed size significantly. There must
be something MSYS2-specific explaining the need for this, because on
other platforms, packages are seemingly happy with the latest version
of these tools. (packages with special requirements may reference
a specific version explicitly.)

On a minor note, MSYS2 CMake doesn't pull in ninja, while the mingw
builds do. It may be useful to consider syncing MSYS2 with this; Ninja
is much more efficient than make for MSYS2 also.

@vszakats
vszakats marked this pull request as ready for review September 30, 2026 12:24
@vszakats vszakats changed the title GHA/windows: try optimizing MSYS2 caches GHA/windows: reduce MSYS2 cache entries Sep 30, 2026
@vszakats
vszakats requested a lite review from Copilot September 30, 2026 12:39

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.

Copilot review overview

🟡 Changes recommended

The autotools path omits the required unprefixed make package.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Refactors Windows MSYS2 package installation to reduce cache entries while preserving job-specific dependencies.

Changes:

  • Consolidates common packages per MSYS2 environment.
  • Installs build tools and job-specific dependencies separately.
  • Uses configuration flags to identify the SSH backend.
File Description
.github/​workflows/​windows.yml Updates MSYS2 caching, prerequisite installation, and SSH test configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/windows.yml Resolved
@vszakats vszakats changed the title GHA/windows: reduce MSYS2 cache entries GHA/windows: reduce number MSYS2 package cache entries Sep 30, 2026
@vszakats vszakats closed this in 5e654e2 Sep 30, 2026
@vszakats
vszakats deleted the gha-w-try-cacheopt branch September 30, 2026 12:51
@vszakats

Copy link
Copy Markdown
Member Author

After this patch these are the 4 cache entries (also reduced in size):

22 MB cached 14 hours ago
150 MB cached 1 hour ago
92 MB cached 1 hour ago
86 MB cached 14 hours ago

vszakats added a commit that referenced this pull request Nov 12, 2026
Caching packages is expensive with msys2/setup-msys2, because cached
packages all need to be installed after restore. Before this patch, to
make installs as fast as possible, only a common set of packages were
cached, and the rest installed from the MSYS2 repo servers (e.g.
autotools or cmake). But, repo servers are struggling, so to avoid using
them and possibly failing due to them, replace this with caching
everything. This makes installs 5-15 seconds slower per job, for 10
jobs.

In jobs running tests, msys openssh is still installed directly. If this
causes an issue, it can be included in the cached set in a future PR.

To avoid:
```
error: failed retrieving file 'mingw-w64-clang-aarch64-libarchive-3.8.9-6-any.pkg.tar.zst.sig'
from ftp2.osuosl.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
```
Ref: https://github.com/curl/curl/actions/runs/43029014875/job/130550970045#step:5:47

Also:
- optimize slow clang-aarch64 install by omitting unused autotools.
  To keep install times the same as before this patch.
- stop installing openssh for torture job, it's unused.
  Follow-up to 2643f5e #23864
- make msys openssh selection explicit (for tests).
- cached entry size changes: 86/92/140/150 -> 100/120/140/160 in MB.
  Number of cache entries is unchanged.

Bug: #23864 (comment)
Ref: msys2/msys2-main-server#79
Follow-up to 2643f5e #23864
Follow-up to 5e654e2 #23155

Closes #23906
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration performance Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

2 participants