Skip to content
schacon edited this page Sep 12, 2010 · 2 revisions

I’ve started integrating the GitRuby raw access library, a way to interact with Git in pure ruby, into Grit in my fork. It’s not quite done – it won’t work with things like the ‘XXXYYY’ range strings in log, or the ‘skip’ dingus, but it does work for a number of things. I’ve implemented it as a module that is included in the Grit::Git class – since all the git calls are captured by the ‘method_missing’ function, I simply implement the ones I want to override and try in pure ruby – if I can’t do it, sometimes I fall back to the method_missing, which will do a ‘git’ system call.

So far I’ve overridden the cat_file, ls_tree, rev_parse and the rev_list and log functions (which are essentially the same thing, since we’re passing —pretty=“raw” to rev-list, which makes it identical to ‘git log’). There are significant speed increases in the short calls (like cat-file, ls_tree, etc) and only becomes worse than the system calls if we’re doing some massive commit walk (‘git rev-list —all’, for example).

Grit 0.7.0

              user     system      total        real
packobj       0.030000   0.260000   1.320000 (  1.344565)
commits 1     0.030000   0.070000   0.380000 (  0.366209)
commits 2     0.110000   0.160000   0.830000 (  0.802311)
big revlist   0.330000   0.130000   0.830000 (  0.795258)
log           0.380000   0.140000   0.880000 (  0.856951)
diff          0.330000   0.190000   2.080000 (  2.072242)
commit-diff   0.690000   0.250000   1.560000 (  1.521016)
heads         0.000000   0.070000   0.360000 (  0.376296)

Grit Edge (with GitRuby) :

              user     system      total        real
packobj       0.050000   0.000000   0.050000 (  0.051167)
commits 1     0.140000   0.010000   0.150000 (  0.164900)
commits 2     0.430000   0.030000   0.460000 (  0.454646)
big revlist   1.540000   0.100000   1.640000 (  1.637204)
log           0.480000   0.030000   0.510000 (  0.512445)
diff          0.200000   0.190000   1.970000 (  1.905014)
commit-diff   0.550000   0.240000   1.420000 (  1.366508)
heads         0.020000   0.090000   0.410000 (  0.402519)
Clone this wiki locally