crystal-lang / shards

Dependency manager for the Crystal language
Other
758 stars 99 forks source link

Using libgit2 for cloning, listing tags, etc #586

Closed skinnyjames closed 1 year ago

skinnyjames commented 1 year ago

Changes

This PR replaces most (but not all) git commands in the git resolve with libgit2 behaviors.

Benchmarks

Overall true git clones appear faster than libgit2, but libgit2 clones consume significantly less memory. If not employed already, concurrency may help.

A benchmark on a repo with many dependencies using hyperfine (gshards is the release binary using libgit2).

hyperfine 'rm -Rf lib && shards install --without-development' 'rm -Rf lib && gshards install --without-development'

Benchmark 1: rm -Rf lib && shards install --without-development
  Time (mean ± σ):      4.076 s ±  0.263 s    [User: 1.844 s, System: 1.789 s]
  Range (min … max):    3.847 s …  4.669 s    10 runs

Benchmark 2: rm -Rf lib && gshards install --without-development
  Time (mean ± σ):      5.929 s ±  0.827 s    [User: 0.721 s, System: 1.340 s]
  Range (min … max):    5.484 s …  8.264 s    10 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Summary
  'rm -Rf lib && shards install --without-development' ran
    1.45 ± 0.22 times faster than 'rm -Rf lib && gshards install --without-development'

Notes

skinnyjames commented 1 year ago

Oh shoot. I didn't mean to PR this against canonical, just my own fork. It's meant for discussion, and I think it could be a win to implement fully, but I'd love to hear thoughts.