summaryrefslogtreecommitdiff
path: root/src/pack.h
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-06-18 17:13:12 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-06-23 21:50:36 +0200
commitb3b66c57930358467395fc3a5bca87edefd25cf4 (patch)
tree1ca1c8fd8bf8fd69156c566a83ac12375b427a5e /src/pack.h
parent1589aa0c4d48fb130d8a5db28c45cd3d173cde6d (diff)
downloadlibgit2-b3b66c57930358467395fc3a5bca87edefd25cf4.tar.gz
Share packs across repository instancescmn/global-mwf
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.
Diffstat (limited to 'src/pack.h')
-rw-r--r--src/pack.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pack.h b/src/pack.h
index 610e70c18..34d37d907 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -90,6 +90,7 @@ struct git_pack_file {
git_mwindow_file mwf;
git_map index_map;
git_mutex lock; /* protect updates to mwf and index_map */
+ git_atomic refcount;
uint32_t num_objects;
uint32_t num_bad_objects;
@@ -123,6 +124,8 @@ typedef struct git_packfile_stream {
size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type);
+int git_packfile__name(char **out, const char *path);
+
int git_packfile_unpack_header(
size_t *size_p,
git_otype *type_p,