From: Jeff King <peff@peff.net>
To: Stefan Saasen <ssaasen@atlassian.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 1/2] sha1_file: freshen pack objects before loose
Date: Mon, 20 Apr 2015 15:54:03 -0400 [thread overview]
Message-ID: <20150420195403.GA15760@peff.net> (raw)
In-Reply-To: <20150420195337.GA15447@peff.net>
When writing out an object file, we first check whether it
already exists and if so optimize out the write. Prior to
33d4221, we did this by calling has_sha1_file(), which will
check for packed objects followed by loose. Since that
commit, we check loose objects first.
For the common case of a repository whose objects are mostly
packed, this means we will make a lot of extra access()
system calls checking for loose objects. We should follow
the same packed-then-loose order that all of our other
lookups use.
Reported-by: Stefan Saasen <ssaasen@atlassian.com>
Signed-off-by: Jeff King <peff@peff.net>
---
sha1_file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sha1_file.c b/sha1_file.c
index 88f06ba..822aaef 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3014,7 +3014,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign
write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen);
if (returnsha1)
hashcpy(returnsha1, sha1);
- if (freshen_loose_object(sha1) || freshen_packed_object(sha1))
+ if (freshen_packed_object(sha1) || freshen_loose_object(sha1))
return 0;
return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);
}
--
2.4.0.rc2.384.g7297a4a
next prev parent reply other threads:[~2015-04-20 19:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-17 7:30 [BUG] Performance regression due to #33d4221: write_sha1_file: freshen existing objects Stefan Saasen
2015-04-17 14:03 ` Jeff King
2015-04-17 15:50 ` Junio C Hamano
2015-04-18 3:35 ` Stefan Saasen
2015-04-20 19:53 ` Jeff King
2015-04-20 19:54 ` Jeff King [this message]
2015-04-21 0:46 ` [PATCH 1/2] sha1_file: freshen pack objects before loose Stefan Saasen
2015-04-20 19:55 ` [PATCH 2/2] sha1_file: only freshen packs once per run Jeff King
2015-04-21 0:45 ` Stefan Saasen
2015-04-20 20:04 ` [BUG] Performance regression due to #33d4221: write_sha1_file: freshen existing objects Junio C Hamano
2015-04-20 20:09 ` Jeff King
2015-04-20 20:12 ` Junio C Hamano
2015-04-20 20:28 ` Jeff King
2015-04-21 1:49 ` Stefan Saasen
2015-04-21 17:05 ` Junio C Hamano
2015-04-21 21:45 ` Junio C Hamano
2015-04-22 1:46 ` Stefan Saasen
2015-04-22 22:00 ` Junio C Hamano
2015-04-22 0:04 ` Stefan Saasen
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=20150420195403.GA15760@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ssaasen@atlassian.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.