]> git.proxmox.com Git - libgit2.git/commit
Add basic support to read pack-*.idx v1 and v2 files
authorShawn O. Pearce <spearce@spearce.org>
Sat, 3 Jan 2009 10:41:26 +0000 (02:41 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 3 Jan 2009 10:56:16 +0000 (02:56 -0800)
commita7c60cfc6d3af29669ef5cba9df325719b9f30cf
tree141d3dd299cb117c277cfe0907b0ddaccdaa75ac
parent20e7f426c3d56ba9e4b55f31a61835dd0031b464
Add basic support to read pack-*.idx v1 and v2 files

The index data is mapped into memory and then scanned using a
binary search algorithm to locate the matching entry for the
supplied git_oid.  The standard fanout hash trick is applied to
reduce the search space by 8 iterations.

Since the v1 and v2 file formats differ in their search function,
due to the different layouts used for the object records, we use
two different search implementations and a virtual function pointer
to jump to the correct version of code for the current pack index.
The single function jump per-pack should be faster then computing
a branch point inside the inner loop of a common binary search.

To improve concurrency during read operations the pack lock is only
held while verifying the index is actually open, or while opening
the index for the first time.  This permits multiple concurrent
readers to scan through the same index.

If an invalid index file is opened we close it and mark the
git_pack's invalid bit to true.  The git_pack structure is kept
around in its parent git_packlist, but the invalid bit will cause
all future readers to skip over the pack entirely.  Pruning the
invalid entries is relatively unimportant because they shouldn't
be very common, a $GIT_DIRECTORY/objects/pack directory tends to
only have valid pack files.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
src/odb.c
src/odb.h [new file with mode: 0644]
src/util.h