From: Nicolas Pitre <nico@cam.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 5/5] fixup_pack_header_footer(): use nicely aligned buffer sizes
Date: Fri, 29 Aug 2008 16:08:02 -0400 [thread overview]
Message-ID: <1220040482-10108-6-git-send-email-nico@cam.org> (raw)
In-Reply-To: <1220040482-10108-5-git-send-email-nico@cam.org>
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>
---
pack-write.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/pack-write.c b/pack-write.c
index f9776c5..939ed56 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -167,7 +167,7 @@ void fixup_pack_header_footer(int pack_fd,
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;
@@ -188,10 +188,11 @@ void fixup_pack_header_footer(int pack_fd,
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;
@@ -199,6 +200,10 @@ void fixup_pack_header_footer(int pack_fd,
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;
--
1.6.0.1.212.g35f9f
next prev parent reply other threads:[~2008-08-29 20:09 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-25 16:46 "failed to read delta base object at..." J. Bruce Fields
2008-08-25 18:58 ` Nicolas Pitre
2008-08-25 21:18 ` J. Bruce Fields
2008-08-25 19:01 ` Linus Torvalds
2008-08-25 21:31 ` J. Bruce Fields
2008-08-25 21:37 ` Linus Torvalds
2008-08-25 22:13 ` J. Bruce Fields
2008-08-25 23:59 ` Linus Torvalds
2008-08-26 20:43 ` Jason McMullan
2008-08-26 21:01 ` Jason McMullan
2008-08-27 17:05 ` Linus Torvalds
2008-08-27 19:17 ` Nicolas Pitre
2008-08-27 19:48 ` Linus Torvalds
2008-08-27 20:46 ` Nicolas Pitre
2008-08-29 2:05 ` [PATCH 0/3] don't let disk corruptions escape pack SHA1 checksum Nicolas Pitre
2008-08-29 2:07 ` [PATCH 1/3] improve reliability of fixup_pack_header_footer() Nicolas Pitre
2008-08-29 2:07 ` [PATCH 2/3] pack-objects: use fixup_pack_header_footer()'s validation mode Nicolas Pitre
2008-08-29 2:07 ` [PATCH 3/3] index-pack: " Nicolas Pitre
2008-08-29 4:44 ` [PATCH 1/3] improve reliability of fixup_pack_header_footer() Shawn O. Pearce
2008-08-29 13:08 ` Nicolas Pitre
2008-08-29 14:30 ` Shawn O. Pearce
2008-08-29 20:07 ` [PATCH 0/5] pack header rewriting improvements Nicolas Pitre
2008-08-29 20:07 ` [PATCH 1/5] pack-objects: improve returned information from write_one() Nicolas Pitre
2008-08-29 20:07 ` [PATCH 2/5] improve reliability of fixup_pack_header_footer() Nicolas Pitre
2008-08-29 20:08 ` [PATCH 3/5] pack-objects: use fixup_pack_header_footer()'s validation mode Nicolas Pitre
2008-08-29 20:08 ` [PATCH 4/5] index-pack: " Nicolas Pitre
2008-08-29 20:08 ` Nicolas Pitre [this message]
2008-08-31 7:10 ` [PATCH 5/5] fixup_pack_header_footer(): use nicely aligned buffer sizes Junio C Hamano
2008-08-29 20:14 ` [PATCH 1/3] improve reliability of fixup_pack_header_footer() Nicolas Pitre
2008-08-29 4:55 ` [PATCH 0/3] don't let disk corruptions escape pack SHA1 checksum Shawn O. Pearce
2008-08-26 20:55 ` "failed to read delta base object at..." J. Bruce Fields
2008-08-27 20:14 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220040482-10108-6-git-send-email-nico@cam.org \
--to=nico@cam.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).