libgit2/libgit2 — pull request #2429 by carlosmn (2014-06-18 15:48:11+00:00)
Title: Share packs across repository instances

Opening the same repository multiple times will currently open the same
file multiple times, as well as map the same region of the file multiple
times. This is not necessary, as the packfile data is immutable.

Instead of opening and closing packfiles directly, introduce an
indirection and allocate packfiles globally. This does mean locking on
each packfile open, but we already use this lock for the global mwindow
list so it doesn't introduce a new contention point.

---

We probably want to add a test to actually make sure we're allocating the right number of packs, but I wanted to get some early feedback.

One thing that this means is that once you have the pack open, we won't check for permissions anymore, so if you open a repo as root and then drop to a normal user, we would still have it open as root, not that anybody should be doing anything of the sort.

/cc @vmg