atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Implement shallow repo cloning in merge checkout strategy

Open ilyaluk opened this issue 2 years ago • 2 comments

When the repository is quite large clones are becoming slower. Previously Atlantis fetched full repository in --checkout-strategy=merge mode. However, that's not required, we only should have enough commits in our clone to perform a merge between base and feature branches, not full history.

This implements rough guessing: fetch 50 (user-configurable) commits from each of base and feature branches, and if their merge base is not in these commits, fetch full repo history. This is not ideal solution and could be improved (e.g. increase the number of fetched commits in several attempts before full fetch), but I think it should be good enough in most cases.

I'm not sure about the flag name and enabling this behaviour by default. The flag could be renamed to something like --checkout-merge-depth, if that would be preferable. Also, I could change the default value to zero and treat it as "always fetch full repo", to comply with previous behaviour.

ilyaluk avatar Jul 13 '22 16:07 ilyaluk

Huh, come to think of it, implementing cache for git repo would probably be a better solution. Something among these lines:

  • Add flag --enable-repo-caching
  • If flag enabled, clone bare repo to some workdir (e.g. data_dir/repos/owner/repo_name/repo) on first usage
  • Clone to PR workdir from this bare repo
  • On each subsequential clone fetch all remote branches in bare repo and then clone/fetch to workspaces

Current PR would still probably be useful in cases when there are tons of files in repo and even cloning from dir to dir takes a long time, but that's more rare scenario.

ilyaluk avatar Jul 18 '22 22:07 ilyaluk

@jilyaluk should we close this base on your comments?

jamengual avatar Sep 21 '22 04:09 jamengual

closed as not planned

jamengual avatar Oct 11 '22 04:10 jamengual

Could we reopen this? I think this has a lot of value for repos with many commits

nitrocode avatar Nov 23 '22 05:11 nitrocode

go for it.

On Tue, Nov 22, 2022, 9:18 p.m. nitrocode @.***> wrote:

Could we reopen this? I think this has a lot of value for repos with many commits

— Reply to this email directly, view it on GitHub https://github.com/runatlantis/atlantis/pull/2387#issuecomment-1324565868, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ3ERBDMVEC7IYJB6LXR3DWJWSL5ANCNFSM53PH5H4Q . You are receiving this because you modified the open/close state.Message ID: @.***>

jamengual avatar Nov 23 '22 13:11 jamengual

@jamengual i cannot open this for some reason. The branch still exists. The button is unclickable.

nitrocode avatar Nov 23 '22 13:11 nitrocode

Ah it's because the master branch was renamed to main. I recreated master from main and now I can reopen this PR.

nitrocode avatar Nov 23 '22 18:11 nitrocode

@jilyaluk please resolve conflicts when time permits. We appreciate your patience

nitrocode avatar Dec 01 '22 09:12 nitrocode