Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git LFS at Light Speed

Git LFS at Light Speed

Git and its extensions are becoming more popular than ever. However, certain use cases may still be suboptimal. We identified a way to dramatically improve performance in a popular Git extension - LFS (Large File Storage) - that required changes in both Git Core, and the extension itself. Based on our combined experiences we’ll walk you through the process of a successful contribution to each project with the help of mailing lists and Pull Requests. If you have already a bit of Git command line knowledge then this talk will prepare you for your first contribution to Git, an extension, or both.

Presented at GitMerge 2017 by Taylor Blau (GitHub) and Lars Schneider (Autodesk).

Lars Schneider

February 03, 2017
Tweet

More Decks by Lars Schneider

Other Decks in Programming

Transcript

  1. GIT LFS @ LIGHT SPEED - The story of a

    Git contribution - Lars Schneider Autodesk Taylor Blau GitHub
  2. @kit3bus Clone: Git without LFS master 301MB + 100 MB

    + 100 MB 1 MB 100 MB 1 MB 100 MB 1 MB 100 MB
  3. @kit3bus LFS Server Clone: Git with LFS 1MB master 1

    MB 100 MB 1 MB 1 MB 100 MB 0 MB 0 MB 0 MB 100 MB
  4. @kit3bus LFS Server Git with LFS master 1 MB 100

    MB 1 MB 1 MB 100 MB 0 MB 0 MB 0 MB 100 MB Clone: 1 MB
  5. @kit3bus LFS Server Git with LFS master 1 MB 100

    MB 1 MB 1 MB 100 MB 0 MB 0 MB 0 MB 100 MB Clone: 1 MB + Checkout: 100 MB
  6. @kit3bus LFS Server Git with LFS master 1 MB 100

    MB 1 MB 1 MB 100 MB 0 MB 0 MB 0 MB 100 MB Clone: 1 MB + Checkout: 100 MB 60% bandwidth saving!
  7. @kit3bus Git LFS Git LFS Git LFS One-Shot Filter: Many

    Git LFS invocations Git Checkout Git
  8. @kit3bus Subscribe to the Mailing List Send an email to

    "[email protected]" with an empty subject line and the words "subscribe git" in the message body.
  9. @kit3bus Make Commits $ git checkout -b myfeature master ...

    feature ... ... tests ... ... docs ... $ git commit maint for bugfixes Read Documentation/CodingGuidelines
  10. @kit3bus Make Commits area: short description Explain the problem. Explain

    the solution. Signed-off-by: Lars Schneider <[email protected]> Pro Tip:
 Use a spell checker!
  11. @kit3bus Check Commits make git rebase master -x "make" make

    test git diff --check master...HEAD ... https://github.com/larsxschneider/git-list-helper prepare-patch.sh master Lazy?
  12. @kit3bus Prepare Patch Emails git format-patch master From ea25a1834be7e2da36fd00f4abc403a56d6b35bc Mon

    Sep 17 00:00:00 2001 From: Lars Schneider <[email protected]> Date: Mon, 21 Nov 2016 13:44:08 +0100 Subject: [PATCH v1] short description Detailed commit message. Signed-off-by: Lars Schneider <[email protected]> --- Hi, message to mailing list! Cheers, Lars apply.c | 2 +- archive.c | 2 +- 2 files changed, 145 insertions(+), 24 deletions(-) diff --git a/apply.c b/apply.c index 2ed808d429..aa7e6e4359 100644 --- a/apply.c +++ b/apply.c @@ -4328,7 +4328,7 @@ static int try_create_file - if (convert_to_working_tree(path, buf, size, &nbuf)) { + if (convert_to_working_tree(path, buf, size, &nbuf, NULL)) { } -- 2.11.0 Commit Message Additional explanations/ cover letter Diff statistics Patch Your Git version Email header
  13. @kit3bus Prepare Patch Emails prepare-patch.sh master From ea25a1834be7e2da36fd00f4abc403a56d6b35bc Mon Sep

    17 00:00:00 2001 From: Lars Schneider <[email protected]> Date: Mon, 21 Nov 2016 13:44:08 +0100 Subject: [PATCH v1] short description Detailed commit message. Signed-off-by: Lars Schneider <[email protected]> --- Notes: Base Commit: 787f75f056 (master) Diff on Web: https://github.com/larsxschneider/git/commit/a8ec423355 Checkout: git fetch https://... demo && git checkout a8ec423355 apply.c | 2 +- archive.c | 2 +- 2 files changed, 145 insertions(+), 24 deletions(-) diff --git a/apply.c b/apply.c index 2ed808d429..aa7e6e4359 100644 --- a/apply.c +++ b/apply.c @@ -4328,7 +4328,7 @@ static int try_create_file - if (convert_to_working_tree(path, buf, size, &nbuf)) { + if (convert_to_working_tree(path, buf, size, &nbuf, NULL)) { } -- 2.11.0 Additional explanations/ cover letter
  14. @kit3bus git send-email /patches/* [email protected] git send-email /patches/* [email protected] [email protected]

    Send Patch Emails Pro Tip:
 Find reviewers
 with git blame prepare-patch.sh master Lazy?
  15. @kit3bus Respond to Reviews 1. Find agreement 2. Update commits

    3. Check commits 4. Prepare patch emails Pro Tip:
 Make notes https://github.com/larsxschneider/git-list-helper prepare-patch.sh master 2
  16. @kit3bus Respond to Reviews 1. Find agreement 2. Update commits

    3. Check commits 4. Prepare patch emails 5. Send patch emails and CC reviewers Pro Tip:
 Make notes
  17. @kit3bus v1 v2 ... v11 Contribution Cycle Take in
 reviews

    next master Release! Send patches RFC More: Documentation/SubmittingPatches
  18. 40 (master) $ GIT_TRACE_PACKET=1 git checkout my-feature packet: git> command=smudge

    packet: git> pathname=foo/bar.dat packet: git> 0000 packet: git> CONTENT packet: git> 0000 packet: git< status=success packet: git< 0000 packet: git< SMUDGED_CONTENT packet: git< 0000 packet: git< 0000 (my-feature) $ ...
  19. 50

  20. 52

  21. 54

  22. 59 for scanner.Scan() { req := scan.Request() switch req.Header[“command”] {

    case “clean”: case “smudge”: default: } } if err := scan.Err(); err != nil { // ... }
  23. 63

  24. 65 type Pktline struct { ... } func (p *Pktline)

    Pkt() ([]byte, error) { // ... }
  25. 72 type PktlineReader struct { ... } func (r *PktlineReader)

    Read(p []byte) (n int, err error) { for { pkt, err := r.pkt() if err != nil { return n, err } copy(p[n:], pkt) } return n, nil }
  26. 73 for scanner.Scan() { req := scanner.Request() sig := sha256.New()

    io.Copy(sig, req.Body) fmt.Fprintln(“OID: %x”, sig.Sum(nil)) }
  27. 78

  28. 87 type PktlineWriter struct { ... } func (w *PktlineWriter)

    Write(p []byte) (n int, err error) { var n int for n < len(p) { c := min(len(p[n:]), MaxPacketLength) if err := w.writePkt(p[n:c]); err != nil { return n, err } n += c } return n, nil }
  29. 92 func smudge(out io.Writer, oid string) (n int, err error)

    { path := lfs.LocalMediaPath(oid) f, err := os.Open(path) if err != nil { return 0, err } return io.Copy(out, f) }