Re: libgit2 - a true git library

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Pierre Habouzit
Date: Friday, October 31, 2008 - 6:02 pm

On Sat, Nov 01, 2008 at 12:19:26AM +0000, Shawn O. Pearce wrote:
 in
 are
lags"

Sure, but for that you just need to reinject the numbers into some kind
of free list (hint a bitmap) to reuse old slots. Of course this is some
kind of take-once never-release approach _BUT_ one can do better and
"defrag" this at times.

E.g. for a server if we take your idea, there are some times we probably
*know* nobody has kept a reference to one of the pointers and we can
reorganize some pointers around to free chunks of data not allocated.

An escape way is to use mmap + madvise for those pools, the former to
allocate the memory and the latter to drop large unused ranges when
needed (remapping with MAP_FIXED is also supposed to work but fails on
Macos it seems).  Even win32 has what it takes to do so (just skim
through the code of jemalloc, that is used for mozilla, it's quite
portable on POSIX + Windows).

I was thinking that one should create and register pools of annotations
as such, define the size of the annotation (IOW the size of cell), and
let deal with that. I imagine the stuff as some kind of allocator that
would allocate the first time e.g. 4k of objects, and if you need more
8k, and if need more 16k and so on exponentially. Mapping an integer to
a cell in this kind of ropes is _really_ efficient: you need to know the
first bit set (__builtin_clz is of help with gcc, it can be emulated
with proper asm for many non-gcc platforms also) to give you the number
of the rope component that you intend to address, you clear that bit,
the resulting number is the index in that rope component of the cell
you're interested in. On most machines such an operation would be a few
cycles, which should be fairly little wrt the operation you would do
during a traversal.

Maintaining the bitmap is important, so that we can give back large
chunks of physical memory back to the system, and many malloc
implementations would likely use such kind of implementations, we would
just do our (which is arguably heavy) but gives us control on the cell
number, which is just what we need.

Of _course_ when we have a better / more natural place to put
annotations we need, let's do it ! But the kind of thing I just imagined
is more generic and can help to do arbitrary complex stuff during a
traversal.

We may want to explore a storage that is aware of the objects type also,
as I expect the liveness of objects to depend on the objects type a lot,
and some traversal to not care about some kind of objects at all, which
when combined with lazy allocation in the annotations pools, could end
up with reduced memory footprint. We could e.g. use two bits of the
"object handler" to store the type and dispatch into 3 (commit, tree,
blob) ropes instead of a big one.


The object and annotations store _is_ what makes git efficient, and is
the very service the library will have to support well. We _will_ have
to put some clever code in there and we cannot sacrifice any kind of
performance, this will be the tight loop every time.  I don't think
there will be anything else in git that is so central for performance.

On the other hand, it's probably ok for the first versions of the
library to have some things in it that don't perform well in long lived
processes (repacking e.g., if we ever want to do that in the library, as
it's slow and that forking a git-repack away should not be a too
expensive cost anyway).
--=20
=C2=B7O=C2=B7  Pierre Habouzit
=C2=B7=C2=B7O                                                madcoder@debia=
n.org
OOO                                                http://www.madism.org
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 10:07 am)
Re: libgit2 - a true git library, Pieter de Bie, (Fri Oct 31, 10:28 am)
Re: libgit2 - a true git library, Pieter de Bie, (Fri Oct 31, 10:29 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 10:47 am)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 11:41 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 11:54 am)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 12:57 pm)
Re: libgit2 - a true git library, Junio C Hamano, (Fri Oct 31, 1:05 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 1:12 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 1:24 pm)
Re: libgit2 - a true git library, Brian Gernhardt, (Fri Oct 31, 1:24 pm)
Re: libgit2 - a true git library, david, (Fri Oct 31, 1:29 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 1:56 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 2:31 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 2:43 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 2:50 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 2:51 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 2:58 pm)
Re: libgit2 - a true git library, Andreas Ericsson, (Fri Oct 31, 2:59 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 3:01 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 3:10 pm)
Re: libgit2 - a true git library, Junio C Hamano, (Fri Oct 31, 3:51 pm)
Re: libgit2 - a true git library, Junio C Hamano, (Fri Oct 31, 4:14 pm)
Re: libgit2 - a true git library, Bruno Santos, (Fri Oct 31, 4:18 pm)
Re: libgit2 - a true git library, Johannes Schindelin, (Fri Oct 31, 4:22 pm)
Re: libgit2 - a true git library, Pieter de Bie, (Fri Oct 31, 4:24 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 4:25 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 4:28 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 4:33 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 4:41 pm)
Re: libgit2 - a true git library, Junio C Hamano, (Fri Oct 31, 4:49 pm)
Re: libgit2 - a true git library, Jakub Narebski, (Fri Oct 31, 4:56 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 5:02 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 5:13 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 5:19 pm)
Re: libgit2 - a true git library, david, (Fri Oct 31, 5:41 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 6:00 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 6:02 pm)
Re: libgit2 - a true git library, david, (Fri Oct 31, 6:04 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 6:06 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 6:08 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 6:15 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 6:19 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 6:33 pm)
Re: libgit2 - a true git library, david, (Fri Oct 31, 6:36 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Fri Oct 31, 6:38 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 6:43 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 6:45 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 6:49 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Fri Oct 31, 6:52 pm)
Re: libgit2 - a true git library, Nicolas Pitre, (Fri Oct 31, 6:53 pm)
Re: libgit2 - a true git library, Johannes Schindelin, (Fri Oct 31, 7:26 pm)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 1, 3:52 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sat Nov 1, 4:01 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 1, 4:17 am)
Re: libgit2 - a true git library, Nicolas Pitre, (Sat Nov 1, 6:50 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sat Nov 1, 10:01 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sat Nov 1, 10:30 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 1, 11:44 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sat Nov 1, 11:48 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 1, 12:18 pm)
Re: libgit2 - a true git library, Johannes Schindelin, (Sat Nov 1, 1:26 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 1:29 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 1:42 pm)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 1, 2:58 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 3:57 pm)
Re: libgit2 - a true git library, Scott Chacon, (Sat Nov 1, 5:26 pm)
Re: libgit2 - a true git library, Scott Chacon, (Sat Nov 1, 6:07 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 6:36 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 6:50 pm)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sat Nov 1, 6:56 pm)
Re: libgit2 - a true git library, Johannes Schindelin, (Sat Nov 1, 7:30 pm)
Re: libgit2 - a true git library, David Brown, (Sat Nov 1, 10:09 pm)
Re: libgit2 - a true git library, Pierre Habouzit, (Sun Nov 2, 2:19 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sun Nov 2, 2:25 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Mon Nov 3, 3:17 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Mon Nov 3, 6:08 am)
Re: libgit2 - a true git library, Shawn O. Pearce, (Mon Nov 3, 9:20 am)
Re: libgit2 - a true git library, Steve Frécinaux, (Sat Nov 8, 6:26 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Sat Nov 8, 7:35 am)
Re: libgit2 - a true git library, Pierre Habouzit, (Sat Nov 8, 10:27 am)
Re: libgit2 - a true git library, Andreas Ericsson, (Sun Nov 9, 3:17 am)
Re: libgit2 - a true git library, Shawn O. Pearce, (Sun Nov 9, 2:02 pm)