Refactor: speed up all clone operations by loading all commits compressed into 1 #2348
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.
I added
--depth 1
to allgit clone
commands without--single-branch
or--depth
to download latest state of the repo without all of the commit history.--single-branch
is implied when using--depth
according to git manual.That's why
--depth 1
replaced--single-branch
instead of leaving both.My big problem with
yay
was is that it either clones entire repo (commands without both--depth 1
and--single-branch
) or clones entire main branch with changes that have no affection to current state of the repo being cloned (with--single-branch
). If one function/file/class was created once and then deleted, it may not be present in the current filesystem, but still will be present in commits and will be passed to user over the internet during clone operation.--depth 1
solves it.--depth 1
fixes the problem and loads only default branch of the repo and only the latest it's state. It basically squashes all commits into one.I don't know
go
although knowgrep
😅, so don't judge too harshly if I did something wrong.There are loads and loads of packages that take a long time to download. Example of such package in AUR is amf-headers-git. It references this AMF repo.
Cloning of AMF repo even over a consistent ssh channel takes SIGNIFICANTLY more time and disk space than doing so with
--depth 1
.Here is benchmark (cloning speed in git logs represents only the speed in last seconds)
Cloning repo without
--depth 1
takes8*60 + 58 = 538
secondsCloning repo with
--depth 1
takes1*60 + 49 = 109
secondsRepo cloned without
--depth 1
takes 1481388 bytesRepo cloned with
--depth 1
takes 758384 bytesWe get
100-(758384 / 1481388)*100=48.8%
decreasing in space on diskWe get
100-(109 / 538)*100=79.7%
decreasing in cloning time