Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement shallow repo cloning in merge checkout strategy #2387

Closed
wants to merge 1 commit into from

Conversation

ilyaluk
Copy link
Contributor

@ilyaluk ilyaluk commented Jul 13, 2022

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.

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.
@ilyaluk ilyaluk requested a review from a team as a code owner July 13, 2022 16:01
@jamengual jamengual added waiting-on-review Waiting for a review from a maintainer provider/github labels Jul 14, 2022
@ilyaluk
Copy link
Contributor Author

ilyaluk commented Jul 18, 2022

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.

@jamengual
Copy link
Contributor

@jilyaluk should we close this base on your comments?

@jamengual
Copy link
Contributor

closed as not planned

@jamengual jamengual closed this Oct 11, 2022
@nitrocode
Copy link
Member

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

@jamengual
Copy link
Contributor

jamengual commented Nov 23, 2022 via email

@nitrocode
Copy link
Member

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

@nitrocode
Copy link
Member

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

@nitrocode nitrocode reopened this Nov 23, 2022
@nitrocode nitrocode changed the base branch from master to main November 23, 2022 18:19
@nitrocode
Copy link
Member

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

@nitrocode nitrocode added waiting-on-response Waiting for a response from the user and removed waiting-on-review Waiting for a review from a maintainer labels Dec 5, 2022
@nitrocode nitrocode closed this Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/github waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants