Slide 1

Slide 1 text

Andy Delcambre sadelcambre

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

YAPC:Asia

Slide 4

Slide 4 text

I don’t write Perl

Slide 5

Slide 5 text

I rarely write Perl

Slide 6

Slide 6 text

Total source lines grouped by language: ! ruby: 316613 (98.99%) sh: 2268 (0.71%) ansic: 743 (0.23%) perl: 179 (0.06%) python: 31 (0.01%)

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

DIRECTED ACYCLIC GRAPH

Slide 10

Slide 10 text

$ git log commit b3f13c1 Author: Andy Delcambre Date: Thu Aug 28 08:29 2014 ! Commit 3 ! commit c79e797 Author: Andy Delcambre Date: Thu Aug 28 08:29 2014 ! Commit 2 ! commit 9a42679 Author: Andy Delcambre Date: Thu Aug 28 08:28 2014 ! Initial commit commit b3f13c1 Commit 3 commit c79e797 Commit 2 commit 9a42679 Initial commit HEAD

Slide 11

Slide 11 text

$ git cat-file -p b3f13c1 tree 9e68447 parent c79e797 author Andy Delcambre 1409182168 committer Andy Delcambre 1409182168 ! Commit 3 commit b3f13c1 Commit 3 tree 9e68447 commit c79e797 Commit 2 Parent

Slide 12

Slide 12 text

$ git cat-file -p 9e68447 100644 blob b465ded README.md commit b3f13c1 Commit 3 tree 9e68447 commit c79e797 Commit 2 Parent blob 9e68447 README.md

Slide 13

Slide 13 text

$ git cat-file -p b465ded # Test ! A test repo, for YAPC:Asia. commit b3f13c1 Commit 3 tree 9e68447 commit c79e797 Commit 2 Parent blob 9e68447 README.md # Test ! A test repo, for YAPC:Asia.

Slide 14

Slide 14 text

GitHub

Slide 15

Slide 15 text

Hosting a Git repo is Secret: EASY

Slide 16

Slide 16 text

enzo $ git init --bare demo.git Initialized empty Git repo in /home/adelcambre/git/demo.git/ ! yt $ git remote add origin adelcambre@enzo:git/demo.git yt $ git push origin master Counting objects: 6, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (6/6), 473 bytes, done. Total 6 (delta 0), reused 6 (delta 0) To adelcambre@enzo:git/demo.git * [new branch] master -> master ! yt $ git clone adelcambre@enzo:git/demo.git Cloning into 'demo'... remote: Counting objects: 6, done. remote: Compressing objects: 100% (2/2), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

yt $ git remote add -f origin [email protected]:adelcambre/demo.git Updating origin From github.com:adelcambre/demo * [new branch] master -> origin/master ! yt $ git push origin master Counting objects: 6, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (6/6), 473 bytes, done. Total 6 (delta 0), reused 6 (delta 0) To https://github.com/adelcambre/demo.git * [new branch] master -> master

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Hosting a *lot* of Git repos is Not so Secret: HARD

Slide 22

Slide 22 text

> 7 million repositories

Slide 23

Slide 23 text

1.5 million pushes

Slide 24

Slide 24 text

100 million pulls & clones

Slide 25

Slide 25 text

27 fileservers

Slide 26

Slide 26 text

100 TB of online storage

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Grit

Slide 29

Slide 29 text

1st Commit GitHub 1st Commit Grit

Slide 30

Slide 30 text

Ruby wrapper around Git

Slide 31

Slide 31 text

repo = Grit::Repo.new(“grit.git”) ! repo.commits # => [#, #, #, #, #]

Slide 32

Slide 32 text

This works for everything! ! (locally)

Slide 33

Slide 33 text

27 fileservers

Slide 34

Slide 34 text

Smoke “Grit in the cloud”

Slide 35

Slide 35 text

The Internet Chimney fs102 fs103 fs104 fs105 … fe102 fe103 fe104 fe105 …

Slide 36

Slide 36 text

module Smoke def self.install! ::Grit.send(:remove_const, :Git) ! ::Grit.const_set(:Git, Smoke::Git) end end

Slide 37

Slide 37 text

ls_tree("HEAD").each do |entry| if entry.blob? load_blob(entry.oid) end end

Slide 38

Slide 38 text

Death by Round Trip

Slide 39

Slide 39 text

A condensed (and probably wrong) history of git

Slide 40

Slide 40 text

Bitkeeper

Slide 41

Slide 41 text

Git

Slide 42

Slide 42 text

Shared library?

Slide 43

Slide 43 text

libgit2

Slide 44

Slide 44 text

JGit

Slide 45

Slide 45 text

libgit2 http://github.com/libgit2/libgit2

Slide 46

Slide 46 text

Rugged http://github.com/libgit2/rugged

Slide 47

Slide 47 text

Ruby wrapper around libgit2

Slide 48

Slide 48 text

repo = Rugged::Repository.new("rugged.git") ! repo.last_commit # => #

Slide 49

Slide 49 text

Perl

Slide 50

Slide 50 text

Git-Raw https://metacpan.org/release/Git-Raw

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

GitRPC The New Hotness aka

Slide 53

Slide 53 text

Like Smoke, But Better

Slide 54

Slide 54 text

Caching

Slide 55

Slide 55 text

Pluggable Wire Protocols

Slide 56

Slide 56 text

Encoding Aware

Slide 57

Slide 57 text

GIT(1) Git Manual GIT(1) ! NAME git - the stupid content tracker

Slide 58

Slide 58 text

GIT(1) Git Manual GIT(1) ! NAME git - the stupid content tracker

Slide 59

Slide 59 text

Git doesn’t care about encodings

Slide 60

Slide 60 text

Smoke doesn’t either

Slide 61

Slide 61 text

GitRPC is encoding aware

Slide 62

Slide 62 text

Detect and tag as soon as possible

Slide 63

Slide 63 text

The Switch

Slide 64

Slide 64 text

class Repository def git Smoke::Repo.new(path) end ! def rpc GitRPC.new(path) end end

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

Graphite

Slide 67

Slide 67 text

Graph Every Call Both GitRPC and Smoke

Slide 68

Slide 68 text

1 Year ago

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

Where are we today?

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Good Progress But not done yet

Slide 77

Slide 77 text

Finding the Final 0.1%

Slide 78

Slide 78 text

Backscatter

Slide 79

Slide 79 text

Call Counting

Slide 80

Slide 80 text

def git backscatter_measure Smoke::Repo.new(path) end

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

Method Tracing

Slide 83

Slide 83 text

def git backscatter_trace 20 Smoke::Repo.new(path) end

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

Recap

Slide 86

Slide 86 text

Run both concurrently

Slide 87

Slide 87 text

Measure Everything

Slide 88

Slide 88 text

Use tracing to find the last 0.1%

Slide 89

Slide 89 text

Andy Delcambre sadelcambre

Slide 90

Slide 90 text

Further Reading Git for Computer Scientists http://eagain.net/articles/git-for-computer-scientists/ My mom told me git doesn’t scale https://vimeo.com/64716825 How GitHub uses GitHub to build Github http://zachholman.com/talk/how-github-uses-github-to-build-github/