Skip to contentSkip to conversation

prepare_packed_git(): sort packs by age and localness.

PATCH In review Junio C Hamano 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 prepare_packed_git(): sort packs by age and localness.

When accessing objects, we first look for them in packs that are linked together in the reverse order of discovery.

Since younger packs tend to contain more recent objects, which are more likely to be accessed often, and local packs tend to contain objects more relevant to our specific projects, sort the list of packs before starting to access them. In addition, favoring local packs over the ones borrowed from alternates can be a win when alternates are mounted on network file systems.

---
 cache.h     |    2 ++
 sha1_file.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
cache.h +2 -0
index ae25759..db3a000 100644
@@ -373,6 +373,7 @@ extern struct packed_git {
 	struct packed_git *next;
 	struct pack_window *windows;
 	uint32_t *index_base;
+	time_t mtime;
 	off_t index_size;
 	off_t pack_size;
 	int pack_fd;
@@ -431,6 +432,7 @@ extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
 extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
 extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
 extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
+void rearrange_packed_git(void);
 
 /* Dumb servers support */
 extern int update_server_info(int);
sha1_file.c +58 -0

76 lines not on this page · raw message

Signature · 1 line
1.5.0.3.942.g299fc
#1 lore raw
Quoted 9 lines · Junio C Hamano

When accessing objects, we first look for them in packs that are linked together in the reverse order of discovery.

Since younger packs tend to contain more recent objects, which are more likely to be accessed often, and local packs tend to contain objects more relevant to our specific projects, sort the list of packs before starting to access them. In addition, favoring local packs over the ones borrowed from alternates can be a win when alternates are mounted on network file systems.

ACK. But...

cache.h extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); · line 432

Quoted 3 lines
cache.h +1 -0
@@ -431,6 +432,7 @@ extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
+void rearrange_packed_git(void);

Is that really necessary to make public?

Signature · 1 line
Shawn.
#2 lore raw
Quoted 11 lines · Shawn O. Pearce
Quoted 9 lines · Junio C Hamano

When accessing objects, we first look for them in packs that are linked together in the reverse order of discovery.

Since younger packs tend to contain more recent objects, which are more likely to be accessed often, and local packs tend to contain objects more relevant to our specific projects, sort the list of packs before starting to access them. In addition, favoring local packs over the ones borrowed from alternates can be a win when alternates are mounted on network file systems.

Quoted 7 lines

ACK. But...

cache.h extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); · line 432

Quoted 3 lines
cache.h +1 -0
@@ -431,6 +432,7 @@ extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
+void rearrange_packed_git(void);

Is that really necessary to make public?

The next patch in the series was going to sort in a different order (giving it a parameter to control the sort order) that is more suitable while repacking, but it seems that the patch is not needed.