From: Linus Torvalds <torvalds@linux-foundation.org>
To: Fredrik Kuivinen <frekui@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3] Threaded grep
Date: Tue, 19 Jan 2010 07:41:43 -0800 (PST) [thread overview]
Message-ID: <alpine.LFD.2.00.1001190728300.13231@localhost.localdomain> (raw)
In-Reply-To: <20100119073454.GA15575@fredrik-laptop>
On Tue, 19 Jan 2010, Fredrik Kuivinen wrote:
> >
> > - git grep --no-ext-grep function
> >
> > real 0m0.241s
> > user 0m1.436s
> > sys 0m0.216s
>
> I haven't seen this overhead during my tests. But I'm _guessing_ that
> the problem is that the mutex grep_lock is held while the result is
> written to stdout. So when we are writing, no significant amount of
> work can be done by any thread. Here is a patch to fix this (applies
> on to of v3).
No, I get basically the same timings with this patch:
real 0m0.239s
user 0m1.372s
sys 0m0.280s
(that _may_ be a slight real improvement, but it's more likely that the
changing in user/sys time is just noise).
But I do think that you're right that there's a difference in my timings,
and I am comparing to the one that uses strstr(). Your patches didn't have
a "disable threads" option that I could see, so I just compared against my
old numbers.
So I guess a better example is to use a "complex" grep pattern like
'function.*a' which also gets a lot of hits, and the threaded case does
look much better in comparison. Pre-threaded:
real 0m0.921s
user 0m0.728s
sys 0m0.184s
so it's less than 2x the CPU time, and a 3.85x real-time improvement. And
that "less than 2x the CPU time" is the factor I'd expect from HT.
It's also worth noting that at least _some_ versions of glibc would
actually use different versions of subroutines for the threaded vs
non-threaded case, ie they'd avoid locking overhead when they know they
aren't running with threads. So things like stdio actually got slower when
you did any pthreads things, because suddenly glibc knew that it needed to
do locking around the functions.
Linus
next prev parent reply other threads:[~2010-01-19 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-18 10:33 [PATCH v3] Threaded grep Fredrik Kuivinen
2010-01-18 11:11 ` Johannes Sixt
2010-01-18 13:28 ` Fredrik Kuivinen
2010-01-18 13:45 ` Johannes Sixt
2010-01-18 18:05 ` Linus Torvalds
2010-01-19 7:34 ` Fredrik Kuivinen
2010-01-19 15:41 ` Linus Torvalds [this message]
[not found] ` <7vmy0bhxn1.fsf@alter.siamese.dyndns.org>
2010-01-19 0:12 ` Fredrik Kuivinen
2010-01-19 7:03 ` Johannes Sixt
2010-01-25 22:47 ` Fredrik Kuivinen
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=alpine.LFD.2.00.1001190728300.13231@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=frekui@gmail.com \
--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).