Skip to content

GHA: drop vcpkg cache and most vcpkg logic with it - #17200

Closed
vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:gha-vcpkg-unlikely
Closed

vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:gha-vcpkg-unlikely

Conversation

@vszakats

@vszakats vszakats commented Apr 26, 2025 •

Copy link
Copy Markdown
Member

The unplanned dropping of the granular vcpkg binary cache indeed fell
into the cracks between Microsoft's various departments. The old method
is now official dropped, without replacement either on the vcpkg side or
the GitHub cache provider side.

Without a granular cache, vcpkg is impractical for builds larger than
a small dependency tree in CI, for performance reasons.

A granular cache is critical for CI use. Building dependencies is not
a goal of this CI, so a more desirable option would be pre-built binary
downloads. This would also allow keeping job timeouts low, which is
important for quick iteration in GHA when a flaky job requiring a manual
retry needs all other jobs to finish first. (GHA often disregards
step timeouts, which is another contributing factor here.)

Windows remains tested extensively with MSYS2, curl-for-win, and via
AppVeyor CI with MSVC + OpenSSL, and also in GHA via scaled back vcpkg
jobs that perform well without caching. What's lost is the recently
added Android OpenSSL build tests.

We may consider building/cachine important dependencies manually as in
GHA/linux-http3, and/or try integrating MSVC jobs with MSYS2 UCRT DLLs.

Ref: microsoft/vcpkg-tool#1662
Ref: microsoft/vcpkg#45073

Follow-up to cd0ec47 #17089
Follow-up to e3912f0 #17086
Follow-up to 15fb1dc #17069

@vszakats vszakats added CI Continuous Integration tidy-up labels Apr 26, 2025
@talregev

Copy link
Copy Markdown
Contributor

I am trying to understand about the nuget cache for vcpkg. Will you give that a chance?

@vszakats

Copy link
Copy Markdown
Member Author

I am trying to understand about the nuget cache for vcpkg. Will you give that a chance?

I personally cannot volunteer more free time for this, sorry. By skimming the thread,
it looks like a complex adventure, open-ended, maybe or maybe not temporary, with
another, proprietary, "ecosystem" (NuGet) to deal with, and manually handling secrets
(stored in clear text files!).

This looks like something that should work out of the box, without much or any effort,
like it does in well-known open-source solutions for MinGW, macOS, Linuxes, BSDs,
other OSes, even MS-DOS.

At this point it almost feels simpler to build and cache these dependencies individually
and manually, like we do for linux-http3. It's probably for somebody having MSVC
installed locally and also motivated to do this.

@vszakats vszakats changed the title GHA: purge vcpkg cache and most vcpkg logic with it GHA: drop vcpkg cache and most vcpkg logic with it Apr 27, 2025
@magnesj

magnesj commented Apr 27, 2025

Copy link
Copy Markdown

Here is our PR for moving to NuGet as caching backend.
OPM/ResInsight#12407

The token used to access the packages is stored as a secret in the repository, seems like a pragmatic solution to with no security issues.

Management of token is described here
https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-packages?pivots=linux-runner

@vszakats vszakats closed this in fd4c342 Apr 29, 2025
@vszakats
vszakats deleted the gha-vcpkg-unlikely branch April 29, 2025 17:37
@vicroms

vicroms commented Apr 29, 2025

Copy link
Copy Markdown

@vszakats

I'm one of the maintainers of vcpkg. We are suggesting teams to switch to a NuGet-backend binary caching provider, your NuGet feed can still be hosted at GitHub if you use GitHub Packages.

We can gladly assist with the transition if you reach to us at [email protected].

@andrewward22

andrewward22 commented Apr 30, 2025 •

Copy link
Copy Markdown

@vicroms
For manifest mode I simply use actions/cache to save and restore ~/.cache/vcpkg/archives which appears to work well (see microsoft/vcpkg#45073 (comment)). Is there some advantage to using GitHub Packages?

@talregev

Copy link
Copy Markdown
Contributor

from:
https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-default?pivots=shell-powershell

VCPKG_DEFAULT_BINARY_CACHE
%LOCALAPPDATA%\vcpkg\archives
%APPDATA%\vcpkg\archives

from the comment microsoft/vcpkg#45073 (comment)

- name: Restore vcpkg cache
  uses: actions/cache/restore@v4
  with:
    path: ~/.cache/vcpkg/archives
    key: some-build-specific-key
    
<Run CMake here>

- name: Save vcpkg cache
  uses: actions/cache/save@v4
  with:
    path: ~/.cache/vcpkg/archives
    key: some-build-specific-key

@vszakats
I can also specify a new location via: VCPKG_DEFAULT_BINARY_CACHE
I can make a PR with vcpkg cache without nuget for the moment.

Let me know what do you think.

@vszakats

vszakats commented Apr 30, 2025 •

Copy link
Copy Markdown
Member Author

Thanks for everyone's interest in this.

I've seen the recommendations, but none seem easy or a good fit for this
CI. I agreed on using vcpkg on the condition that it has a proper cache.
With that gone, I don't feel it's my duty now to seek and experiment
with worse solutions to keep using vcpkg for a handful of larger
packages. We want to build against those, but it's a non-goal to build
them in CI from source, or to use a particular package manager. I also
personally do this on my free time, for fun, and dealing with these
isn't.

Taking up the NuGet "ecosystem" on top of vcpkg seems like a large
project and also entirely unrelated to curl, CI, or open-source. It
needs an individual user, with new personal secrets, and manage them
from now on. This also seems to entail saving that secret in clear text
in a local file (via -StorePasswordInClearText). This may be secure,
but certainly doesn't sound like it. We also get to publish a "NuGet
feed" with non-curl packages in it, which seems confusing. Expiration
is unclear, and at first sight it's also not something designed for use
as cache.

The NuGet method has mono as its dependency, to call two commands to set
parameters in a file. This dependency is 250MB+ of size, an extra
install, which rules it out on Android (using the Linux runner).

The manifest cache or actions/cache method has unclear invalidation
props. Even with that working, it would invalidate the whole thing,
requiring to reserve enough time (and wait for it everytime it happens)
to rebuild everything from scratch. We discarded this idea in the first
PR bringing vcpkg to curl. It's also non-trivial to figure out what
to cache and where these directories are (also after looking at
the takes on this in different projects.)

On a wider picture, MSVC vcpkg jobs had caused a lot of grief since
installed. They need to keep the job timeout high, which works against
fast iterations when a step gets stuck, GitHub ignores its step timeout
and don't let us restart failed jobs till the high job timeout expires.
These jobs also had a high tendency for flakiness, with MSBuild actively
contributing to it by making any job fail that puts "error" in its output
(surrounded by colons in the same line) (that's one of the reasons, but
one that's also unfixable). vcpkg also seems to build slower compared
to other solutions (e.g. curl-for-win builds the complete dep stack from
source under 7 minutes for 3 CPUs, whereas vcpkg requires more time than
that to build a single dependency for 1 CPU.)

Speaking of individual dependencies, vcpkg builds the libpsl package in
a way to include large dependencies. The MultiSSL build is not where
development is heading, and rather a stress test. The libssh package is
insecure on Windows. libssh2 with the WinCNG backend is flaky on Windows.
GnuTLS is broken in vcpkg/MSVC. BoringSSL doesn't support Windows ARM64.
That leaves some TLS backends and compression libs, but those we test
extensively elsewhere. We can also build them from source manually in
separate steps and cache like done for linux-http3.

My point is, these jobs had caused issues we didn't see in other CI
jobs. It causes daily pain and require high maintenance. The added
benefit for curl seems slim. With the cache gone, this needs yet another
work investment, and not a small, or a (subjectively) interesting one.

My question is if Microsoft is considering pushing pre-built binaries
(for MSVC at least) to an official vcpkg NuGet feed? This would seem
to be of everyone's benefit, saving headaches all around and making
vcpkg a viable option for CI.

@bagder

bagder commented Apr 30, 2025

Copy link
Copy Markdown
Member

No one struggles as much and as hard with curl builds for Windows as @vszakats do.

The primary idea behind curl's CI builds is to verify curl on different platforms with different dependencies and build combinations. It is not in our interest to be fancy or to favor any particular package management systems. In general it is just easier and more effective to avoid package managers in our CI - to just build a few dependencies from source and cache them individually. It gives us better control and a more stream-lined process.

I'm all in favor of going the easiest route with the least friction.

@talregev

talregev commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

I can create a cache using gihub action cache mechanism with cache/restore and cache/save that it will save the binary cache that vcpkg is created as a zip files, and restore them.
This is a default tool of github action so no risk to maintain them or that they will break in the future.

I created that mechanism in different repo. you can take a look.
If it is relevant, I can create a PR here.

talregev/omplapp#4

@vszakats

vszakats commented Jun 5, 2025

Copy link
Copy Markdown
Member Author

We started with this solution, and it wasn't good. It means rebuidling the whole cache whenever any dependency changes. These dependencies are deep, large and build slowly. Therefore it also means that we must extend the timeout for the job to an hour, which is a huge issue combined with Windows jobs routinely hanging, and forcing to wait for them to retry them manually.

I think the Windows CI jobs have been more bearable since these large vcpkg builds are no longer done in them.

I also believe Microsoft is in the perfect position to solve this problem like it was before breaking it unintentionally,
or even solve it with a proper global cache, so that mere package users are not forced to build everything from
source all the time.

In the meantime we are not in a hurry and the CI does its job fine as it is.

@talregev

talregev commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

It means rebuidling the whole cache whenever any dependency changes

My solution it similar to your past solution, but have a key difference. It will not rebuilding the whole cache whenever any dependency changes.
It only build the new ports when there is a change.
There is a limitation. It always adding the new packages to the old ones without delete the old packages, even if vcpkg will not use it.
So when there cache size will hit the size limit of github action it will reset, then it will be rebuild. but this will take for long time. for few months before it reset.
Reson: new packages appear only when vcpkg get a new version in github action (not always, but let assume it does).
New version of vcpkg appear in every 2 weeks. the new packages will add the cache about 10mb more or less. and total size that it need to break is 10GB.

I am not sure that microsoft/vcpkg team want to solve this problem as it was before, that why I am suggesting this solution.

@vszakats

vszakats commented Jun 5, 2025 •

Copy link
Copy Markdown
Member Author

It doesn't solve the issue with hour+ long timeouts we would have to use for the initial
and eventual full (re)builds. Paying attention to cache size also isn't ideal. The ever
growing cache entries need to be downloaded and extracted on each run, gradually
worsening performance, which also isn't ideal, IIUC.

What I'd like is not building dependencies from source in CI.

Is there any reason why such (to me) essential feature is out of the scope for both
Microsoft and vcpkg? It's been a decade, and the same binary blobs are built and
rebuilt over and over again by every user. It seems very wasteful for energy and
everyone's time. One would think there is already infrastructure for that, and this
could save CI machines a lot of cycles.

I haven't had the time yet to try in production (the local test env is already in place
though): it seems to be option to use MSYS2 binary packages with MSVC curl builds.
With UCRT this should work in theory, and it worked in an isolated example locally.
Trying this on real builds would be nice and could solve these issues.

It'd also make things easier if vcpkg could somehow be made (much) faster, and/or
more frugal with dependencies, like having a minimal libpsl build without the deep
dependencies it's been using a few months back. This may allow to carefully enable
more options, if they build reasonably fast from source. Though for large packages
like most TLS backends, this is unlikely to ever become practical.

@vicroms

vicroms commented Jun 9, 2025 •

Copy link
Copy Markdown

What I'd like is not building dependencies from source in CI.

@vszakats perhaps you would be best served by the vcpkg export command.

The export command creates a "standalone SDK" that contains the binaries for your installed dependencies and vcpkg integration files.

Using this command, you can set up a workflow where you run vcpkg install and vcpkg export to produce the output once, then copy the produced output into your CI builders and consume the binaries (no dependencies' builds in CI runs). The step that produces the binary output only needs to be run when you want to update any of your dependencies.

It'd also make things easier if vcpkg could somehow be made (much) faster, and/or
more frugal with dependencies

We provide methods to override how individual dependencies are built in the form of private registries and overlay ports; if you feel that the way we build a specific library in our registry is incorrect then you can also submit a PR to change the behavior. We are not experts on each individual library that is packaged so we rely on contributors that know better than us, we would love a submission that improves the situation for all users.

Please let us know, if you would like us to explain the vcpkg export workflow in more detail.

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

Labels

CI Continuous Integration tidy-up

Development

Successfully merging this pull request may close these issues.

6 participants