diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-11-07 09:59:25 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-11-06 20:31:28 -0800 |
commit | c9486eb04dd99fc00df3e68f9b908f9ad7ff9728 (patch) | |
tree | 1604f80dc18373e70f69c3b0578c74846a0d623d /pack.h | |
parent | 473935188cc9b0363b30553f23d816231a66cb44 (diff) | |
download | git-c9486eb04dd99fc00df3e68f9b908f9ad7ff9728.tar.gz |
fsck: avoid reading every object twice
During verify_pack() all objects are read for SHA-1 check. Then
fsck_sha1() is called on every object, which read the object again
(fsck_sha1 -> parse_object -> read_sha1_file).
Avoid reading an object twice, do fsck_sha1 while we have an object
uncompressed data in verify_pack.
On git.git, with this patch I got:
$ /usr/bin/time ./git fsck >/dev/null
98.97user 0.90system 1:40.01elapsed 99%CPU (0avgtext+0avgdata 616624maxresident)k
0inputs+0outputs (0major+194186minor)pagefaults 0swaps
Without it:
$ /usr/bin/time ./git fsck >/dev/null
231.23user 2.35system 3:53.82elapsed 99%CPU (0avgtext+0avgdata 636688maxresident)k
0inputs+0outputs (0major+461629minor)pagefaults 0swaps
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack.h')
-rw-r--r-- | pack.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -70,10 +70,13 @@ struct pack_idx_entry { off_t offset; }; + +typedef int (*verify_fn)(const unsigned char*, enum object_type, unsigned long, void*, int*); + extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, const struct pack_idx_option *, unsigned char *sha1); extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr); extern int verify_pack_index(struct packed_git *); -extern int verify_pack(struct packed_git *); +extern int verify_pack(struct packed_git *, verify_fn fn); extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t); extern char *index_pack_lockfile(int fd); extern int encode_in_pack_object_header(enum object_type, uintmax_t, unsigned char *); |