summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8522148)
raw | patch | inline | side by side (parent: 8522148)
author | Nicolas Pitre <nico@cam.org> | |
Fri, 29 Aug 2008 20:08:02 +0000 (16:08 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 30 Aug 2008 04:51:28 +0000 (21:51 -0700) |
It should be more efficient to use nicely aligned buffer sizes, either
for filesystem operations or SHA1 checksums. Also, using a relatively
small nominal size might allow for the data to remain in L1 cache
between both SHA1_Update() calls.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for filesystem operations or SHA1 checksums. Also, using a relatively
small nominal size might allow for the data to remain in L1 cache
between both SHA1_Update() calls.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pack-write.c | patch | blob | history |
diff --git a/pack-write.c b/pack-write.c
index f9776c51facbcf289ca04b7475145a7f967b2f5a..939ed56362d3c29bfc64e8cca91032df9a57961e 100644 (file)
--- a/pack-write.c
+++ b/pack-write.c
unsigned char *partial_pack_sha1,
off_t partial_pack_offset)
{
- static const int buf_sz = 128 * 1024;
+ int aligned_sz, buf_sz = 8 * 1024;
SHA_CTX old_sha1_ctx, new_sha1_ctx;
struct pack_header hdr;
char *buf;
partial_pack_offset -= sizeof(hdr);
buf = xmalloc(buf_sz);
+ aligned_sz = buf_sz - sizeof(hdr);
for (;;) {
ssize_t m, n;
- m = (partial_pack_sha1 && partial_pack_offset < buf_sz) ?
- partial_pack_offset : buf_sz;
+ m = (partial_pack_sha1 && partial_pack_offset < aligned_sz) ?
+ partial_pack_offset : aligned_sz;
n = xread(pack_fd, buf, m);
if (!n)
break;
die("Failed to checksum %s: %s", pack_name, strerror(errno));
SHA1_Update(&new_sha1_ctx, buf, n);
+ aligned_sz -= n;
+ if (!aligned_sz)
+ aligned_sz = buf_sz;
+
if (!partial_pack_sha1)
continue;