sha1_file.c: Don't retain open fds on small packs

If a pack file is small enough that its entire contents fits within
one mmap window, mmap the file and then immediately close its file
descriptor.  This reduces the number of file descriptors that are
needed to read from repositories with many tiny pack files, such
as one that has received 1000 pushes (and created 1000 small pack
files) since its last repack.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Shawn O. Pearce
2011-03-02 10:01:54 -08:00
committed by Junio C Hamano
parent 38abd9b8b4
commit d131b7afea
3 changed files with 39 additions and 6 deletions

View File

@ -899,7 +899,8 @@ extern struct packed_git {
time_t mtime;
int pack_fd;
unsigned pack_local:1,
pack_keep:1;
pack_keep:1,
do_not_close:1;
unsigned char sha1[20];
/* something like ".git/objects/pack/xxxxx.pack" */
char pack_name[FLEX_ARRAY]; /* more */