Copy files instead of rsync when they are in a local cache #4270
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.
This PR is just to upstream a change I've been using in https://github.com/kit-ty-kate/opam-health-check.
This change improves slightly the time it takes to retrieve archives from a local cache by avoiding a rather unnecessary call to
rsync
from the cache to a temporary file (which is then going to be moved to the global download cache in~/.opam/download-cache
), and replacing it by theOpamSystem.copy_file
function improved in this wonderful PR: #4064This PR approximatively improves the time it takes to retrieve archive by 0.02s per archive in cache on my test server. In my use-case (CI), opam is repetitively called and thus repetitively retrieve archive from the cache.
On a typical medium sized-example:
core.v0.14.0
for instance pulls 59 archives, so in total this PR make us gain 1.13s in this build. Multiply by 10_000 packages and this is now significant.This was tested and timed with master + #4071 for simplicity and to avoid noise in the timing. (cc @Armael in case you want a simple-to-use commit to rebase #4071 you can use this one: kit-ty-kate@ac20d2f)
Just to avoid confusion, I know I could directly move (or link) the entire cache to
~/.opam/download-cache
for an extra second of gain per 50 archives, but this is less composable and this PR is still an improvement nonetheless.