From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
John Hsing <tsyj2007@gmail.com>,
Matthieu Moy <matthieu.moy@grenoble-inp.fr>,
git@vger.kernel.org
Subject: Re: [PATCH] read-cache.c: fix index memory allocation
Date: Tue, 25 Oct 2011 20:00:04 +0200 [thread overview]
Message-ID: <4EA6F924.6060208@lsrfire.ath.cx> (raw)
In-Reply-To: <CACsJy8A7yVk15aAgqDkKTz31rChA7Oj-kS2VT2y2tWS6h01GyA@mail.gmail.com>
Am 25.10.2011 02:01, schrieb Nguyen Thai Ngoc Duy:
> On Tue, Oct 25, 2011 at 10:34 AM, Nguyen Thai Ngoc Duy
> <pclouds@gmail.com> wrote:
>> "git status" is slow. If your changes causes slowdown, it won't likely
>> stand out while other fast commands may show (read_cache() is used in
>> nearly all commands). So I tested using the following patch.
>>
>> The result on linux-2.6 shows about 10-20 us slowdown per each
>> read_cache() call (30-40 us on webkit, ~50k files) I think your patch
>> is good enough :-)
>
> That was with -O0 by the way. valgrind/massif shows about 200kb memory
> more with your patch on webkit repository (7.497 MB vs 7.285 MB),
> using the same test, so memory overhead is ok too.
We can reduce that a bit -- unless block allocation of index entries
is still done somewhere.
-- >8 --
Subject: [PATCH 2/1] cache.h: put single NUL at end of struct cache_entry
Since in-memory index entries are allocated individually now, the
variable slack at the end meant to provide an eight byte alignment
is not needed anymore. Have a single NUL instead. This saves zero
to seven bytes for an entry, depending on its filename length.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
cache.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cache.h b/cache.h
index ec0e571..bd106b5 100644
--- a/cache.h
+++ b/cache.h
@@ -306,7 +306,7 @@ static inline unsigned int canon_mode(unsigned int mode)
}
#define flexible_size(STRUCT,len) ((offsetof(struct STRUCT,name) + (len) + 8) & ~7)
-#define cache_entry_size(len) flexible_size(cache_entry,len)
+#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
#define ondisk_cache_entry_size(len) flexible_size(ondisk_cache_entry,len)
#define ondisk_cache_entry_extended_size(len) flexible_size(ondisk_cache_entry_extended,len)
--
1.7.7
next prev parent reply other threads:[~2011-10-25 18:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-22 0:20 a bug when execute "git status" in git version 1.7.7.431.g89633 John Hsing
2011-10-23 8:25 ` Matthieu Moy
2011-10-23 8:35 ` John Hsing
2011-10-23 13:25 ` René Scharfe
2011-10-23 14:28 ` René Scharfe
2011-10-23 16:29 ` Jeff King
2011-10-23 17:50 ` René Scharfe
2011-10-24 1:01 ` [PATCH] read-cache.c: fix index memory allocation René Scharfe
2011-10-24 7:07 ` Junio C Hamano
2011-10-24 15:59 ` René Scharfe
2011-10-24 21:59 ` René Scharfe
2011-10-24 23:34 ` Nguyen Thai Ngoc Duy
2011-10-25 0:01 ` Nguyen Thai Ngoc Duy
2011-10-25 18:00 ` René Scharfe [this message]
2011-10-25 16:24 ` Junio C Hamano
2011-10-24 7:28 ` Junio C Hamano
2011-10-24 15:52 ` René Scharfe
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=4EA6F924.6060208@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=matthieu.moy@grenoble-inp.fr \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=tsyj2007@gmail.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).