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

fix: Refactor cloning and caching workflow #71

Merged
merged 1 commit into from
Dec 23, 2023
Merged

fix: Refactor cloning and caching workflow #71

merged 1 commit into from
Dec 23, 2023

Conversation

0xDEC0DE
Copy link
Contributor

  • Clone repositories into the cache with --bare to keep just the repo objects in cache, rather than an unused copy of the working tree. This can yield a significant space savings in repositories with large numbers of files
  • Clone repositories into the cache with --filter=blob:none. This will skip downloading any objects from the repository in the initial copy of the clone, and only populate the repository metadata; subsequent operations will automatically download the required objects (and ONLY the required objects) from origin as needed. This yields a massive space/performance boost.
  • Make use of the git worktree subcommand to populate dstDir targets rather than git checkout-index. This subcommand is designed for using a single repository as a source for multiple copies of the working tree, so it is a much better fit for what Gilt is trying to do.
  • Remove the now-obsolete CloneByTag, Reset, and CheckoutIndex workflows.

With this change, the tag: and sha: directives in Giltfile.yaml become 100% equivalent, with no difference in handling required.

Fixes: Issue #70

@0xDEC0DE
Copy link
Contributor Author

0xDEC0DE commented Dec 22, 2023

Using the following Giltfile.yaml:

---
giltDir: ~/.gilt/clone
debug: true
repositories:
  - git: https://github.com/bitnami/charts.git
    sha: 2ae853c9
    dstDir: /tmp/bitnami

Before

$ time go-gilt overlay
3:47PM INF acquiring lock lockfile=/Users/nisimond/.gilt/clone/gilt.lock
3:47PM INF cloning repository=https://github.com/bitnami/charts.git sha=2ae853c9 tag="" dstDir=/Users/nisimond/.gilt/clone/cache/https---github.com-bitnami-charts.git-2ae853c9
3:51PM INF extracting to=/tmp/bitnami

real	4m35.984s
user	7m3.872s
sys	1m17.738s

After

$ time go-gilt overlay
3:46PM INF acquiring lock lockfile=/Users/nisimond/.gilt/clone/gilt.lock
3:46PM INF cloning repository=https://github.com/bitnami/charts.git dstDir=/Users/nisimond/.gilt/clone/cache
3:46PM INF extracting from=/Users/nisimond/.gilt/clone/cache/charts.git version=2ae853c9 to=/tmp/bitnami

real	0m6.115s
user	0m1.992s
sys	0m2.242s

Disk usage

du -sh .gilt/clone/cache/*
 35M	.gilt/clone/cache/charts.git
3.1G	.gilt/clone/cache/https---github.com-bitnami-charts.git-2ae853c9

The produced dstDir is equivalent in both runs.

@retr0h
Copy link
Owner

retr0h commented Dec 22, 2023

Thanks Nic I'll check it out shortly!

@retr0h
Copy link
Owner

retr0h commented Dec 22, 2023

@nisimond can amend your PR comments following https://www.conventionalcommits.org/en/v1.0.0/ and force push.

Something such as fix: refactor cloning and caching workflow

- Clone repositories into the cache with `--bare` to keep just the
  repo objects in cache, rather than an unused copy of the working
  tree.  This can yield a significant space savings in repositories
  with large numbers of files

- Clone repositories into the cache with `--filter=blob:none`.  This
  will skip downloading any objects from the repository in the
  initial copy of the clone, and only populate the repository
  metadata; subsequent operations will automatically download the
  required objects (and ONLY the required objects) from origin as
  needed.  This yields a massive space/performance boost.

- Make use of the `git worktree` subcommand to populate `dstDir`
  targets rather than `git checkout-index`.  This subcommand is
  designed for using a single repository as a source for multiple
  copies of the working tree, so it is a much better fit for what
  Gilt is trying to do.

- Remove the now-obsolete `CloneByTag`, `Reset`, and `CheckoutIndex`
  workflows.

With this change, the `tag:` and `sha:` directives in `Giltfile.yaml`
become 100% equivalent, with no difference in handling required.

Fixes: Issue #70
@0xDEC0DE
Copy link
Contributor Author

@nisimond can amend your PR comments following https://www.conventionalcommits.org/en/v1.0.0/ and force push.

Something such as fix: refactor cloning and caching workflow

tumblr_2ef2c4d610c3e69c30ff2263b91c142d_5a8d479c_540

@0xDEC0DE 0xDEC0DE changed the title Refactor cloning and caching workflow fix: Refactor cloning and caching workflow Dec 23, 2023
@retr0h retr0h merged commit d306437 into retr0h:main Dec 23, 2023
4 of 5 checks passed
@0xDEC0DE 0xDEC0DE deleted the issue/70 branch December 23, 2023 19:00
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.

None yet

3 participants