From: Avi Kivity <avi@redhat.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] lookup_object(): Speed up 'git gc' by 12%, by reducing hash chain length
Date: Sun, 01 May 2011 16:21:40 +0300 [thread overview]
Message-ID: <4DBD5E64.507@redhat.com> (raw)
In-Reply-To: <20110427213502.GA13647@elte.hu>
On 04/28/2011 12:35 AM, Ingo Molnar wrote:
> : while ((obj = obj_hash[i]) != NULL) {
> 4.13 : 498316: eb 1f jmp 498337<lookup_object+0x47>
> 0.00 : 498318: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
> 0.00 : 49831f: 00
> : if (!hashcmp(sha1, obj->sha1))
> 1.48 : 498320: 48 8d 78 04 lea 0x4(%rax),%rdi
> 0.02 : 498324: 4c 89 d6 mov %r10,%rsi
> 0.00 : 498327: 4c 89 d9 mov %r11,%rcx
> 26.12 : 49832a: f3 a6 repz cmpsb %es:(%rdi),%ds:(%rsi)
> 17.12 : 49832c: 74 14 je 498342<lookup_object+0x52>
> : break;
rep cmps can be very slow on some machines, and in particular, rep cmpsb
is optimized for really small strings (the tail of a larger rep cmps[lq]
run).
I think that if you'll replace hashcmp() by something like
static inline bool hashcmp(const unsigned char *sha1, const unsigned
char *sha2)
{
unsigned long cmp;
cmp = *(uint64_t *)sha1 ^ *(unint64_t *)sha2;
cmp |= *(uint64_t *)(sha1 + 8) ^ *(unint64_t *)(sha2 + 8);
cmp |= *(uint32_t *)(sha1 + 16) ^ *(unint32_t *)(sha2 + 16);
return cmp == 0;
}
You'll see much better results.
Of course this only works in general if the hashes are aligned.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2011-05-01 13:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 21:35 [PATCH] lookup_object(): Speed up 'git gc' by 12%, by reducing hash chain length Ingo Molnar
2011-04-29 6:22 ` Ingo Molnar
2011-04-29 6:58 ` Junio C Hamano
2011-04-29 7:26 ` Ingo Molnar
2011-04-29 7:38 ` Ingo Molnar
2011-04-29 7:46 ` Sverre Rabbelier
2011-04-29 9:50 ` Ingo Molnar
2011-04-29 16:57 ` Shawn Pearce
2011-05-01 13:21 ` Avi Kivity [this message]
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=4DBD5E64.507@redhat.com \
--to=avi@redhat.com \
--cc=git@vger.kernel.org \
--cc=mingo@elte.hu \
/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.