Re: [PATCH v2 3/3] grep: disable threading in all but worktree case
- From
Jeff King <peff@peff.net>
- Date
- Dec 7, 2011, 04:24 UTC
- Message-ID
- <20111207042431.GA10765@sigill.intra.peff.net>
- In-Reply-To
- <4EDE9BBA.2010409@lsrfire.ath.cx>
On Tue, Dec 06, 2011 at 11:48:26PM +0100, René Scharfe wrote:
Show 6 quoted lines
> #ifndef NO_PTHREADS
> - if (use_threads) {
> + if (nr_threads > 0) {
> grep_sha1_async(opt, name, sha1);
> return 0;
> } elseShould this be "if (nr_threads > 1)"?
As a user, I would do:
git grep --threads=1 ...
if I wanted a single-threaded process. Instead, we actually spawn a sub-thread and do all of the locking, which has a measurable cost:
$ time git grep --threads=0 SIMPLE HEAD >/dev/null real 0m2.994s user 0m2.932s sys 0m0.060s
$ time git grep --threads=1 SIMPLE HEAD >/dev/null real 0m3.407s user 0m3.392s sys 0m0.140s
Should --threads=1 be equivalent to --threads=0?
-Peff