Binary Cache: Add write-back support #1406
Open
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.
Write-back support for Binary Caching
This PR adds support for a cache write-back phase during package installation when the relevant cache entry was not newly built. This allows ports to be synced to all binary-cache providers marked as
write
orreadwrite
upon a successful installation.Currently the
vcpkg
binary-caching layer will only populate awrite
-capable if the port was built from scratch, i.e. not restored from aread
-capable cache provider. This means that a consumer has no way of guaranteeing other caches to be populated, unless they themselves build the port.Use-cases
As a developer I have a local cache, e.g. file-system & a remote cache, e.g. S3. The remote cache is meant to be a fallback in case the local cache isn't populated. Once restored from the remote cache, I'd like the local cache to be populated with the restored entry, so if the port needs to be restored at a later time, it can be done from the cheaper local cache i.s.o. the remote cache.
Implementation details
Provider identity
The binary caching layer generally works by adding a list of
read
&write
capable cache providers. Theread
providers are typically single-source, while thewrite
providers are multi-source, e.g. multiple local file-system directories belong to 1write
provider. In order to identify which providers need be written back to, we need to uniquely identify each provider that qualifies for a write-back. This is done using a uniqueProviderId
, assigned during the parsing of the binary-cache segment list.Write-back
The
push_success()
function is now also called post-install to populate thewrite
-capable providers that were (during prefetch) marked as missing the port. These individually mark the cache entry as written back usingmark_written_back()
.Relevant issues/discussions