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

feat: Use shallow clone to speed up performance #830

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

jnovick
Copy link
Contributor

@jnovick jnovick commented Aug 13, 2024

  • Only git fetch the one target revision that we need
  • This does not utilize the history so there is no reason to clone it
  • For large repos, this will speed up performance significantly

@jnovick jnovick force-pushed the shallow-clone branch 2 times, most recently from cba9345 to fe16b69 Compare August 13, 2024 17:38
@@ -384,6 +385,40 @@ func (m *nativeGitClient) Fetch(revision string) error {
return err
}

func (m *nativeGitClient) shallowFetch(revision string, depth int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move both functions to a separate file and only leave the change to the interface in this one? Reason is, that we copy over the Git code from Argo CD on every release. If this code stays in an file that exists in Argo CD too, it makes it pretty complicated to maintain. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, moved it. I chose not to update the existing fetch function since I saw it was copied in, but I wasn't sure where to put new logic, but I found it now.

You have made me wonder if I can contribute to ArgoCD, but updating it to use shallow clones as well. I will be investigating that later.

Thanks, I appreciate the help :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we discussed shallow cloning with Argo CD in the past a couple of times and came to no final conclusion yet. It's a pretty invasive change due to repository caching, history requirements for rollbacks and information etc.

For Image Updater however, I think there is no issue with shallow cloning and I believe it's beneficial.

* Only git fetch the one target revision that we need
* This does not utilize the history so there is no reason to clone it
* For large repos, this will speed up performance significantly

Signed-off-by: Joshua Novick <[email protected]>
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.53%. Comparing base (65698c5) to head (12767fa).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #830   +/-   ##
=======================================
  Coverage   73.53%   73.53%           
=======================================
  Files          31       31           
  Lines        3140     3140           
=======================================
  Hits         2309     2309           
  Misses        695      695           
  Partials      136      136           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jannfis jannfis changed the title Use shallow clone to speed up performance feat: Use shallow clone to speed up performance Aug 14, 2024
Copy link
Contributor

@jannfis jannfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @jnovick! Appreciate your contributions.

@jannfis jannfis merged commit 859900e into argoproj-labs:master Aug 14, 2024
10 checks passed
Tchoupinax pushed a commit to Tchoupinax/argocd-image-updater that referenced this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants