summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-08-05 14:54:57 -0700
committerJunio C Hamano <gitster@pobox.com>2011-08-05 14:54:57 -0700
commit96790ca02935791b302cd65a4d092f4cdf5cd21e (patch)
tree450e39507c2024160acf6d85fc965c7cfa1f21f6 /sha1_file.c
parent5d2fc9135a35284176e99708b9b6f32c9e6eb7a2 (diff)
parent1b4bb16b9ec331c91e28d2e3e7dee5070534b6a2 (diff)
downloadgit-96790ca02935791b302cd65a4d092f4cdf5cd21e.tar.gz
Merge branch 'jc/pack-order-tweak'
* jc/pack-order-tweak: pack-objects: optimize "recency order" core: log offset pack data accesses happened
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 89d7e5eb57..d5616dca08 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1797,6 +1797,24 @@ static void *unpack_delta_entry(struct packed_git *p,
return result;
}
+static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
+{
+ static FILE *log_file;
+
+ if (!log_file) {
+ log_file = fopen(log_pack_access, "w");
+ if (!log_file) {
+ error("cannot open pack access log '%s' for writing: %s",
+ log_pack_access, strerror(errno));
+ log_pack_access = NULL;
+ return;
+ }
+ }
+ fprintf(log_file, "%s %"PRIuMAX"\n",
+ p->pack_name, (uintmax_t)obj_offset);
+ fflush(log_file);
+}
+
int do_check_packed_object_crc;
void *unpack_entry(struct packed_git *p, off_t obj_offset,
@@ -1806,6 +1824,9 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
off_t curpos = obj_offset;
void *data;
+ if (log_pack_access)
+ write_pack_access_log(p, obj_offset);
+
if (do_check_packed_object_crc && p->index_version > 1) {
struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
unsigned long len = revidx[1].offset - obj_offset;